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