Easier access to PropertyInfo

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Marco Spatz

    Easier access to PropertyInfo

    Hi,

    This is my first post on this mailing list as I am quite new to the c#
    programming language. So please be patient ;)

    I am currently developing a small framework that can connect two properties
    of two objects. Therefore I create a Connection object, that gets the input
    object i and the PropertyInfo of the property that should be used as input,
    and an output object o and the PropertyInfo of the property that acts as
    the output. A call for creating the connection currently looks like this :

    graph.AddConnec tion(
    i, i.GetType().Get Property("Input "),
    o, o.GetType().Get Property("Outpu t"));

    This is ok, but not satisfying for me :D.
    I want the user of the framework to be able to create a connection like
    this:

    graph.AddConnec tion(i.Input, o.Output);

    So by calling the properties "getter method" I want to get the object the
    getter method is called on and the property info the getter method has
    called for.

    I don't even know if this possible, but would be great ;)

    Thx for your help,

    Marco
  • Marc Gravell

    #2
    Re: Easier access to PropertyInfo

    I want the user of the framework to be able to create a connection like
    this:
    graph.AddConnec tion(i.Input, o.Output);
    A few options leap to mind:
    Te simplest is just a half-way house is to handle the lookup inside the
    method:
    graph.AddConnec tion(i, "Input", o, "Output");
    But of course it still isn't compiler-verified.

    You could do various things involving delegates and lambdas, including
    treating a lambda as the missing "infoof" operator, which would allow
    you to refer to a property directy (and safely), but simply: they are
    all quite complicated.

    That said, you are also duplicating a lot of what Binding does (at least
    for the UI).

    You haven't really indicated how it would be *used* (i.e. end-to-end,
    not just creation), which probably counts for a lot in terms of giving
    the best reply...

    Marc

    Comment

    • Marc Gravell

      #3
      Re: Easier access to PropertyInfo

      Just to warn you that this sounds *awfully* like what System.Expressi on
      does... even if just to rule it out, you might want to see what .NET 3.5
      and C# 3 bring to this...

      Marc

      Comment

      Working...