title: Design problem causing inability to get returned proper dataType
body: <p>I have an object that has properties of another object and one called <code>DataValue</code>, but the type that I want <code>DataValue</code> to return depends on information contained in the object in the other property.  I'm not convinced my way is the best way to do this.</p>
  
  <p>I have this business object called an AssetStructure.</p>
  
  <p>An AssetStructure object contains a generic list of IAssetStructureField objects, which are a series of objects that basically hold information about the data that can be held in that field, a default value of a certain datatype and some displaying information properties.  Each of the objects implementing the IAssetStructureField interface will hold different datatype.  For example, one's DefaultValue's type maybe string and the other maybe a <code>List&lt;ofCustomType&gt;</code>. </p>
  
  <p>I have my Asset object containing a generic list of objects called AssetDataField. The AssetDataField has properties of one containing the AssetStructureField and one called DataValue, the Asset's data for that StructureField.  </p>
  
  <p>My problem is datatype of AssetDataField DataValue property, it will need to be different depending on the details of the AssetStructureField object.  This StructureField may hold data representing all the user groups with access to the Asset (datatype <code>List&lt;UserGroups&gt;</code>), and another might just be a description field (datatype string), so I need the DataValue coming out of the AssetDataField to be of the same type.</p>
  
  <p>What I'm thinking of doing now, and that I feel can probably be done much better, is having the AssetDataField.DataValue return an object, and then cast it to the typeof the AssetDataField.StructureField.DefaultValue.  </p>
  
  <pre><code>object fieldValue;
  object fieldDefaultValue;
  Asset certainAsset = new Asset(32423);
  foreach (AssetDataField dataField in certainAsset.DataFields)
  {
       fieldDefaultValue = datafield.StructureField.DefaultValue;
       fieldValue = datafield.DataValue as typeof(fieldDefaultValue);
  
       // then do stuff depending on what typeof(fieldValue) is.  This is where I
       // see things getting particularly ugly.  Not only just because that
       // this class here will need to know the possible types that may be 
       // returned, so it can deal.
  
       if (typeof(fieldValue) == whatever)
       {
            // deal;
       }
       else if (typeof(fieldValue) == whatever2)
       {
            // deal differently;
       }
  }
  </code></pre>
  
  <p>Does anyone have any suggestions?  I am not a opposed, at all, to a complete redo. I'm really sorry this is so long-winded, I just wanted to try and explain the situation well.  I tried to put together a UML diagram to help out, but my ArgoUML was acting up.  Thanks for any insights at all that you can provide.</p>