/// <summary> /// Returns the property descriptors for this instance. /// </summary> public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) { Guard.NotNull(() => context, context); var descriptors = base.GetProperties(context, value, attributes).Cast <PropertyDescriptor>(); // Remove descriptors for the data type of this property (string) descriptors = descriptors.Where(descriptor => descriptor.ComponentType != typeof(string)); // Get the model element being described var selection = context.Instance; ModelElement mel = selection as ModelElement; var pel = selection as PresentationElement; if (pel != null) { mel = pel.Subject; } var element = ExtensionElement.GetExtension <ArtifactExtension>(mel); if (element != null) { // Copy descriptors from owner (make Browsable) var descriptor1 = new DelegatingPropertyDescriptor(element, TypedDescriptor.CreateProperty(element, extension => extension.OnArtifactActivation), new BrowsableAttribute(true), new DefaultValueAttribute(element.GetPropertyDefaultValue <ArtifactExtension, ArtifactActivatedAction>(e => e.OnArtifactActivation))); var descriptor2 = new DelegatingPropertyDescriptor(element, TypedDescriptor.CreateProperty(element, extension => extension.OnArtifactDeletion), new BrowsableAttribute(true), new DefaultValueAttribute(element.GetPropertyDefaultValue <ArtifactExtension, ArtifactDeletedAction>(e => e.OnArtifactDeletion))); descriptors = descriptors.Concat(new[] { descriptor1, descriptor2 }); } return(new PropertyDescriptorCollection(descriptors.ToArray())); }
public void InitializeContext() { this.store.TransactionManager.DoWithinTransaction(() => { var patternModel = store.ElementFactory.CreateElement <PatternModelSchema>(); this.product = patternModel.Create <PatternSchema>(); this.product.Name = "WebService"; }); this.validationExtension = ExtensionElement.GetExtension <ValidationExtension>(this.product); }