Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / April 2008

Tip: Looking for answers? Try searching our database.

Easier access to PropertyInfo

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Marco Spatz - 28 Apr 2008 12:42 GMT
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.AddConnection(
               i, i.GetType().GetProperty("Input"),
               o, o.GetType().GetProperty("Output"));

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.AddConnection(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 - 28 Apr 2008 14:13 GMT
> I want the user of the framework to be able to create a connection like
> this:
> graph.AddConnection(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.AddConnection(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
Marco Spatz - 28 Apr 2008 14:51 GMT
Hi Marc,

thanks for your fast answer.

>> I want the user of the framework to be able to create a connection like
>> this:
[quoted text clipped - 5 lines]
> graph.AddConnection(i, "Input", o, "Output");
> But of course it still isn't compiler-verified.

But it's easier than my current approach, so if everything fails, I'll do
it that way.

> You could do various things involving delegates and lambdas, including
> treating a lambda as the missing "infoof" operator, which would allow
[quoted text clipped - 3 lines]
> That said, you are also duplicating a lot of what Binding does (at least
> for the UI).

I don't worry about complicated solutions for this problem, as long as the
usage for the user of the framework get's simpler :D.. But I'm sorry, I
forgot to mention that I'm using C# 2.0, so lambdas won't apply here I
think :(

> 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...

Ok, so here's what the framework should be used for:

The (dev) user can creates a tree graph by adding custom nodes and creating
connections. The connections are made between properties of nodes. Those
properties are marked declarative by using an [Input] or [Output]
attribute.
The nodes transfers the data from inputs to outputs on update calls, and
the connection transports the data from one node's output tp the connected
input of another node.

In my current domain, the tree represents a query to a custom datamodel.
The creation of the query is supported by a UI.

After creating the query tree, the user sets an input collection and calls
evalute on the tree. Inside, the tree nodes and connections are sorted to
be evaluated in the correct order, and then their update methods are
called.

The result of the query is the output of the last node.

Bye,

Marco
Marc Gravell - 28 Apr 2008 14:58 GMT
Just to warn you that this sounds *awfully* like what System.Expression
does... even if just to rule it out, you might want to see what .NET 3.5
and C# 3 bring to this...

Marc

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.