PC Review


Reply
Thread Tools Rate Thread

Data binding to extension method?

 
 
Seth Gecko
Guest
Posts: n/a
 
      23rd Oct 2008
Hi

Bear with me for second...

We have a complex data object used to contain chemical data about a
fluid. This fluid class is used heavily in our application and is also
available to 3rd party programmers for custom simulations. It is
therefore important that the fluid class only contain fluid relevant
data.

Our application needs to display the chemical data from the fluid and
to do this we use data binding to various Window controls. The problem
is when showing some of the data they actually depends on some
application settings, like a SimulationModel which the fluid class
itself knows nothing about.

My suggestion is to add a number of extension methods to the fluid
class which knows and handles SimulationModel, but is it possible to
data bind to these and if so, how?

A quick example to illustrate the problem:

class Fluid
{
DataTable GetInteractionParameters(SimulationModel
simulationModel)
}

class FluidDisplay
{
public static DataTable InteractionParameters (this Fluid fluid)
{
return
fluid.GetInteractionParameters(ApplicationSetting.SimulationModel);
}
}

I want to be able to data bind a control to the
FluidDisplay.InteractionParameters, is this possible?
I suspect it isn't possible, but any other suggestion to how the
problem can be solved is appreciated. Our first idea was to inherit
from Fluid and add the InteractionParameters to the inherited
FluidDisplay class, but all I get from the data layer is a Fluid and
how would I get an inherited FluidDisplay object from that?

The not so nice solution is a simple class like:

class FluidDisplay
{
public Fluid Fluid { get; set; }

public DataTable InteractionParameters ()
{
return
Fluid.GetInteractionParameters(ApplicationSetting.SimulationModel);
}
}

But as mentioned the fluid class is rather complex and have several
sub objects which also depends on SimulationModel and it would "ruin"
the structure to have all of these on the root of the object.

Comments and suggestions are welcome.

Sincere regards
....Seth
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Extension method for static method? Harlan Messinger Microsoft C# .NET 2 3rd Mar 2010 01:53 AM
binding webcontrol to a C# method that produces string with xml data jason@cyberpine.com Microsoft ASP .NET 0 22nd Sep 2006 09:08 PM
Parse method never called when data binding from class property to textedit Richard Urwin Microsoft C# .NET 3 15th Oct 2004 04:42 AM
Parse method never called when data binding from class property to textedit Richard Urwin Microsoft Dot NET Framework Forms 1 14th Oct 2004 09:43 AM
Invoke method / Late binding / passing ref variables to a method?? PJ Microsoft C# .NET 0 25th Jul 2003 10:03 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:15 AM.