My setup:
- A chart with an instance of each of two of my indicators
- The indicators share a common base class of mine
- The base class is a subclass of Indicator
- There are some properties that are the same in both indicators.
- The goal is to encapsulate those parameters
- The only possibly workable solution anyone has proposed is based on .NET reflection, allowing attribute modification from Initialize()
Here's what I have found out by using Reflection to examine the properties and attributes for my two indicators.
if one indicator has its own (local) copy of the property and the other indicator depends on the base class copy of the property all works fine:
- Neither indicator affects the other when changing the property value
- The .NET Reflection method successfully changes the Browsable attribute, and that successfully controls whether or not the property is shown in the indicators' configuration dialog.
- Neither indicator affects the other when changing the attribute's value
However, if both indicators depend on the base class property (i.e. neither has a local instance of the property)
- Neither indicator affects the other when changing the property value
- The .NET Reflection method successfully changes the Browsable attribute
- One indicator changing the attribute's value does affect the other indicator -- they both get the same attribute value. That means the property can be hidden or shown programmatically (from Initialize()) but any such action will affect both indicators. It is not possible for one to show the property and the other not to.
- I have confirmed this unpleasant aspect of attribute values both by .NET Reflection and by observing the indicators configuration dialog.
That's it -- properties in the base class do provide instance-specific values, as one would expect for non-static base class values. However, the property's attribute value is not instance-specific -- it is shared. That means, unless someone can tell me what I am missing, that using the base class to encapsulate properties is not a successful plan. Any thoughts on how to make the base class property attributes be instance-specific?
(I say instance specific, but I could live with indicator class-specific. Just not common to the whole base class, as they are at the moment.)
--EV
Comment