Example #1
0
        private static void CreateDummyWorkflowDesignerForCaching()
        {
            var workflowDesigner = new WorkflowDesigner
            {
                PropertyInspectorFontAndColorData = XamlServices.Save(ActivityDesignerHelper.GetDesignerHashTable())
            };
            var designerConfigService = workflowDesigner.Context.Services.GetService <DesignerConfigurationService>();

            if (designerConfigService != null)
            {
                // set the runtime Framework version to 4.5 as new features are in .NET 4.5 and do not exist in .NET 4
                designerConfigService.TargetFrameworkName         = new FrameworkName(".NETFramework", new Version(4, 5));
                designerConfigService.AutoConnectEnabled          = true;
                designerConfigService.AutoSplitEnabled            = true;
                designerConfigService.PanModeEnabled              = true;
                designerConfigService.RubberBandSelectionEnabled  = true;
                designerConfigService.BackgroundValidationEnabled = true;

                // prevent design-time background validation from blocking UI thread
                // Disabled for now
                designerConfigService.AnnotationEnabled = false;
                designerConfigService.AutoSurroundWithSequenceEnabled = false;
            }
            var meta = new DesignerMetadata();

            meta.Register();

            var builder = new AttributeTableBuilder();

            foreach (var designerAttribute in ActivityDesignerHelper.DesignerAttributes)
            {
                builder.AddCustomAttributes(designerAttribute.Key, new DesignerAttribute(designerAttribute.Value));
            }

            MetadataStore.AddAttributeTable(builder.CreateTable());
            workflowDesigner.Context.Services.Subscribe <DesignerView>(instance =>
            {
                instance.WorkflowShellHeaderItemsVisibility = ShellHeaderItemsVisibility.All;
                instance.WorkflowShellBarItemVisibility     = ShellBarItemVisibility.None;
                instance.WorkflowShellBarItemVisibility     = ShellBarItemVisibility.Zoom | ShellBarItemVisibility.PanMode | ShellBarItemVisibility.MiniMap;
            });
            var activityBuilder = new WorkflowHelper().CreateWorkflow("DummyWF");

            workflowDesigner.Load(activityBuilder);
        }
        public Activity Create(DependencyObject target)
        {
            string correlationHandleName = ActivityDesignerHelper.GenerateUniqueVariableNameForContext(target, correlationHandleNamePrefix);

            Variable <CorrelationHandle> requestReplyCorrelation = new Variable <CorrelationHandle> {
                Name = correlationHandleName
            };

            Receive receive = new Receive
            {
                OperationName           = "Operation1",
                ServiceContractName     = XName.Get("IService", "http://tempuri.org/"),
                CorrelationInitializers =
                {
                    new RequestReplyCorrelationInitializer
                    {
                        CorrelationHandle = new VariableValue <CorrelationHandle>{
                            Variable = requestReplyCorrelation
                        }
                    }
                }
            };


            Sequence sequence = new Sequence()
            {
                Variables  = { requestReplyCorrelation },
                Activities =
                {
                    receive,
                    new SendReply
                    {
                        DisplayName = "SendReplyToReceive",
                        Request     = receive,
                    },
                }
            };

            return(sequence);
        }