I have one nit. I noticed that the code for the built-in indicators and signals generally uses this style for properties, like this code from MovAvg_Cross_LE:
Code: Select all
private int m_length = 9;
[Input]
public int length{
get { return m_length; }
set { m_length = value; }
}
I did some hacking, and I found a shorter way to declare the same property:
Code: Select all
[DefaultValueInput(9)]
public int length{ get; set; }
I based this code on two features of C#:
1. There's a simplified way of declaring properties that only have simple getters and setters, known as "auto-implemented properties." That's described here: http://msdn.microsoft.com/en-us/library ... .110).aspx
2. By default, auto-implemented properties can't have default values. However, I tweaked this by changing the "Input" attribute to take a default value, and then used the technique described here to set the properties to their specified default values in the constructor: http://www.codeproject.com/Tips/310476/ ... implemente
To support this, I had to create two derived classes with some helper code, one for the "SignalObject" base class and one for the "InputAttribute" base class (called "DefaultValueInputAttribute" and"DefaultValueSignalObject," attached). To run this code, put the two derived classes into the "Functions" folder, and the "MovAvg_Cross_LE_Rev" file into the "Signals" folder.
Note that it would be possible for MC.net to include this code in the underlying SignalObject and InputAttribute classes. This would eliminate the need to have the additional derived classes, and allow for shorter syntax like this:
Code: Select all
[Input(9)]
public int length{ get; set; }