I have a situation where I would like objects of a certain type to be used as two different types. If one of the "base" types was an interface, that would not be a problem, but in my case it is preferable that both of them be concrete types.
I am considering adding copies of the methods and properties of one of the base types to a derived type and adding an implicit conversion from a derived type to this base type. Then users will be able to process the derived type as the base type using the duplicated methods directly, assigning it to a variable of the base type or passing it to a method that takes the base type.
It seems that this solution will satisfy my needs, but I did not miss anything? Is there a situation where this does not work, or where is it likely to add confusion instead of simplicity when using the API?
EDIT: More about my specific scenario:
This is a potential future redesign of how indicators are written in RightEdge , which is the development environment for an automated trading system. Price data are presented as a series of bars that are relevant for open, low, high and closed prices for a given period (1 minute, 1 day, etc.). Indicators perform calculations on a series of data. An example of a simple indicator is a moving average indicator, which gives a moving average of the last n values of its input, where n is set by the user. A moving average can be applied to close the panel, or it can be applied to the output of another indicator to smooth it.
Each time a new bar appears, indicators calculate a new value for their output for this line.
, (. MACD) .
, "", , . , ( ), . , SMA.Current SMA, , SMA.Output.Current. , Indicator2.Input = Indicator1; Indicator2.Input = Indicator1.Output;. , .NET, .
- , .