All pastes #801399 Raw Edit

Something

public text v1 · immutable
#801399 ·published 2007-11-29 06:15 UTC
rendered paste body
//Instead of composition, I'd like to use inheritance in this case, because I'm only 
//extending the basic functionality of the base class and I'm trying to reduce
//the amount of work that needs to be done.

//An XML file with static data is used for querying and conveying definitions eg.:
<company>
<data name="co1" value="value1"/>
<data name="co2" value="value2"/>
</company>

//Objects are created to assist in querying the XML eg.: 
public class Data
{
 protected internal Data(){}

 private string _name;
 public string Name{ get{ return _name; } internal set{ _name = value; }}

 private string _value;
 public string Value{ get{ return _value;} internal set{ _value = value;}}
}

public class Reader
{
 public Reader(){}
 public Reader(string xmlUri){...}
 //etc...

 public ICollection<Data> GetData(){}
 //etc...
}

//Now along comes a user interface...
//The XML is extended to add additional attributes(visible,readonly) for UI purposes eg.:
<company>
<data name="co1" value="value1" visible="true" readonly="true"/>
<data name="co1" value="value2" visible="false" readonly="true"/>
</company>

//the objects are extended
public class DataEx : Data
{
  protected internal DataEx() : base(){}
  
  private string _readOnly;
  public string ReadOnly { get{ return _readOnly; } internal set{ _readOnly = value; }}
}

public class UIReader : Reader
{
  //In order to get this to work properly, I have to shadow the base
  //class's GetData method and do alot of work on reimplementing
  //the method and then populating DataEx(the extended version of Data)
  public ICollection<Data> GetData(){ //lots-o-damn code ...}
 
}