Class methods in ECO
CapableObjects Forums
Home       Members    Calendar    Who's On
Welcome Guest ( Login | Register )
        



Class methods in ECO Expand / Collapse
Author
Message
Posted 2009-02-08 18:05:28
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 2009-02-16 17:50:38
Posts: 5, Visits: 66
Hello everyone!
I am very new to ECO. Could someone please explain me about the class methods concept in ECO. For example, in ECO4 you can create a method in your model for some class, then in the Body you can specify some actions using EAL, generate the code and everything should work.

As an problematic example here is a part of the model (modeling the growth of a plant depending on a weather conditions):
PlantGrowth (Plant) 1 --- 0..* (Weather) Weather
In the Weather class I want to have a method GetWeather(). It should take PlantGrowth.Date and assign it's value to self.Date. Then I need to retrieve some data from external database using the same Date as a WHERE clause. Where should I set the connection and assign the retrieved values to the Weather object?
I have managed to do that in form's code using CurrencyManagerHandle, knowing both the current PlantGrowth object and Weather object and working with their attributes. But how can I implement that from the model side?
Post #2231
Posted 2009-02-08 23:09:20
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Administrators
Last Login: 2010-11-30 12:17:13
Posts: 1 230, Visits: 1 382
To be able get this kind of informatoin when coding in the model, I suggest you register a service in your ecospace.

It would look something like this:

in the ecospace constructor:
RegisterEcoService(typeof(IMyService), new MyService(myConnectionString));

Where IMyService is the interface you want to be able to use in your domain classes, MyService is a class that implements this interface and myConnectoinString is just an arbitrary parameter to this class (for example the connectoin string to the external database).

In your domain claass you might write something like:

IMyService serv = AsIObject().ServiceProvider.GetEcoService(typeof(IMyService)) as IMyService;

Weather w = serv.GetWeatherByDate(aDate);

// do whatever

In ECO5, there are some new generic overloads that reduces the need for casting in the code above, but this code should work in both ECO4 and 5.


/Jonas Hogstrom [CapableObjects]
Post #2243
« Prev Topic | Next Topic »


Reading This Topic Expand / Collapse
Active Users: 0 (0 guests, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: HansKarlsen, Jonas Hogstrom, PeterMorris

Permissions Expand / Collapse

All times are GMT +1:00, Time now is 12:23

Powered By InstantForum.NET v4.1.4 © 2012
Execution: 0,172. 6 queries. Compression Disabled.