public void RegisterSubstituteTypeForMetadata(Type type, Type metadataType) { if (!registeredTypeDescriptors.ContainsKey(type)) { lock (registerSubstituteTypeForMetadataLock) { if (!registeredTypeDescriptors.ContainsKey(type)) { var originalProperties = TypeDescriptor.GetProperties(type); var originalAttributes = TypeDescriptor.GetAttributes(type); var substituteDescriptor = new AnnotatedTypeDescriptorProvider(originalAttributes.OfType <Attribute>(), originalProperties.OfType <PropertyDescriptor>(), metadataType); registeredTypeDescriptors.Add(type, substituteDescriptor); TypeDescriptor.AddProvider(this, type); } } } }
public void RegisterSubstituteTypeForMetadata(Type type, Type metadataType) { if (!registeredTypeDescriptors.ContainsKey(type)) { lock (registerSubstituteTypeForMetadataLock) { if (!registeredTypeDescriptors.ContainsKey(type)) { var originalProperties = TypeDescriptor.GetProperties(type); var originalAttributes = TypeDescriptor.GetAttributes(type); var substituteDescriptor = new AnnotatedTypeDescriptorProvider(originalAttributes.OfType<Attribute>(), originalProperties.OfType<PropertyDescriptor>(), metadataType); registeredTypeDescriptors.Add(type, substituteDescriptor); TypeDescriptor.AddProvider(this, type); } } } }