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
|