internal static void MakePropertiesReadOnly(IServiceProvider serviceProvider, object topComponent) { Hashtable hashtable = new Hashtable(); Queue queue = new Queue(); queue.Enqueue(topComponent); while (queue.Count > 0) { object instance = queue.Dequeue(); if (hashtable[instance.GetHashCode()] == null) { hashtable[instance.GetHashCode()] = instance; TypeDescriptor.AddProvider(new ReadonlyTypeDescriptonProvider(TypeDescriptor.GetProvider(instance)), instance); foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(instance, new Attribute[] { BrowsableAttribute.Yes })) { if (!descriptor.PropertyType.IsPrimitive) { object component = descriptor.GetValue(instance); if (component != null) { TypeConverter converter = TypeDescriptor.GetConverter(component); System.Workflow.ComponentModel.Design.TypeDescriptorContext context = new System.Workflow.ComponentModel.Design.TypeDescriptorContext(serviceProvider, descriptor, instance); if (converter.GetPropertiesSupported(context)) { TypeDescriptor.AddProvider(new ReadonlyTypeDescriptonProvider(TypeDescriptor.GetProvider(component)), component); queue.Enqueue(component); } } } } } } }
internal static void MakePropertiesReadOnly(IServiceProvider serviceProvider, object topComponent) { Hashtable hashtable = new Hashtable(); Queue queue = new Queue(); queue.Enqueue(topComponent); while (queue.Count > 0) { object instance = queue.Dequeue(); if (hashtable[instance.GetHashCode()] == null) { hashtable[instance.GetHashCode()] = instance; TypeDescriptor.AddProvider(new ReadonlyTypeDescriptonProvider(TypeDescriptor.GetProvider(instance)), instance); foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(instance, new Attribute[] { BrowsableAttribute.Yes })) { if (!descriptor.PropertyType.IsPrimitive) { object component = descriptor.GetValue(instance); if (component != null) { TypeConverter converter = TypeDescriptor.GetConverter(component); System.Workflow.ComponentModel.Design.TypeDescriptorContext context = new System.Workflow.ComponentModel.Design.TypeDescriptorContext(serviceProvider, descriptor, instance); if (converter.GetPropertiesSupported(context)) { TypeDescriptor.AddProvider(new ReadonlyTypeDescriptonProvider(TypeDescriptor.GetProvider(component)), component); queue.Enqueue(component); } } } } } } }