GetPropertyOwner() public method

public GetPropertyOwner ( PropertyDescriptor pd ) : object
pd PropertyDescriptor
return object
 public void GetPropertyOwnerShouldReturnExpectedValue()
 {
     var parent = TypeDescriptor.GetProvider( typeof( string ) ).GetTypeDescriptor( typeof( string ) );
     var target = new CustomTypeDescriptor<string>( parent );
     var property = target.GetProperties().Cast<PropertyDescriptor>().First();
     var owner = target.GetPropertyOwner( property );
     Assert.Equal( target, owner );
 }
Ejemplo n.º 2
0
 /// <summary>This method returns the object that should be used during invocation of members.</summary>
 /// <returns>The <see cref="T:System.Object" /> that should be used during invocation of members.</returns>
 /// <param name="type">The <see cref="T:System.Type" /> of the invocation target.</param>
 /// <param name="instance">The potential invocation target.</param>
 protected override object GetInvocationTarget(Type type, object instance)
 {
     if (type == null)
     {
         throw new ArgumentNullException("type");
     }
     if (instance == null)
     {
         throw new ArgumentNullException("instance");
     }
     if (instance is CustomTypeDescriptor)
     {
         CustomTypeDescriptor customTypeDescriptor = (CustomTypeDescriptor)instance;
         return(customTypeDescriptor.GetPropertyOwner(this));
     }
     return(base.GetInvocationTarget(type, instance));
 }