1 //----------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation. All rights reserved.
3 //----------------------------------------------------------------
5 namespace System.Activities.Presentation
7 using System.Activities.Expressions;
8 using System.Activities.Presentation.Converters;
9 using System.Activities.Presentation.Expressions;
10 using System.Activities.Presentation.Metadata;
11 using System.Activities.Presentation.PropertyEditing;
12 using System.Activities.Presentation.View;
13 using System.Activities.Presentation.View.OutlineView;
14 using System.Collections.ObjectModel;
15 using System.ComponentModel;
16 using System.Reflection;
17 using System.ServiceModel.Activities;
19 using System.Xml.Linq;
20 using Microsoft.VisualBasic.Activities;
22 class DesignerMetadata : IRegisterMetadata
24 // Called by the designer to register design-time metadata.
25 public void Register()
27 AttributeTableBuilder builder = new AttributeTableBuilder();
29 // Register Designers.
30 builder.AddCustomAttributes(typeof(Activity), new DesignerAttribute(typeof(ActivityDesigner)));
31 builder.AddCustomAttributes(typeof(ActivityBuilder), new DesignerAttribute(typeof(ActivityTypeDesigner)));
32 builder.AddCustomAttributes(typeof(ActivityBuilder<>), new DesignerAttribute(typeof(GenericActivityTypeDesigner)));
34 // Register PropertyValueEditors
35 builder.AddCustomAttributes(typeof(Argument), new EditorAttribute(typeof(ExpressionValueEditor), typeof(PropertyValueEditor)));
36 builder.AddCustomAttributes(typeof(Type), PropertyValueEditor.CreateEditorAttribute(typeof(TypePropertyEditor)));
38 builder.AddCustomAttributes(typeof(Activity<>), new EditorAttribute(typeof(ExpressionValueEditor), typeof(PropertyValueEditor)));
40 // Disable reuse of propertyvalueeditors for Arguments
41 builder.AddCustomAttributes(typeof(Argument), new EditorReuseAttribute(false));
42 builder.AddCustomAttributes(typeof(Activity<>), new EditorReuseAttribute(false));
44 //Removing all the properties except "Name" from property grid for the type SchemaType.
45 foreach (MemberInfo mi in typeof(ActivityBuilder).GetMembers())
47 if (mi.MemberType == MemberTypes.Property && !mi.Name.Equals("Name") && !mi.Name.Equals("ImplementationVersion"))
49 builder.AddCustomAttributes(typeof(ActivityBuilder), mi, new BrowsableAttribute(false));
53 // Removing all the properties property grid for the type SchemaType.
54 foreach (MemberInfo mi in typeof(ActivityBuilder<>).GetMembers())
56 builder.AddCustomAttributes(typeof(ActivityBuilder<>), mi, new BrowsableAttribute(false));
59 builder.AddCustomAttributes(typeof(Argument), new SearchableStringConverterAttribute(typeof(ArgumentSearchableStringConverter)));
60 builder.AddCustomAttributes(typeof(VisualBasicValue<>), new SearchableStringConverterAttribute(typeof(VisualBasicValueSearchableStringConverter)));
61 builder.AddCustomAttributes(typeof(Type), new SearchableStringConverterAttribute(typeof(TypeSearchableStringConverter)));
62 builder.AddCustomAttributes(typeof(ActivityAction<>),
63 new SearchableStringConverterAttribute(typeof(ActivityActionSearchableStringConverter<>)));
64 builder.AddCustomAttributes(typeof(XName), new SearchableStringConverterAttribute(typeof(XNameSearchableStringConverter)));
65 builder.AddCustomAttributes(typeof(Encoding), new SearchableStringConverterAttribute(typeof(EncodingSearchableStringConverter)));
66 builder.AddCustomAttributes(typeof(ErrorActivity), new SearchableStringConverterAttribute(typeof(EmptySearchableStringConverter)));
68 builder.AddCustomAttributes(typeof(XName), new TypeConverterAttribute(typeof(XNameConverter)));
70 builder.AddCustomAttributes(typeof(VBIdentifierName), new EditorAttribute(typeof(VBIdentifierNameEditor), typeof(PropertyValueEditor)));
71 builder.AddCustomAttributes(typeof(VBIdentifierName), new EditorReuseAttribute(false));
73 ExpressionTextBox.RegisterExpressionActivityEditor(VisualBasicEditor.ExpressionLanguageName, typeof(VisualBasicEditor), VisualBasicEditor.CreateExpressionFromString);
74 builder.AddCustomAttributes(typeof(VisualBasicValue<>), new ExpressionMorphHelperAttribute(typeof(VisualBasicExpressionMorphHelper)));
75 builder.AddCustomAttributes(typeof(VisualBasicReference<>), new ExpressionMorphHelperAttribute(typeof(VisualBasicExpressionMorphHelper)));
76 builder.AddCustomAttributes(typeof(VisualBasicValue<>), new FeatureAttribute(typeof(VisualBasicValueValidationFeature)));
77 builder.AddCustomAttributes(typeof(VisualBasicReference<>), new FeatureAttribute(typeof(VisualBasicReferenceValidationFeature)));
79 builder.AddCustomAttributes(typeof(Literal<>), new ExpressionMorphHelperAttribute(typeof(NonTextualExpressionMorphHelper)));
80 builder.AddCustomAttributes(typeof(VariableValue<>), new ExpressionMorphHelperAttribute(typeof(NonTextualExpressionMorphHelper)));
81 builder.AddCustomAttributes(typeof(VariableReference<>), new ExpressionMorphHelperAttribute(typeof(NonTextualExpressionMorphHelper)));
83 builder.AddCustomAttributes(typeof(Activity), new ShowInOutlineViewAttribute());
84 builder.AddCustomAttributes(typeof(Collection<Activity>), new ShowInOutlineViewAttribute());
88 Type type = typeof(ActivityDelegate);
89 builder.AddCustomAttributes(type, new ShowInOutlineViewAttribute() { PromotedProperty = "Handler" });
91 type = typeof(ActivityBuilder);
92 builder.AddCustomAttributes(type, new ShowInOutlineViewAttribute());
93 builder.AddCustomAttributes(type, type.GetProperty("Implementation"), new ShowPropertyInOutlineViewAttribute() { CurrentPropertyVisible = false });
95 type = typeof(WorkflowService);
96 builder.AddCustomAttributes(type, type.GetProperty("Body"), new ShowPropertyInOutlineViewAttribute() { CurrentPropertyVisible = false });
98 builder.AddCustomAttributes(typeof(WorkflowIdentity), new TypeConverterAttribute(typeof(ExpandableObjectConverter)));
99 builder.AddCustomAttributes(typeof(Version), new EditorAttribute(typeof(VersionPropertyValueEditor), typeof(PropertyValueEditor)));
101 // Apply the metadata
102 MetadataStore.AddAttributeTable(builder.CreateTable());