private void RegisterMetadata() { DesignerMetadata metaData = new DesignerMetadata(); metaData.Register(); AttributeTableBuilder builder = new AttributeTableBuilder(); MetadataStore.AddAttributeTable(builder.CreateTable()); }
// <summary> // Initializes the metadata provided by this class. Multiple class // are ignored. // </summary> public static void Initialize() { if (_initialized) { return; } // Introduce any Cider-specific customizations AttributeTableBuilder builder = new AttributeTableBuilder(); // Make Name and FlowDirection properties browsable. The reason why // these attributes are here instead of in the BaseOverridesAttributeTable // is because the BaseAttributeTable explicitly hides these properties // and adding conflicting attributes to the same table (via BaseOverridesAttributeTable // which derives from BaseAttributeTable) currently results in unspeciefied // behavior. Hence we use this table to deal with these attributes. // MakeBasic(builder, typeof(FrameworkElement), FrameworkElement.FlowDirectionProperty); MakeBasic(builder, typeof(Control), Control.NameProperty); // Note: Add any new attributes here or into System.Activities.Presentation.Developer / // System.Activities.Presentation.Internal.Metadata.BaseOverridesAttributeTable MetadataStore.AddAttributeTable(builder.CreateTable()); _initialized = true; }
static void Main(string[] args) { // First, we will print out all attributes that are on string by default AttributeCollection attributeCollection = TypeDescriptor.GetAttributes(typeof(string)); Console.WriteLine("--------- default attributes"); OutputAttributes(attributeCollection); // Use the AttributeTableBuilder to add a new Attribute to string AttributeTableBuilder builder = new AttributeTableBuilder(); builder.AddCustomAttributes(typeof(string), new DesignerCategoryAttribute("Custom category")); MetadataStore.AddAttributeTable(builder.CreateTable()); Console.WriteLine("--------- including custom attributes"); attributeCollection = TypeDescriptor.GetAttributes(typeof(string)); OutputAttributes(attributeCollection); Console.WriteLine("--------- registering callback"); // Use the AttributeCallback to delay registering metadata until it is requested. builder = new AttributeTableBuilder(); builder.AddCallback(typeof(string), new AttributeCallback(acb => { Console.WriteLine("*** In AttributeCallback, adding a new attribute"); acb.AddCustomAttributes(new DesignTimeVisibleAttribute(false)); } ) ); MetadataStore.AddAttributeTable(builder.CreateTable()); Console.WriteLine("--------- including custom attributes added via callback"); attributeCollection = TypeDescriptor.GetAttributes(typeof(string)); OutputAttributes(attributeCollection); Console.WriteLine("Press Enter to Exit"); Console.ReadLine(); }
public void Register() { AttributeTableBuilder builder = new AttributeTableBuilder(); Type stateMachineType = typeof(StateMachine); builder.AddCustomAttributes(stateMachineType, new DesignerAttribute(typeof(StateMachineDesigner))); builder.AddCustomAttributes(stateMachineType, stateMachineType.GetProperty(StateContainerEditor.ChildStatesPropertyName), BrowsableAttribute.No); builder.AddCustomAttributes(stateMachineType, stateMachineType.GetProperty(StateMachineDesigner.VariablesPropertyName), BrowsableAttribute.No); builder.AddCustomAttributes(stateMachineType, stateMachineType.GetProperty(StateMachineDesigner.InitialStatePropertyName), BrowsableAttribute.No); Type stateType = typeof(State); builder.AddCustomAttributes(stateType, new DesignerAttribute(typeof(StateDesigner))); builder.AddCustomAttributes(stateType, stateType.GetProperty(StateDesigner.EntryPropertyName), BrowsableAttribute.No); builder.AddCustomAttributes(stateType, stateType.GetProperty(StateDesigner.ExitPropertyName), BrowsableAttribute.No); builder.AddCustomAttributes(stateType, stateType.GetProperty(StateContainerEditor.ChildStatesPropertyName), BrowsableAttribute.No); builder.AddCustomAttributes(stateType, stateType.GetProperty(StateDesigner.TransitionsPropertyName), BrowsableAttribute.No); builder.AddCustomAttributes(stateType, stateType.GetProperty(StateDesigner.IsFinalPropertyName), BrowsableAttribute.No); Type transitionType = typeof(Transition); builder.AddCustomAttributes(transitionType, new DesignerAttribute(typeof(TransitionDesigner))); builder.AddCustomAttributes(transitionType, transitionType.GetProperty(TransitionDesigner.TriggerPropertyName), BrowsableAttribute.No); builder.AddCustomAttributes(transitionType, transitionType.GetProperty(TransitionDesigner.ActionPropertyName), BrowsableAttribute.No); builder.AddCustomAttributes(transitionType, transitionType.GetProperty(TransitionDesigner.ToPropertyName), BrowsableAttribute.No); MetadataStore.AddAttributeTable(builder.CreateTable()); }
// since designer and activity are in same assembly register in static constructor static SimpleCodeActivity() { AttributeTableBuilder builder = new AttributeTableBuilder(); builder.AddCustomAttributes(typeof(SimpleCodeActivity), "RepeatCount", new EditorAttribute(typeof(CustomInlineEditor), typeof(PropertyValueEditor))); builder.AddCustomAttributes(typeof(SimpleCodeActivity), "FileName", new EditorAttribute(typeof(FilePickerEditor), typeof(DialogPropertyValueEditor))); MetadataStore.AddAttributeTable(builder.CreateTable()); }
public MainWindow() { InitializeComponent(); new BluEnergyXDesignerStart().ShowDialog(); errorService = new ValidationErrorService(this.messageListBox); originalTitle = this.Title; //register designers for the standard activities DesignerMetadata dm = new DesignerMetadata(); dm.Register(); //toolbox toolboxControl = CreateToolbox(); toolboxArea.Child = toolboxControl; CreateContextMenu(); InitializeDesigner(); StartNewWorkflow(); //override designer for the standard While activity AttributeTableBuilder atb = new AttributeTableBuilder(); atb.AddCustomAttributes(typeof(While), new DesignerAttribute(typeof(ActivityLibrary.Design.MyWhileDesigner))); MetadataStore.AddAttributeTable(atb.CreateTable()); }
public static void RegisterAll() { var builder = new AttributeTableBuilder(); HttpWorkflowServiceDesigner.RegisterMetadata(builder); HttpReceiveDesigner.RegisterMetadata(builder); MetadataStore.AddAttributeTable(builder.CreateTable()); }
void IRegisterMetadata.Register() { var builder = new AttributeTableBuilder(); Presentation.FileCopyDesigner.RegisterMetadata(builder); Presentation.FolderWatcherDesigner.RegisterMetadata(builder); Presentation.ReceiveFileChangesDesigner.RegisterMetadata(builder); MetadataStore.AddAttributeTable(builder.CreateTable()); }
public override void Initialize(EditingContext context, Type modelType) { if (context.Services.GetService<DesignerConfigurationService>().TargetFrameworkName.IsLessThan45()) { AttributeTableBuilder builder = new AttributeTableBuilder(); builder.AddCustomAttributes(typeof(FlowSwitchDefaultLink<>), "DefaultCaseDisplayName", BrowsableAttribute.No); MetadataStore.AddAttributeTable(builder.CreateTable()); } }
static SendReplyDesigner() { AttributeTableBuilder builder = new AttributeTableBuilder(); Type sendType = typeof(SendReply); builder.AddCustomAttributes(sendType, sendType.GetProperty("CorrelationInitializers"), PropertyValueEditor.CreateEditorAttribute(typeof(CorrelationInitializerValueEditor))); var categoryAttribute = new CategoryAttribute(EditorCategoryTemplateDictionary.Instance.GetCategoryTitle(CorrelationsCategoryLabelKey)); builder.AddCustomAttributes(sendType, sendType.GetProperty("CorrelationInitializers"), categoryAttribute, BrowsableAttribute.Yes, PropertyValueEditor.CreateEditorAttribute(typeof(CorrelationInitializerValueEditor))); categoryAttribute = new CategoryAttribute(EditorCategoryTemplateDictionary.Instance.GetCategoryTitle(MiscellaneousCategoryLabelKey)); builder.AddCustomAttributes(sendType, sendType.GetProperty("DisplayName"), categoryAttribute); var descriptionAttribute = new DescriptionAttribute(StringResourceDictionary.Instance.GetString("messagingValueHint", "<Value to bind>")); builder.AddCustomAttributes(sendType, sendType.GetProperty("Content"), categoryAttribute, descriptionAttribute, PropertyValueEditor.CreateEditorAttribute(typeof(SendContentPropertyEditor))); builder.AddCustomAttributes(sendType, sendType.GetProperty("Request"), categoryAttribute, PropertyValueEditor.CreateEditorAttribute(typeof(ActivityXRefPropertyEditor))); var advancedAttribute = new EditorBrowsableAttribute(EditorBrowsableState.Advanced); builder.AddCustomAttributes(sendType, sendType.GetProperty("Action"), categoryAttribute, advancedAttribute); Action = sendType.GetProperty("Action").Name; Type sendMessageContentType = typeof(SendMessageContent); Message = sendMessageContentType.GetProperty("Message").Name; DeclaredMessageType = sendMessageContentType.GetProperty("DeclaredMessageType").Name; MetadataStore.AddAttributeTable(builder.CreateTable()); Func<Activity, IEnumerable<ArgumentAccessor>> argumentAccessorGenerator = (activity) => new ArgumentAccessor[] { new ArgumentAccessor { Getter = (ownerActivity) => { SendReply sendReply = (SendReply)ownerActivity; SendMessageContent content = sendReply.Content as SendMessageContent; return content != null ? content.Message : null; }, Setter = (ownerActivity, arg) => { SendReply sendReply = (SendReply)ownerActivity; SendMessageContent content = sendReply.Content as SendMessageContent; if (content != null) { content.Message = arg as InArgument; } }, }, }; ActivityArgumentHelper.RegisterAccessorsGenerator(sendType, argumentAccessorGenerator); }
public void Register() { var builder = new AttributeTableBuilder(); builder.AddCustomAttributes(typeof (DiagnosticTrace), new DesignerAttribute(typeof (DiagnosticTraceDesigner))); builder.AddCustomAttributes(typeof (TestBookmark<string>), new DesignerAttribute(typeof (TestBookmarkDesigner))); MetadataStore.AddAttributeTable(builder.CreateTable()); }
private static void RegisterMetadata() { Type type = typeof(AzureAsyncOperation); AttributeTableBuilder builder = new AttributeTableBuilder(); builder.AddCustomAttributes(type, new Attribute[] { new DesignerAttribute(typeof(AzureOperationDesigner)) }); builder.AddCustomAttributes(type, new ActivityDesignerOptionsAttribute { AllowDrillIn = false }); builder.AddCustomAttributes(type, type.GetProperty("Operation"), new Attribute[] { BrowsableAttribute.No }); builder.AddCustomAttributes(type, type.GetProperty("Success"), new Attribute[] { BrowsableAttribute.No }); builder.AddCustomAttributes(type, type.GetProperty("Failure"), new Attribute[] { BrowsableAttribute.No }); MetadataStore.AddAttributeTable(builder.CreateTable()); }
static InitializeCorrelationDesigner() { Type type = typeof(InitializeCorrelation); AttributeTableBuilder builder = new AttributeTableBuilder(); builder.AddCustomAttributes(type, type.GetProperty("Correlation"), new DescriptionAttribute(StringResourceDictionary.Instance.GetString("messagingCorrelatesWithHint"))); builder.AddCustomAttributes(type, type.GetProperty("CorrelationData"), PropertyValueEditor.CreateEditorAttribute(typeof(CorrelationDataValueEditor)), new DescriptionAttribute(StringResourceDictionary.Instance.GetString("messagingCorrelationDataHint"))); builder.AddCustomAttributes(type, "CorrelationData", BrowsableAttribute.Yes); MetadataStore.AddAttributeTable(builder.CreateTable()); }
void IRegisterMetadata.Register() { var builder = new AttributeTableBuilder(); // Register metadata for PublishNotification activity /* Type type = typeof(Messaging.PublishNotification); builder.AddCustomAttributes(type, "Properties", new Attribute[] { BrowsableAttribute.Yes, PropertyValueEditor.CreateEditorAttribute(typeof(ArgumentDictionaryPropertyEditor)) }); builder.AddCustomAttributes(type, "Content", new Attribute[] { BrowsableAttribute.Yes, PropertyValueEditor.CreateEditorAttribute(typeof(ArgumentDictionaryPropertyEditor)) }); builder.AddCustomAttributes(type, "Metadata", new Attribute[] { BrowsableAttribute.Yes, PropertyValueEditor.CreateEditorAttribute(typeof(ArgumentDictionaryPropertyEditor)) }); */ MetadataStore.AddAttributeTable(builder.CreateTable()); }
/// <summary> /// The register. /// </summary> public void Register() { var builder = new AttributeTableBuilder(); DelayUntilTimeDesigner.RegisterMetadata(builder); InvokeWorkflowDesigner.RegisterMetadata(builder); LoadActivityDesigner.RegisterMetadata(builder); LoadAndInvokeWorkflowDesigner.RegisterMetadata(builder); LoadAssemblyDesigner.RegisterMetadata(builder); AddToDictionaryDesigner.RegisterMetadata(builder); ClearDictionaryDesigner.RegisterMetadata(builder); GetFromDictionaryDesigner.RegisterMetadata(builder); KeyExistsInDictionaryDesigner.RegisterMetadata(builder); RemoveFromDictionaryDesigner.RegisterMetadata(builder); ValueExistsInDictionaryDesigner.RegisterMetadata(builder); DelayUntilDateTimeDesigner.RegisterMetadata(builder); MetadataStore.AddAttributeTable(builder.CreateTable()); }
public static void loadSystemIcon() { AttributeTableBuilder builder = new AttributeTableBuilder(); string str = System.Environment.CurrentDirectory + @"\Microsoft.VisualStudio.Activities.dll"; Assembly sourceAssembly = Assembly.LoadFile(str); System.Resources.ResourceReader resourceReader = new System.Resources.ResourceReader(sourceAssembly.GetManifestResourceStream("Microsoft.VisualStudio.Activities.Resources.resources")); foreach (Type type in typeof(System.Activities.Activity).Assembly.GetTypes()) { if (type.Namespace == "System.Activities.Statements") { createImageToActivity(builder, resourceReader, type); } } MetadataStore.AddAttributeTable(builder.CreateTable()); }
public void Register() { AttributeTableBuilder builder = new AttributeTableBuilder(); var designers = GetType().Assembly.GetTypes(); var activities = Assembly.Load(new AssemblyName(ServiceActivitiesAssemblyName)).GetTypes(); // Register designers. foreach (var activity in activities) { var designer = designers.FirstOrDefault(d => d.Name == activity.Name + "Designer"); if (designer != null) builder.AddCustomAttributes(activity, new DesignerAttribute(designer)); } // Apply the metadata. MetadataStore.AddAttributeTable(builder.CreateTable()); }
/// <summary> /// Registers metadata for the StateMachine related designers. /// </summary> public void Register() { AttributeTableBuilder builder = new AttributeTableBuilder(); builder.AddCustomAttributes(typeof(WizardContainer), new DesignerAttribute(typeof(WizardContainerDesigner))); builder.AddCustomAttributes(typeof(Wizard), new DesignerAttribute(typeof(WizardDesigner))); builder.AddCustomAttributes(typeof(Step), new DesignerAttribute(typeof(StepDesigner))); MetadataStore.AddAttributeTable(builder.CreateTable()); }
// Ideally we need to filter out ALL new properties introduced in 4.5, for performance // reasons, we do not take this approach. Instead, we build a cache for the new properties // we want to filter out. Currently the cache is not a full cache, it only contains new properties // that affect activities. // Ideally, the cache would only contain TypeName and we load type using TypeName. // The current implementation of the cache directly references the type defined in S.A.dll and // S.SM.A.dll, this is also to save performance cost of resolving the type by type name. public static void FilterOut45Properties() { AttributeTableBuilder builder = new AttributeTableBuilder(); // System.Activities.dll builder.AddCustomAttributes(typeof(ActivityBuilder), "ImplementationVersion", BrowsableAttribute.No); builder.AddCustomAttributes(typeof(ActivityBuilder<>), "ImplementationVersion", BrowsableAttribute.No); builder.AddCustomAttributes(typeof(DynamicActivity), "ImplementationVersion", BrowsableAttribute.No); builder.AddCustomAttributes(typeof(DynamicActivity<>), "ImplementationVersion", BrowsableAttribute.No); builder.AddCustomAttributes(typeof(Flowchart), "ValidateUnconnectedNodes", BrowsableAttribute.No); builder.AddCustomAttributes(typeof(FlowDecision), "DisplayName", BrowsableAttribute.No); builder.AddCustomAttributes(typeof(FlowSwitch<>), "DisplayName", BrowsableAttribute.No); // System.ServiceModel.Activities.dll builder.AddCustomAttributes(typeof(WorkflowService), "DefinitionIdentity", BrowsableAttribute.No); builder.AddCustomAttributes(typeof(WorkflowService), "ImplementedContracts", BrowsableAttribute.No); builder.AddCustomAttributes(typeof(Send), "SecurityTokenHandle", BrowsableAttribute.No); MetadataStore.AddAttributeTable(builder.CreateTable()); }
// Called by the designer to register design-time metadata. public void Register() { AttributeTableBuilder builder = new AttributeTableBuilder(); // Register Designers. builder.AddCustomAttributes(typeof(Activity), new DesignerAttribute(typeof(ActivityDesigner))); builder.AddCustomAttributes(typeof(ActivityBuilder), new DesignerAttribute(typeof(ActivityTypeDesigner))); builder.AddCustomAttributes(typeof(ActivityBuilder<>), new DesignerAttribute(typeof(GenericActivityTypeDesigner))); // Register PropertyValueEditors builder.AddCustomAttributes(typeof(Argument), new EditorAttribute(typeof(ExpressionValueEditor), typeof(PropertyValueEditor))); builder.AddCustomAttributes(typeof(Type), PropertyValueEditor.CreateEditorAttribute(typeof(TypePropertyEditor))); builder.AddCustomAttributes(typeof(Activity<>), new EditorAttribute(typeof(ExpressionValueEditor), typeof(PropertyValueEditor))); // Disable reuse of propertyvalueeditors for Arguments builder.AddCustomAttributes(typeof(Argument), new EditorReuseAttribute(false)); builder.AddCustomAttributes(typeof(Activity<>), new EditorReuseAttribute(false)); //Removing all the properties except "Name" from property grid for the type SchemaType. foreach (MemberInfo mi in typeof(ActivityBuilder).GetMembers()) { if (mi.MemberType == MemberTypes.Property && !mi.Name.Equals("Name") && !mi.Name.Equals("ImplementationVersion")) { builder.AddCustomAttributes(typeof(ActivityBuilder), mi, new BrowsableAttribute(false)); } } // Removing all the properties property grid for the type SchemaType. foreach (MemberInfo mi in typeof(ActivityBuilder<>).GetMembers()) { builder.AddCustomAttributes(typeof(ActivityBuilder<>), mi, new BrowsableAttribute(false)); } builder.AddCustomAttributes(typeof(Argument), new SearchableStringConverterAttribute(typeof(ArgumentSearchableStringConverter))); builder.AddCustomAttributes(typeof(VisualBasicValue<>), new SearchableStringConverterAttribute(typeof(VisualBasicValueSearchableStringConverter))); builder.AddCustomAttributes(typeof(Type), new SearchableStringConverterAttribute(typeof(TypeSearchableStringConverter))); builder.AddCustomAttributes(typeof(ActivityAction<>), new SearchableStringConverterAttribute(typeof(ActivityActionSearchableStringConverter<>))); builder.AddCustomAttributes(typeof(XName), new SearchableStringConverterAttribute(typeof(XNameSearchableStringConverter))); builder.AddCustomAttributes(typeof(Encoding), new SearchableStringConverterAttribute(typeof(EncodingSearchableStringConverter))); builder.AddCustomAttributes(typeof(ErrorActivity), new SearchableStringConverterAttribute(typeof(EmptySearchableStringConverter))); builder.AddCustomAttributes(typeof(XName), new TypeConverterAttribute(typeof(XNameConverter))); builder.AddCustomAttributes(typeof(VBIdentifierName), new EditorAttribute(typeof(VBIdentifierNameEditor), typeof(PropertyValueEditor))); builder.AddCustomAttributes(typeof(VBIdentifierName), new EditorReuseAttribute(false)); ExpressionTextBox.RegisterExpressionActivityEditor(VisualBasicEditor.ExpressionLanguageName, typeof(VisualBasicEditor), VisualBasicEditor.CreateExpressionFromString); builder.AddCustomAttributes(typeof(VisualBasicValue<>), new ExpressionMorphHelperAttribute(typeof(VisualBasicExpressionMorphHelper))); builder.AddCustomAttributes(typeof(VisualBasicReference<>), new ExpressionMorphHelperAttribute(typeof(VisualBasicExpressionMorphHelper))); builder.AddCustomAttributes(typeof(VisualBasicValue<>), new FeatureAttribute(typeof(VisualBasicValueValidationFeature))); builder.AddCustomAttributes(typeof(VisualBasicReference<>), new FeatureAttribute(typeof(VisualBasicReferenceValidationFeature))); builder.AddCustomAttributes(typeof(Literal<>), new ExpressionMorphHelperAttribute(typeof(NonTextualExpressionMorphHelper))); builder.AddCustomAttributes(typeof(VariableValue<>), new ExpressionMorphHelperAttribute(typeof(NonTextualExpressionMorphHelper))); builder.AddCustomAttributes(typeof(VariableReference<>), new ExpressionMorphHelperAttribute(typeof(NonTextualExpressionMorphHelper))); builder.AddCustomAttributes(typeof(Activity), new ShowInOutlineViewAttribute()); builder.AddCustomAttributes(typeof(Collection<Activity>), new ShowInOutlineViewAttribute()); Type type = typeof(ActivityDelegate); builder.AddCustomAttributes(type, new ShowInOutlineViewAttribute() { PromotedProperty = "Handler" }); type = typeof(ActivityBuilder); builder.AddCustomAttributes(type, new ShowInOutlineViewAttribute()); builder.AddCustomAttributes(type, type.GetProperty("Implementation"), new ShowPropertyInOutlineViewAttribute() { CurrentPropertyVisible = false }); type = typeof(WorkflowService); builder.AddCustomAttributes(type, type.GetProperty("Body"), new ShowPropertyInOutlineViewAttribute() { CurrentPropertyVisible = false }); builder.AddCustomAttributes(typeof(WorkflowIdentity), new TypeConverterAttribute(typeof(ExpandableObjectConverter))); builder.AddCustomAttributes(typeof(Version), new EditorAttribute(typeof(VersionPropertyValueEditor), typeof(PropertyValueEditor))); // Apply the metadata MetadataStore.AddAttributeTable(builder.CreateTable()); }
public void Register() { AttributeTableBuilder atb = new AttributeTableBuilder(); atb.AddCustomAttributes(typeof(CalcShipping),new DesignerAttribute(typeof(CalcShippingDesigner))); MetadataStore.AddAttributeTable(atb.CreateTable()); }
void RegisterCustomMetadata() { AttributeTableBuilder builder = new AttributeTableBuilder(); builder.AddCustomAttributes(typeof(Parallel), new DesignerAttribute(typeof(CustomParallelDesigner))); MetadataStore.AddAttributeTable(builder.CreateTable()); }
void RegisterCustomMetadata() { AttributeTableBuilder builder = new AttributeTableBuilder(); builder.AddCustomAttributes(typeof(SimpleNativeActivity), new DesignerAttribute(typeof(SimpleNativeDesigner))); MetadataStore.AddAttributeTable(builder.CreateTable()); }
// Called by the designer to register any design-time metadata. // // Be aware of the accidential performance impact when adding things into this method. // In particular, pay attention to calls that will lead to loading extra assemblies. // public void Register() { AttributeTableBuilder builder = new AttributeTableBuilder(); //shared component builder.AddCustomAttributes(typeof(Collection<Constraint>), new BrowsableAttribute(false)); builder.AddCustomAttributes(typeof(string), new EditorReuseAttribute(false)); builder.AddCustomAttributes(typeof(ActivityAction), new EditorReuseAttribute(false)); builder.AddCustomAttributes(typeof(XName), new EditorReuseAttribute(false)); //Flowchart activities FlowchartDesigner.RegisterMetadata(builder); FlowSwitchDesigner.RegisterMetadata(builder); FlowDecisionDesigner.RegisterMetadata(builder); // Messaging activities ServiceDesigner.RegisterMetadata(builder); // Registering inline for designers for InitializeCorrelation, Send, Receive, SendReply, ReceiveReply activities to avoid calling // their static constructors. This will avoid instantiating the ResourceDictionary for their PropertyValueEditors during designer load. builder.AddCustomAttributes(typeof(Send), new DesignerAttribute(typeof(SendDesigner))); builder.AddCustomAttributes(typeof(Send), new ActivityDesignerOptionsAttribute { AllowDrillIn = false }); builder.AddCustomAttributes(typeof(Receive), new DesignerAttribute(typeof(ReceiveDesigner))); builder.AddCustomAttributes(typeof(Receive), new ActivityDesignerOptionsAttribute { AllowDrillIn = false }); builder.AddCustomAttributes(typeof(SendReply), new FeatureAttribute(typeof(SendReplyValidationFeature))); builder.AddCustomAttributes(typeof(SendReply), new DesignerAttribute(typeof(SendReplyDesigner))); builder.AddCustomAttributes(typeof(SendReply), new ActivityDesignerOptionsAttribute { AllowDrillIn = false }); CutCopyPasteHelper.AddDisallowedTypeForCopy(typeof(SendReply)); builder.AddCustomAttributes(typeof(ReceiveReply), new FeatureAttribute(typeof(ReceiveReplyValidationFeature))); builder.AddCustomAttributes(typeof(ReceiveReply), new DesignerAttribute(typeof(ReceiveReplyDesigner))); builder.AddCustomAttributes(typeof(ReceiveReply), new ActivityDesignerOptionsAttribute { AllowDrillIn = false }); CutCopyPasteHelper.AddDisallowedTypeForCopy(typeof(ReceiveReply)); builder.AddCustomAttributes(typeof(InitializeCorrelation), new DesignerAttribute(typeof(InitializeCorrelationDesigner))); builder.AddCustomAttributes(typeof(InitializeCorrelation), new ActivityDesignerOptionsAttribute { AllowDrillIn = false }); TransactedReceiveScopeDesigner.RegisterMetadata(builder); CorrelationScopeDesigner.RegisterMetadata(builder); //Procedural activities AssignDesigner.RegisterMetadata(builder); IfElseDesigner.RegisterMetadata(builder); InvokeMethodDesigner.RegisterMetadata(builder); DoWhileDesigner.RegisterMetadata(builder); WhileDesigner.RegisterMetadata(builder); ForEachDesigner.RegisterMetadata(builder); TryCatchDesigner.RegisterMetadata(builder); CatchDesigner.RegisterMetadata(builder); ParallelDesigner.RegisterMetadata(builder); SequenceDesigner.RegisterMetadata(builder); SwitchDesigner.RegisterMetadata(builder); CaseDesigner.RegisterMetadata(builder); //Compensation/Transaction CancellationScopeDesigner.RegisterMetadata(builder); CompensableActivityDesigner.RegisterMetadata(builder); TransactionScopeDesigner.RegisterMetadata(builder); //Misc activities PickDesigner.RegisterMetadata(builder); PickBranchDesigner.RegisterMetadata(builder); WriteLineDesigner.RegisterMetadata(builder); NoPersistScopeDesigner.RegisterMetadata(builder); InvokeDelegateDesigner.RegisterMetadata(builder); // StateMachine StateMachineDesigner.RegisterMetadata(builder); StateDesigner.RegisterMetadata(builder); TransitionDesigner.RegisterMetadata(builder); builder.AddCustomAttributes(typeof(AddToCollection<>), new FeatureAttribute(typeof(UpdatableGenericArgumentsFeature))); builder.AddCustomAttributes(typeof(RemoveFromCollection<>), new FeatureAttribute(typeof(UpdatableGenericArgumentsFeature))); builder.AddCustomAttributes(typeof(ClearCollection<>), new FeatureAttribute(typeof(UpdatableGenericArgumentsFeature))); builder.AddCustomAttributes(typeof(ExistsInCollection<>), new FeatureAttribute(typeof(UpdatableGenericArgumentsFeature))); builder.AddCustomAttributes(typeof(AddToCollection<>), new DefaultTypeArgumentAttribute(typeof(int))); builder.AddCustomAttributes(typeof(RemoveFromCollection<>), new DefaultTypeArgumentAttribute(typeof(int))); builder.AddCustomAttributes(typeof(ClearCollection<>), new DefaultTypeArgumentAttribute(typeof(int))); builder.AddCustomAttributes(typeof(ExistsInCollection<>), new DefaultTypeArgumentAttribute(typeof(int))); MetadataStore.AddAttributeTable(builder.CreateTable()); MorphHelper.AddPropertyValueMorphHelper(typeof(InArgument<>), MorphHelpers.ArgumentMorphHelper); MorphHelper.AddPropertyValueMorphHelper(typeof(OutArgument<>), MorphHelpers.ArgumentMorphHelper); MorphHelper.AddPropertyValueMorphHelper(typeof(InOutArgument<>), MorphHelpers.ArgumentMorphHelper); MorphHelper.AddPropertyValueMorphHelper(typeof(ActivityAction<>), MorphHelpers.ActivityActionMorphHelper); MorphHelper.AddPropertyValueMorphHelper(typeof(ActivityFunc<,>), MorphHelpers.ActivityFuncMorphHelper); // There is no need to keep an reference to this delayed worker since the AppDomain event handler will do it. RegisterMetadataDelayedWorker delayedWorker = new RegisterMetadataDelayedWorker(); delayedWorker.RegisterMetadataDelayed("System.Workflow.Runtime", InteropDesigner.RegisterMetadata); delayedWorker.RegisterMetadataDelayed("System.ServiceModel", RegisterMetadataForMessagingActivitiesSearchMetadata); delayedWorker.RegisterMetadataDelayed("System.ServiceModel", RegisterMetadataForMessagingActivitiesPropertyEditors); delayedWorker.WorkNowIfApplicable(); }
public void Work() { AttributeTableBuilder builder = new AttributeTableBuilder(); foreach (Action<AttributeTableBuilder> delayedWork in this.currentDelayedWorkItems) { delayedWork(builder); } MetadataStore.AddSystemAttributeTable(builder.CreateTable()); }
private static void LoadToolboxIconsForBuiltInActivities() { var builder = new AttributeTableBuilder(); var sourceAssembly = Assembly.LoadFile(Path.Combine(Directory.GetCurrentDirectory(), @"Lib\Microsoft.VisualStudio.Activities.dll")); if (sourceAssembly != null) { var stream = sourceAssembly.GetManifestResourceStream("Microsoft.VisualStudio.Activities.Resources.resources"); if (stream != null) { var resourceReader = new ResourceReader(stream); foreach (var type in typeof(Activity).Assembly.GetTypes().Where(t => t.Namespace == "System.Activities.Statements")) { CreateToolboxBitmapAttributeForActivity(builder, resourceReader, type); } } } MetadataStore.AddAttributeTable(builder.CreateTable()); }
private void InitialiseToolbox() { Control = new ToolboxControl(); AttributeTableBuilder builder = new AttributeTableBuilder(); foreach (Type type in typeof(System.Activities.Activity).Assembly.GetTypes().Where(t => t.Namespace == "System.Activities.Statements")) { CreateToolboxBitmapAttributeForActivity(builder, type); } foreach (Type type in typeof(System.ServiceModel.Activities.Receive).Assembly.GetTypes().Where(t => t.Namespace == "System.ServiceModel.Activities")) { CreateToolboxBitmapAttributeForActivity(builder, type); } foreach (Type type in typeof(System.ServiceModel.Activities.Presentation.Factories.ReceiveAndSendReplyFactory).Assembly.GetTypes().Where(t => t.Namespace == "System.ServiceModel.Activities.Presentation.Factories")) { CreateToolboxBitmapAttributeForActivity(builder, type); } foreach (Type type in typeof(System.Activities.Statements.Interop).Assembly.GetTypes().Where(t => t.Namespace == "System.Activities.Statements")) { CreateToolboxBitmapAttributeForActivity(builder, type); } MetadataStore.AddAttributeTable(builder.CreateTable()); var cat = new ToolboxCategory("Control Flow"); cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.DoWhile))); cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.ForEach<>),"ForEach<T>")); cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.If))); cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.Parallel))); cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.ParallelForEach<>),"ParallelForEach<T>")); cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.Pick))); cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.PickBranch))); cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.Sequence))); cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.Switch<>),"Switch<T>")); cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.While))); Control.Categories.Add(cat); cat = new ToolboxCategory("FlowChart"); cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.Flowchart))); cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.FlowDecision))); cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.FlowSwitch<>),"FlowSwitch<T>")); Control.Categories.Add(cat); cat = new ToolboxCategory("Messaging"); cat.Add(new ToolboxItemWrapper(typeof(System.ServiceModel.Activities.CorrelationScope))); cat.Add(new ToolboxItemWrapper(typeof(System.ServiceModel.Activities.InitializeCorrelation))); cat.Add(new ToolboxItemWrapper(typeof(System.ServiceModel.Activities.Receive))); cat.Add(new ToolboxItemWrapper(typeof(System.ServiceModel.Activities.Presentation.Factories.ReceiveAndSendReplyFactory),"ReceiveAndSendReply")); cat.Add(new ToolboxItemWrapper(typeof(System.ServiceModel.Activities.Send))); cat.Add(new ToolboxItemWrapper(typeof(System.ServiceModel.Activities.Presentation.Factories.SendAndReceiveReplyFactory),"SendAndReceiveReply")); cat.Add(new ToolboxItemWrapper(typeof(System.ServiceModel.Activities.TransactedReceiveScope))); Control.Categories.Add(cat); cat = new ToolboxCategory("Runtime"); cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.Persist))); cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.TerminateWorkflow))); Control.Categories.Add(cat); cat = new ToolboxCategory("Primitives"); cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.Assign))); cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.Delay))); cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.InvokeMethod))); cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.WriteLine))); Control.Categories.Add(cat); cat = new ToolboxCategory("Transaction"); cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.CancellationScope))); cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.CompensableActivity))); cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.Compensate))); cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.Confirm))); cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.TransactionScope))); Control.Categories.Add(cat); cat = new ToolboxCategory("Collection"); cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.AddToCollection<>),"AddToCollection<T>")); cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.ClearCollection<>),"ClearCollection<T>")); cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.ExistsInCollection<>),"ExistsInCollection<T>")); cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.RemoveFromCollection<>),"RemoveFromCollection<T>")); Control.Categories.Add(cat); cat = new ToolboxCategory("Error Handling"); cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.Rethrow))); cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.Throw))); cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.TryCatch))); Control.Categories.Add(cat); cat = new ToolboxCategory("Migration"); cat.Add(new ToolboxItemWrapper(typeof(System.Activities.Statements.Interop))); Control.Categories.Add(cat); }
static ReceiveDesigner() { AttributeTableBuilder builder = new AttributeTableBuilder(); Type receiveType = typeof(Receive); builder.AddCustomAttributes(receiveType, receiveType.GetProperty("CorrelationInitializers"), PropertyValueEditor.CreateEditorAttribute(typeof(CorrelationInitializerValueEditor))); var categoryAttribute = new CategoryAttribute(EditorCategoryTemplateDictionary.Instance.GetCategoryTitle(CorrelationsCategoryLabelKey)); var descriptionAttribute = new DescriptionAttribute(StringResourceDictionary.Instance.GetString("messagingCorrelatesWithHint", "<Correlation handle>")); builder.AddCustomAttributes(receiveType, receiveType.GetProperty("CorrelatesWith"), categoryAttribute, descriptionAttribute); builder.AddCustomAttributes(receiveType, receiveType.GetProperty("CorrelatesOn"), categoryAttribute, BrowsableAttribute.Yes, PropertyValueEditor.CreateEditorAttribute(typeof(CorrelatesOnValueEditor))); builder.AddCustomAttributes(receiveType, receiveType.GetProperty("CorrelationInitializers"), categoryAttribute, BrowsableAttribute.Yes, PropertyValueEditor.CreateEditorAttribute(typeof(CorrelationInitializerValueEditor))); categoryAttribute = new CategoryAttribute(EditorCategoryTemplateDictionary.Instance.GetCategoryTitle(MiscellaneousCategoryLabelKey)); builder.AddCustomAttributes(receiveType, receiveType.GetProperty("DisplayName"), categoryAttribute); builder.AddCustomAttributes(receiveType, receiveType.GetProperty("OperationName"), categoryAttribute); builder.AddCustomAttributes(receiveType, receiveType.GetProperty("ServiceContractName"), categoryAttribute, new TypeConverterAttribute(typeof(XNameConverter))); descriptionAttribute = new DescriptionAttribute(StringResourceDictionary.Instance.GetString("messagingValueHint", "<Value to bind>")); builder.AddCustomAttributes(receiveType, receiveType.GetProperty("Content"), categoryAttribute, descriptionAttribute, PropertyValueEditor.CreateEditorAttribute(typeof(ReceiveContentPropertyEditor))); var advancedAttribute = new EditorBrowsableAttribute(EditorBrowsableState.Advanced); builder.AddCustomAttributes(receiveType, receiveType.GetProperty("Action"), advancedAttribute, categoryAttribute); builder.AddCustomAttributes( receiveType, "KnownTypes", advancedAttribute, categoryAttribute, PropertyValueEditor.CreateEditorAttribute(typeof(TypeCollectionPropertyEditor)), new EditorOptionAttribute { Name = TypeCollectionPropertyEditor.AllowDuplicate, Value = false }); builder.AddCustomAttributes(receiveType, receiveType.GetProperty("ProtectionLevel"), advancedAttribute, categoryAttribute); builder.AddCustomAttributes(receiveType, receiveType.GetProperty("SerializerOption"), advancedAttribute, categoryAttribute); builder.AddCustomAttributes(receiveType, receiveType.GetProperty("CanCreateInstance"), advancedAttribute, categoryAttribute); Action = receiveType.GetProperty("Action").Name; Type receiveMessageContentType = typeof(ReceiveMessageContent); Message = receiveMessageContentType.GetProperty("Message").Name; DeclaredMessageType = receiveMessageContentType.GetProperty("DeclaredMessageType").Name; MetadataStore.AddAttributeTable(builder.CreateTable()); Func<Activity, IEnumerable<ArgumentAccessor>> argumentAccessorGenerator = (activity) => new ArgumentAccessor[] { new ArgumentAccessor { Getter = (ownerActivity) => { Receive receive = (Receive)ownerActivity; ReceiveMessageContent content = receive.Content as ReceiveMessageContent; return content != null ? content.Message : null; }, Setter = (ownerActivity, arg) => { Receive receive = (Receive)ownerActivity; ReceiveMessageContent content = receive.Content as ReceiveMessageContent; if (content != null) { content.Message = arg as OutArgument; } }, }, }; ActivityArgumentHelper.RegisterAccessorsGenerator(receiveType, argumentAccessorGenerator); }