示例#1
0
        void Container4()
        {
            //ReceiveActivity.ServiceOperationInfo
            //<snippet4>
            ReceiveActivity          receiveQuoteFromShipper1  = new ReceiveActivity();
            CodeActivity             shipper1ShippingQuote     = new CodeActivity();
            ContextToken             contextToken1             = new ContextToken();
            ActivityBind             activityBind1             = new ActivityBind();
            WorkflowParameterBinding workflowParameterBinding1 = new WorkflowParameterBinding();
            TypedOperationInfo       typedOperationInfo1       = new TypedOperationInfo();

            receiveQuoteFromShipper1.Activities.Add(shipper1ShippingQuote);
            contextToken1.Name = "Shipper1Context";
            contextToken1.OwnerActivityName       = "GetShippingQuotes";
            receiveQuoteFromShipper1.ContextToken = contextToken1;
            receiveQuoteFromShipper1.Name         = "receiveQuoteFromShipper1";
            activityBind1.Name = "SupplierWorkflow";
            activityBind1.Path = "quoteShipper1";
            workflowParameterBinding1.ParameterName = "quote";
            workflowParameterBinding1.SetBinding(WorkflowParameterBinding.ValueProperty, ((ActivityBind)(activityBind1)));
            receiveQuoteFromShipper1.ParameterBindings.Add(workflowParameterBinding1);
            typedOperationInfo1.ContractType = typeof(IShippingQuote);
            typedOperationInfo1.Name         = "ShippingQuote";
            receiveQuoteFromShipper1.ServiceOperationInfo = typedOperationInfo1;
            //</snippet4>
        }
        public void AddServiceOperation(OperationInfoBase operationInfo, Activity implementingActivity)
        {
            if (operationInfo == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("operationInfo");
            }

            TypedOperationInfo typedOperationInfo    = operationInfo as TypedOperationInfo;
            OperationInfo      workflowOperationInfo = operationInfo as OperationInfo;
            string             contractName          = operationInfo.GetContractFullName(null);

            // Do not add operation if the contractName is not valid. Not throwing here gives the user to fix
            // a broken contract/operation by selecting a different operation from the UI.
            if (String.IsNullOrEmpty(contractName))
            {
                return;
            }
            ServiceContractListItem serviceContract = this.serviceContracts.Find(contractName);

            if (typedOperationInfo != null)
            {
                if (serviceContract == null)
                {
                    serviceContract                  = new ServiceContractListItem(this.operationsListBox);
                    serviceContract.Validating      += new CancelEventHandler(ServiceContractValidating);
                    serviceContract.Name             = contractName;
                    serviceContract.ContractType     = typedOperationInfo.ContractType;
                    serviceContract.IsCustomContract = false;
                    AddServiceContract(serviceContract);
                }

                TypedServiceOperationListItem operationItem = new TypedServiceOperationListItem();
                operationItem.Validating += new CancelEventHandler(ServiceOperationValidating);
                operationItem.Name        = typedOperationInfo.Name;
                operationItem.Operation   = typedOperationInfo;

                operationItem.ImplementingActivities.Add(implementingActivity);
                serviceContract.AddOperation(operationItem);
            }
            else if (workflowOperationInfo != null)
            {
                if (serviceContract == null)
                {
                    serviceContract                  = new ServiceContractListItem(this.operationsListBox);
                    serviceContract.Validating      += new CancelEventHandler(ServiceContractValidating);
                    serviceContract.Name             = workflowOperationInfo.ContractName;
                    serviceContract.IsCustomContract = true;
                    AddServiceContract(serviceContract);
                }
                WorkflowServiceOperationListItem workflowOperationItem = new WorkflowServiceOperationListItem();
                workflowOperationItem.Validating += new CancelEventHandler(ServiceOperationValidating);
                workflowOperationItem.Operation   = workflowOperationInfo;
                workflowOperationItem.ImplementingActivities.Add(implementingActivity);
                serviceContract.AddOperation(workflowOperationItem);
            }
        }
示例#3
0
        void Container1()
        {
            //SendActivity.ServiceOperationInfo
            //<snippet1>
            SendActivity       RequestQuoteFromShipper3 = new SendActivity();
            TypedOperationInfo typedOperationInfo2      = new TypedOperationInfo();

            typedOperationInfo2.ContractType = typeof(IShippingRequest);
            typedOperationInfo2.Name         = "RequestShippingQuote";
            RequestQuoteFromShipper3.ServiceOperationInfo = typedOperationInfo2;
            //</snippet1>
        }
        public Form1()
        {
            InitializeComponent();

            // ���[�N�t���[�v���W�F�N�g�̃p�X��擾
            projectpath = Path.Combine(Directory.GetCurrentDirectory(), @"..\..\..\CustomWorkflowLibrary");

            // ���[�N�t���[�f�U�C�i�[�̏�����
            this.designSurface = new DesignSurface();
            loader = new MyWorkflowLoader(Path.Combine(projectpath, "Workflow1.xoml"));
            designSurface.BeginLoad(loader);

            this.workflowView = new WorkflowView((IServiceProvider) this.designSurface);
            splitContainer1.Panel1.Controls.Add(this.workflowView);
            this.workflowView.Dock = DockStyle.Fill;

            IDesignerHost designerHost = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
            designerHost.Activate();

            // �R���e�L�X�g���j���[�̕\��
            IMenuCommandService menuService = new WorkflowMenuCommandService((IServiceProvider)workflowView);
            designerHost.AddService(typeof(IMenuCommandService), menuService);

            // �Q�Ƃ���A�Z���u�� (�ꕔ) ��ݒ�
            // (�p�����[�^�� Validation �`�F�b�N�Ȃǂ̍ۂɁA���̃A�Z���u������ɂ�������)
            TypeProvider typeProvider = new TypeProvider((IServiceProvider)workflowView);
            typeProvider.AddAssemblyReference(@"..\..\..\CustomWorkflowLibrary\bin\Debug\CustomWorkflowLibrary.dll");
            designerHost.AddService(typeof(ITypeProvider), typeProvider);

            // (.NET 3.5 ReceiveActivity �� ServiceOperationInfo �𐳂����ݒ肵�Ȃ� (Validation Error �ƂȂ�) ���߈ȉ���lj�)
            SequentialWorkflowActivity rootActivity = (SequentialWorkflowActivity)designerHost.RootComponent;
            ReceiveActivity receiveActivity = (ReceiveActivity)rootActivity.Activities[0];
            TypedOperationInfo typedOperationInfo = new TypedOperationInfo();
            typedOperationInfo.ContractType = typeof(CustomWorkflowLibrary.IWorkflow1);
            typedOperationInfo.Name = "CalcData";
            receiveActivity.ServiceOperationInfo = typedOperationInfo;
        }