15b3c69be6a318de735b9cf61497f514346070ef
[mono.git] / mcs / class / referencesource / System.Activities.Presentation / System.Activities.Presentation / System / Activities / Presentation / DesignerMetadata.cs
1 //----------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation.  All rights reserved.
3 //----------------------------------------------------------------
4
5 namespace System.Activities.Presentation
6 {
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;
18     using System.Text;
19     using System.Xml.Linq;
20     using Microsoft.VisualBasic.Activities;
21
22     class DesignerMetadata : IRegisterMetadata
23     {
24         // Called by the designer to register  design-time metadata.
25         public void Register()
26         {
27             AttributeTableBuilder builder = new AttributeTableBuilder();
28
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)));
33
34             // Register PropertyValueEditors
35             builder.AddCustomAttributes(typeof(Argument), new EditorAttribute(typeof(ExpressionValueEditor), typeof(PropertyValueEditor)));
36             builder.AddCustomAttributes(typeof(Type), PropertyValueEditor.CreateEditorAttribute(typeof(TypePropertyEditor)));
37
38             builder.AddCustomAttributes(typeof(Activity<>), new EditorAttribute(typeof(ExpressionValueEditor), typeof(PropertyValueEditor)));
39
40             // Disable reuse of propertyvalueeditors for Arguments
41             builder.AddCustomAttributes(typeof(Argument), new EditorReuseAttribute(false));
42             builder.AddCustomAttributes(typeof(Activity<>), new EditorReuseAttribute(false));
43
44             //Removing all the properties except "Name" from property grid for the type SchemaType.            
45             foreach (MemberInfo mi in typeof(ActivityBuilder).GetMembers())
46             {
47                 if (mi.MemberType == MemberTypes.Property && !mi.Name.Equals("Name") && !mi.Name.Equals("ImplementationVersion"))
48                 {
49                     builder.AddCustomAttributes(typeof(ActivityBuilder), mi, new BrowsableAttribute(false));
50                 }
51             }
52
53             // Removing all the properties property grid for the type SchemaType.            
54             foreach (MemberInfo mi in typeof(ActivityBuilder<>).GetMembers())
55             {
56                 builder.AddCustomAttributes(typeof(ActivityBuilder<>), mi, new BrowsableAttribute(false));
57             }
58
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)));
67
68             builder.AddCustomAttributes(typeof(XName), new TypeConverterAttribute(typeof(XNameConverter)));
69
70             builder.AddCustomAttributes(typeof(VBIdentifierName), new EditorAttribute(typeof(VBIdentifierNameEditor), typeof(PropertyValueEditor)));            
71             builder.AddCustomAttributes(typeof(VBIdentifierName), new EditorReuseAttribute(false));
72
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)));
78
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)));
82
83             builder.AddCustomAttributes(typeof(Activity), new ShowInOutlineViewAttribute());
84             builder.AddCustomAttributes(typeof(Collection<Activity>), new ShowInOutlineViewAttribute());
85
86
87
88             Type type = typeof(ActivityDelegate);
89             builder.AddCustomAttributes(type, new ShowInOutlineViewAttribute() { PromotedProperty = "Handler" });
90
91             type = typeof(ActivityBuilder);
92             builder.AddCustomAttributes(type, new ShowInOutlineViewAttribute());
93             builder.AddCustomAttributes(type, type.GetProperty("Implementation"), new ShowPropertyInOutlineViewAttribute() { CurrentPropertyVisible = false });
94
95             type = typeof(WorkflowService);
96             builder.AddCustomAttributes(type, type.GetProperty("Body"), new ShowPropertyInOutlineViewAttribute() { CurrentPropertyVisible = false });
97
98             builder.AddCustomAttributes(typeof(WorkflowIdentity), new TypeConverterAttribute(typeof(ExpandableObjectConverter)));
99             builder.AddCustomAttributes(typeof(Version), new EditorAttribute(typeof(VersionPropertyValueEditor), typeof(PropertyValueEditor)));
100
101             // Apply the metadata
102             MetadataStore.AddAttributeTable(builder.CreateTable());
103         }
104     }
105 }