当前位置: 首页>>代码示例>>C#>>正文


C# WorkflowServiceInstance.SetupExtensions方法代码示例

本文整理汇总了C#中System.ServiceModel.Activities.Dispatcher.WorkflowServiceInstance.SetupExtensions方法的典型用法代码示例。如果您正苦于以下问题:C# WorkflowServiceInstance.SetupExtensions方法的具体用法?C# WorkflowServiceInstance.SetupExtensions怎么用?C# WorkflowServiceInstance.SetupExtensions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.ServiceModel.Activities.Dispatcher.WorkflowServiceInstance的用法示例。


在下文中一共展示了WorkflowServiceInstance.SetupExtensions方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InitializeInstance

        public static WorkflowServiceInstance InitializeInstance(PersistenceContext persistenceContext, Guid instanceId, Activity workflowDefinition, WorkflowIdentity definitionIdentity, IDictionary<XName, InstanceValue> loadedObject, WorkflowCreationContext creationContext,
            SynchronizationContext synchronizationContext, WorkflowServiceHost serviceHost, DynamicUpdateMap updateMap = null)
        {
            Fx.Assert(workflowDefinition != null, "workflowDefinition cannot be null.");
            Fx.Assert(serviceHost != null, "serviceHost cannot be null!");
            Fx.Assert(instanceId != Guid.Empty, "instanceId cannot be empty.");

            WorkflowServiceInstance workflowInstance = new WorkflowServiceInstance(workflowDefinition, definitionIdentity, instanceId, serviceHost, persistenceContext)
            {
                SynchronizationContext = synchronizationContext
            };

            // let us initalize the instance level extensions here
            workflowInstance.SetupExtensions(serviceHost.WorkflowExtensions);

            if (loadedObject != null)
            {
                InstanceValue stateValue;
                object deserializedRuntimeState;

                if (!loadedObject.TryGetValue(WorkflowNamespace.Workflow, out stateValue) || stateValue.Value == null)
                {
                    throw FxTrace.Exception.AsError(
                        new InstancePersistenceException(SR.WorkflowInstanceNotFoundInStore(instanceId)));
                }
                deserializedRuntimeState = stateValue.Value;

                if (loadedObject.TryGetValue(WorkflowServiceNamespace.CreationContext, out stateValue))
                {
                    workflowInstance.creationContext = (WorkflowCreationContext)stateValue.Value;
                }

                if (persistenceContext.IsSuspended)
                {
                    workflowInstance.state = State.Suspended;
                }
                try
                {
                    workflowInstance.Initialize(deserializedRuntimeState, updateMap);
                }
                catch (InstanceUpdateException)
                {
                    // Need to flush the tracking record for the update failure
                    workflowInstance.ScheduleAbortTracking(true);
                    throw;
                }

                if (updateMap != null)
                {
                    workflowInstance.HasBeenUpdated = true;
                }
            }
            else
            {
                IList<Handle> rootExecutionProperties = null;
                IDictionary<string, object> workflowArguments = null;
                // Provide default CorrelationScope if root activity is not CorrelationScope
                if (!(workflowDefinition is CorrelationScope))
                {
                    rootExecutionProperties = new List<Handle>(1)
                    {
                        new CorrelationHandle()
                    };
                }

                if (creationContext != null)
                {
                    workflowArguments = creationContext.RawWorkflowArguments;
                    workflowInstance.creationContext = creationContext;
                }
                workflowInstance.Initialize(workflowArguments, rootExecutionProperties);
            }

            return workflowInstance;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:75,代码来源:WorkflowServiceInstance.cs

示例2: InitializeInstance

 public static WorkflowServiceInstance InitializeInstance(PersistenceContext persistenceContext, Guid instanceId, Activity workflowDefinition, IDictionary<XName, InstanceValue> loadedObject, WorkflowCreationContext creationContext, SynchronizationContext synchronizationContext, WorkflowServiceHost serviceHost)
 {
     WorkflowServiceInstance instance = new WorkflowServiceInstance(workflowDefinition, instanceId, serviceHost, persistenceContext) {
         SynchronizationContext = synchronizationContext
     };
     instance.SetupExtensions(serviceHost.WorkflowExtensions);
     if (loadedObject != null)
     {
         InstanceValue value2;
         if (!loadedObject.TryGetValue(WorkflowNamespace.Workflow, out value2) || (value2.Value == null))
         {
             throw System.ServiceModel.Activities.FxTrace.Exception.AsError(new InstancePersistenceException(System.ServiceModel.Activities.SR.WorkflowInstanceNotFoundInStore(instanceId)));
         }
         object deserializedRuntimeState = value2.Value;
         if (loadedObject.TryGetValue(WorkflowServiceNamespace.CreationContext, out value2))
         {
             instance.creationContext = (WorkflowCreationContext) value2.Value;
         }
         if (persistenceContext.IsSuspended)
         {
             instance.state = State.Suspended;
         }
         instance.Initialize(deserializedRuntimeState);
         return instance;
     }
     IList<Handle> workflowExecutionProperties = null;
     IDictionary<string, object> workflowArgumentValues = null;
     if (!(workflowDefinition is CorrelationScope))
     {
         workflowExecutionProperties = new List<Handle>(1) {
             new CorrelationHandle()
         };
     }
     if (creationContext != null)
     {
         workflowArgumentValues = creationContext.RawWorkflowArguments;
         instance.creationContext = creationContext;
     }
     instance.Initialize(workflowArgumentValues, workflowExecutionProperties);
     return instance;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:41,代码来源:WorkflowServiceInstance.cs


注:本文中的System.ServiceModel.Activities.Dispatcher.WorkflowServiceInstance.SetupExtensions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。