/// <summary> /// Removes the given property. /// </summary> /// <param name="propertyInfo">The property being removed.</param> public virtual void RemoveProperty(PropertyInfo propertyInfo) { if (propertyInfo == null) { throw Error.ArgumentNull("propertyInfo"); } if (!propertyInfo.DeclaringType.IsAssignableFrom(ClrType)) { throw Error.Argument("propertyInfo", SRResources.PropertyDoesNotBelongToType, propertyInfo.Name, ClrType.FullName); } if (ExplicitProperties.ContainsKey(propertyInfo)) { ExplicitProperties.Remove(propertyInfo); } if (!RemovedProperties.Contains(propertyInfo)) { RemovedProperties.Add(propertyInfo); } if (_dynamicPropertyDictionary == propertyInfo) { _dynamicPropertyDictionary = null; } }
/// <summary> /// Removes the given property. /// </summary> /// <param name="propertyInfo">The property being removed.</param> public virtual void RemoveProperty(PropertyInfo propertyInfo) { if (propertyInfo == null) { throw Error.ArgumentNull("propertyInfo"); } if (!propertyInfo.ReflectedType.IsAssignableFrom(ClrType)) { throw Error.Argument("propertyInfo", SRResources.PropertyDoesNotBelongToType, propertyInfo.Name, ClrType.FullName); } if (ExplicitProperties.Keys.Any(key => key.Name.Equals(propertyInfo.Name))) { ExplicitProperties.Remove(ExplicitProperties.Keys.First(key => key.Name.Equals(propertyInfo.Name))); } if (!RemovedProperties.Any(prop => prop.Name.Equals(propertyInfo.Name))) { RemovedProperties.Add(propertyInfo); } if (_dynamicPropertyDictionary == propertyInfo) { _dynamicPropertyDictionary = null; } }
/// <summary> /// Removes the given property. /// </summary> /// <param name="propertyInfo">The property being removed.</param> public virtual void RemoveProperty(PropertyInfo propertyInfo) { if (propertyInfo == null) { throw Error.ArgumentNull("propertyInfo"); } if (!propertyInfo.ReflectedType.IsAssignableFrom(ClrType)) { throw Error.InvalidOperation(SRResources.PropertyDoesNotBelongToType, propertyInfo.Name, ClrType.FullName); } if (ExplicitProperties.ContainsKey(propertyInfo)) { ExplicitProperties.Remove(propertyInfo); } if (!RemovedProperties.Contains(propertyInfo)) { RemovedProperties.Add(propertyInfo); } }