title: Get *value* of custom property on object instance?
body: <p>Using .NET 4, C#</p>
  
  <p>Let's say I have class <code>Info</code> that extends <code>CustomTypeDescriptor</code>. An instance of class <code>Info</code> has a dictionary of <code>&lt;string, object&gt;</code> pairs, loaded at runtime.</p>
  
  <p>I'd like to be able to expose the dictionary keys as properties (so that each instance of <code>Info</code> has different properties). The values of the properties should be the corresponding values in the dictionary.</p>
  
  <p>I got around to exposing properties:</p>
  
  <pre><code>    public override PropertyDescriptorCollection GetProperties()
      {
  
          var orig = base.GetProperties();
          var newProps = dictionary.Select( kvp =&gt; 
                         TypeDescriptor.CreateProperty(
                             this.GetType(), 
                             kvp.key, 
                             typeof(string)));
          return new PropertyDescriptorCollection(
                     orig.Cast&lt;PropertyDescriptor&gt;()
                     .Concat(newProps)
                     .ToArray());
      }
  </code></pre>
  
  <p>The problem is, how do I get their values?</p>
  
  <pre><code>var info = new Info(new Dictionary&lt;string, object&gt;{{"some_property", 5}};
  var prop = TypeDescriptor.GetProperties(i_info)["some_property"];
  var val = prop.GetValue(i_info); //should return 5
  </code></pre>
  
  <p>The only way I found to get control when <code>prop.GetValue()</code> is called was to override <code>GetPropertyOwner(PropertyDescriptor pd)</code>, but the way I understand it, it expects me to return the instance of another <em>type</em> that has a matching real (compiled) property. </p>
  
  <p>I'd like to be able to write the actual implementation of the property myself (for this example, return the value in the dictionary whose key matches the property name). </p>
  
  <p>Is this possible?</p>