Select a tab to view language specific
aspect engine implementation.
First let's change the class to extend
OnPremiseAspectEngineBase
(which partially implements
IOnPremiseAspectEngine
). This has the type arguments of
IStarSignData
- the interface extending
aspect data which will be added to the
flow data, and
IAspectPropertyMetaData
- instead of
IElementPropertyMetaData
.
The existing constructor needs to change to match the OnPremiseAspectEngineBase
class. So it takes the additional arguments of a data file path, and a temporary data file path. This is the location of the data file that the aspect engine will use, and where to make a temporary copy if required.
The constructor will also read the data file containing the star signs into memory. This is done in another method so that it can also be used by the RefreshData
method when a new data file is downloaded (this is not applicable for this example as star sign data will not change).
The Init
method in this example will simply read a CSV file with the start and end dates of each star sign, which looks like:
Aries,21/03,19/04
Taurus,20/04,20/05
Gemini,21/05,20/06
Cancer,21/06,22/07
...
and add each to a list of a new class named StarSign
which has the following simple implementation:
Note that the year of the start and end date are both set to 1, as the year should be ignored, but the year 0 cannot be used in a DateTime
.
The new Init
method looks like this:
Now the abstract methods can be implemented to create a functional aspect engine.
First let's change the class to extend
OnPremiseAspectEngineBase
(which partially implements
OnPremiseAspectEngine
). This has the type arguments of
StarSignData
- the interface extending
aspect data which will be added to the
flow data, and
AspectPropertyMetaData
- instead of
ElementPropertyMetaData
.
The existing constructor needs to change to match the OnPremiseAspectEngineBase
class. So it takes the additional arguments of a data file path, and a temporary data file path. This is the location of the data file that the aspect engine will use, and where to make a temporary copy if required.
The constructor will also read the data file containing the star signs into memory. This is done in another method so that it can also be used by the refreshData
method when a new data file is downloaded (this is not applicable for this example as star sign data is static).
The init
method in this example will simply read a CSV file with the start and end dates of each star sign, which looks like:
Aries,21/03,19/04
Taurus,20/04,20/05
Gemini,21/05,20/06
Cancer,21/06,22/07
...
and add each to a list of a new class named StarSign
which has the following simple implementation:
Note that the year of the start and end date are both set to 0, as the year should be ignored.
The new init
method looks like this:
Now the abstract methods can be implemented to create a functional aspect engine.
First let's change the class to extend engine
.
The existing constructor needs to change to match the engine
class. So it takes the additional argument of a data file path. This is the location of the data file that the aspect engine will use.
The constructor will also read the data file containing the star signs into memory. This is done in another method so that it can also be used when a new data file is downloaded (this is not applicable for this example as star sign data is static).
The refresh
method in this example will simply read a JSON file with the start and end dates of each star sign, which looks like:
[
[
"Aries",
"21/03",
"19/04"
],
[
"Taurus",
"20/04",
"20/05"
],
...
and parse into objects.
The new refresh
method looks like this:
Now the abstract methods can be implemented to create a functional aspect engine.