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


C# ActivityExecutionContext.InitializeActivity方法代码示例

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


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

示例1: NotifyChangesToChildExecutors

 private void NotifyChangesToChildExecutors(IWorkflowCoreRuntime workflowCoreRuntime, Activity contextActivity, IList<WorkflowChangeAction> changeActions)
 {
     foreach (WorkflowChangeAction action in changeActions)
     {
         if (action is ActivityChangeAction)
         {
             CompositeActivity activity = contextActivity.TraverseDottedPathFromRoot(((ActivityChangeAction) action).OwnerActivityDottedPath) as CompositeActivity;
             if ((activity != null) && IsActivityExecutable(activity))
             {
                 ISupportWorkflowChanges activityExecutor = ActivityExecutors.GetActivityExecutor(activity) as ISupportWorkflowChanges;
                 if (activityExecutor == null)
                 {
                     throw new ApplicationException(SR.GetString("Error_WorkflowChangesNotSupported", new object[] { activity.GetType().FullName }));
                 }
                 using (workflowCoreRuntime.SetCurrentActivity(activity))
                 {
                     using (ActivityExecutionContext context = new ActivityExecutionContext(activity))
                     {
                         if (action is AddedActivityAction)
                         {
                             Activity activity2 = activity.Activities[((AddedActivityAction) action).Index];
                             if (IsActivityExecutable(activity2))
                             {
                                 activity2.OnActivityExecutionContextLoad(context.Activity.RootActivity.WorkflowCoreRuntime);
                                 context.InitializeActivity(activity2);
                                 activityExecutor.OnActivityAdded(context, activity2);
                             }
                         }
                         else if (action is RemovedActivityAction)
                         {
                             RemovedActivityAction action2 = (RemovedActivityAction) action;
                             if (IsActivityExecutable(action2.OriginalRemovedActivity))
                             {
                                 activityExecutor.OnActivityRemoved(context, action2.OriginalRemovedActivity);
                                 if (action2.OriginalRemovedActivity.ExecutionResult != ActivityExecutionResult.Uninitialized)
                                 {
                                     action2.OriginalRemovedActivity.Uninitialize(context.Activity.RootActivity.WorkflowCoreRuntime);
                                     action2.OriginalRemovedActivity.SetValue(Activity.ExecutionResultProperty, ActivityExecutionResult.Uninitialized);
                                 }
                                 action2.OriginalRemovedActivity.OnActivityExecutionContextUnload(context.Activity.RootActivity.WorkflowCoreRuntime);
                                 action2.OriginalRemovedActivity.Dispose();
                             }
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:49,代码来源:WorkflowChanges.cs

示例2: CreateExecutionContext

        public ActivityExecutionContext CreateExecutionContext(Activity activity)
        {
            if (this.ownerContext == null)
                throw new ObjectDisposedException("ActivityExecutionContextManager");

            if (activity == null)
                throw new ArgumentNullException("activity");

            if (!this.ownerContext.IsValidChild(activity, true))
                throw new ArgumentException(SR.GetString(SR.AEC_InvalidActivity), "activity");

            Activity copiedActivity = activity.Clone();
            ((IDependencyObjectAccessor)copiedActivity).InitializeInstanceForRuntime(this.ownerContext.Activity.WorkflowCoreRuntime);

            //Reset the cloned tree for execution.
            Queue<Activity> activityQueue = new Queue<Activity>();
            activityQueue.Enqueue(copiedActivity);

            while (activityQueue.Count != 0)
            {
                Activity clonedActivity = activityQueue.Dequeue();
                if (clonedActivity.ExecutionStatus != ActivityExecutionStatus.Initialized)
                {
                    clonedActivity.ResetAllKnownDependencyProperties();
                    CompositeActivity compositeActivity = clonedActivity as CompositeActivity;

                    if (compositeActivity != null)
                    {
                        for (int i = 0; i < compositeActivity.EnabledActivities.Count; ++i)
                        {
                            activityQueue.Enqueue(compositeActivity.EnabledActivities[i]);
                        }

                        ISupportAlternateFlow alternateFlow = compositeActivity as ISupportAlternateFlow;

                        if (alternateFlow != null)
                        {
                            for (int i = 0; i < alternateFlow.AlternateFlowActivities.Count; ++i)
                            {
                                activityQueue.Enqueue(alternateFlow.AlternateFlowActivities[i]);
                            }
                        }
                    }
                }
            }

            // get active context activities and add it to this one
            IList<Activity> activeContexts = (IList<Activity>)this.ownerContext.Activity.ContextActivity.GetValue(Activity.ActiveExecutionContextsProperty);
            if (activeContexts == null)
            {
                activeContexts = new List<Activity>();
                this.ownerContext.Activity.ContextActivity.SetValue(Activity.ActiveExecutionContextsProperty, activeContexts);
            }
            activeContexts.Add(copiedActivity);

            // prepare the copied activity as a context activity
            ActivityExecutionContextInfo contextInfo = new ActivityExecutionContextInfo(activity.QualifiedName, this.ownerContext.WorkflowCoreRuntime.GetNewContextActivityId(), Guid.NewGuid(), this.ownerContext.ContextId);
            copiedActivity.SetValue(Activity.ActivityExecutionContextInfoProperty, contextInfo);
            copiedActivity.SetValue(Activity.ActivityContextGuidProperty, contextInfo.ContextGuid);
            ActivityExecutionContext newExecutionContext = null;
            try
            {
                // inform workflow runtime
                this.ownerContext.Activity.WorkflowCoreRuntime.RegisterContextActivity(copiedActivity);

                // return the new context
                newExecutionContext = new ActivityExecutionContext(copiedActivity);
                this.executionContexts.Add(newExecutionContext);
                newExecutionContext.InitializeActivity(newExecutionContext.Activity);
                return newExecutionContext;
            }
            catch (Exception)
            {
                if (newExecutionContext != null)
                {
                    this.CompleteExecutionContext(newExecutionContext);
                }
                else
                {
                    activeContexts.Remove(copiedActivity);
                }
                throw;
            }
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:84,代码来源:ActivityExecutionContextCollection.cs

示例3: NotifyChangesToChildExecutors

        private void NotifyChangesToChildExecutors(IWorkflowCoreRuntime workflowCoreRuntime, Activity contextActivity, IList<WorkflowChangeAction> changeActions)
        {
            foreach (WorkflowChangeAction action in changeActions)
            {
                if (!(action is ActivityChangeAction))
                    continue;

                CompositeActivity ownerActivity = contextActivity.TraverseDottedPathFromRoot(((ActivityChangeAction)action).OwnerActivityDottedPath) as CompositeActivity;
                if (ownerActivity == null || !WorkflowChanges.IsActivityExecutable(ownerActivity))
                    continue;

                ISupportWorkflowChanges compositeActivityExecutor = ActivityExecutors.GetActivityExecutor(ownerActivity) as ISupportWorkflowChanges;
                if (compositeActivityExecutor == null)
                    throw new ApplicationException(SR.GetString(SR.Error_WorkflowChangesNotSupported, ownerActivity.GetType().FullName));

                using (workflowCoreRuntime.SetCurrentActivity(ownerActivity))
                {
                    using (ActivityExecutionContext executionContext = new ActivityExecutionContext(ownerActivity))
                    {
                        if (action is AddedActivityAction)
                        {
                            Activity addedActivity = ownerActivity.Activities[((AddedActivityAction)action).Index];
                            if (WorkflowChanges.IsActivityExecutable(addedActivity))
                            {
                                addedActivity.OnActivityExecutionContextLoad(executionContext.Activity.RootActivity.WorkflowCoreRuntime);
                                executionContext.InitializeActivity(addedActivity);
                                compositeActivityExecutor.OnActivityAdded(executionContext, addedActivity);
                            }
                        }
                        else if (action is RemovedActivityAction)
                        {
                            RemovedActivityAction removedActivityAction = (RemovedActivityAction)action;
                            if (WorkflowChanges.IsActivityExecutable(removedActivityAction.OriginalRemovedActivity))
                            {
                                compositeActivityExecutor.OnActivityRemoved(executionContext, removedActivityAction.OriginalRemovedActivity);
                                if (removedActivityAction.OriginalRemovedActivity.ExecutionResult != ActivityExecutionResult.Uninitialized)
                                {
                                    removedActivityAction.OriginalRemovedActivity.Uninitialize(executionContext.Activity.RootActivity.WorkflowCoreRuntime);
                                    removedActivityAction.OriginalRemovedActivity.SetValue(Activity.ExecutionResultProperty, ActivityExecutionResult.Uninitialized);
                                }
                                removedActivityAction.OriginalRemovedActivity.OnActivityExecutionContextUnload(executionContext.Activity.RootActivity.WorkflowCoreRuntime);
                                removedActivityAction.OriginalRemovedActivity.Dispose();
                            }
                        }
                    }
                }
            }
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:48,代码来源:ScheduleChanges.cs

示例4: RegisterWithRuntime

        internal void RegisterWithRuntime(WorkflowRuntime workflowRuntime)
        {
            _isInstanceValid = true;
            _runtime = workflowRuntime;
            using (new ServiceEnvironment(this.rootActivity))
            {
                using (SetCurrentActivity(this.rootActivity))
                {
                    using (ActivityExecutionContext executionContext = new ActivityExecutionContext(this.rootActivity, true))
                        executionContext.InitializeActivity(this.rootActivity);
                }

                //
                // Tell the runtime that the instance is ready 
                // so that internal components can set up event subscriptions
                this._runtime.WorkflowExecutorCreated(this, false);

                //
                // Fire first events
                FireWorkflowExecutionEvent(this, WorkflowEventInternal.Creating);
            }
        }
开发者ID:uQr,项目名称:referencesource,代码行数:22,代码来源:WorkflowExecutor.cs

示例5: RegisterWithRuntime

 internal void RegisterWithRuntime(System.Workflow.Runtime.WorkflowRuntime workflowRuntime)
 {
     this._isInstanceValid = true;
     this._runtime = workflowRuntime;
     using (new ServiceEnvironment(this.rootActivity))
     {
         using (this.SetCurrentActivity(this.rootActivity))
         {
             using (ActivityExecutionContext context = new ActivityExecutionContext(this.rootActivity, true))
             {
                 context.InitializeActivity(this.rootActivity);
             }
         }
         this._runtime.WorkflowExecutorCreated(this, false);
         this.FireWorkflowExecutionEvent(this, WorkflowEventInternal.Creating);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:17,代码来源:WorkflowExecutor.cs

示例6: Initialize

        public void Initialize(Activity definition, IDictionary<string, object> inputs, bool hasNameCollision)
        {
            this.rootActivity.SetValue(Activity.ActivityExecutionContextInfoProperty,
                new ActivityExecutionContextInfo(this.rootActivity.QualifiedName, this.GetNewContextActivityId(), instanceId, -1));
            this.rootActivity.SetValue(Activity.ActivityContextGuidProperty, instanceId);

            SetInputParameters(definition, this.rootActivity, inputs, hasNameCollision);

            ((IDependencyObjectAccessor)this.rootActivity).InitializeActivatingInstanceForRuntime(
                null,
                this);

            this.rootActivity.FixUpMetaProperties(definition);

            TimerQueue = new TimerEventSubscriptionCollection(this, this.instanceId);

            using (new ServiceEnvironment(this.rootActivity))
            {
                using (SetCurrentActivity(this.rootActivity))
                {
                    RegisterContextActivity(this.rootActivity);

                    using (ActivityExecutionContext executionContext = new ActivityExecutionContext(this.rootActivity, true))
                    {
                        executionContext.InitializeActivity(this.rootActivity);
                    }
                }
            }
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:29,代码来源:InteropExecutor.cs

示例7: CreateExecutionContext

 public ActivityExecutionContext CreateExecutionContext(Activity activity)
 {
     ActivityExecutionContext context2;
     if (this.ownerContext == null)
     {
         throw new ObjectDisposedException("ActivityExecutionContextManager");
     }
     if (activity == null)
     {
         throw new ArgumentNullException("activity");
     }
     if (!this.ownerContext.IsValidChild(activity, true))
     {
         throw new ArgumentException(SR.GetString("AEC_InvalidActivity"), "activity");
     }
     Activity item = activity.Clone();
     ((IDependencyObjectAccessor) item).InitializeInstanceForRuntime(this.ownerContext.Activity.WorkflowCoreRuntime);
     Queue<Activity> queue = new Queue<Activity>();
     queue.Enqueue(item);
     while (queue.Count != 0)
     {
         Activity activity3 = queue.Dequeue();
         if (activity3.ExecutionStatus != ActivityExecutionStatus.Initialized)
         {
             activity3.ResetAllKnownDependencyProperties();
             CompositeActivity activity4 = activity3 as CompositeActivity;
             if (activity4 != null)
             {
                 for (int i = 0; i < activity4.EnabledActivities.Count; i++)
                 {
                     queue.Enqueue(activity4.EnabledActivities[i]);
                 }
                 ISupportAlternateFlow flow = activity4;
                 if (flow != null)
                 {
                     for (int j = 0; j < flow.AlternateFlowActivities.Count; j++)
                     {
                         queue.Enqueue(flow.AlternateFlowActivities[j]);
                     }
                 }
             }
         }
     }
     IList<Activity> list = (IList<Activity>) this.ownerContext.Activity.ContextActivity.GetValue(Activity.ActiveExecutionContextsProperty);
     if (list == null)
     {
         list = new List<Activity>();
         this.ownerContext.Activity.ContextActivity.SetValue(Activity.ActiveExecutionContextsProperty, list);
     }
     list.Add(item);
     ActivityExecutionContextInfo info = new ActivityExecutionContextInfo(activity.QualifiedName, this.ownerContext.WorkflowCoreRuntime.GetNewContextActivityId(), Guid.NewGuid(), this.ownerContext.ContextId);
     item.SetValue(Activity.ActivityExecutionContextInfoProperty, info);
     item.SetValue(Activity.ActivityContextGuidProperty, info.ContextGuid);
     ActivityExecutionContext context = null;
     try
     {
         this.ownerContext.Activity.WorkflowCoreRuntime.RegisterContextActivity(item);
         context = new ActivityExecutionContext(item);
         this.executionContexts.Add(context);
         context.InitializeActivity(context.Activity);
         context2 = context;
     }
     catch (Exception)
     {
         if (context != null)
         {
             this.CompleteExecutionContext(context);
         }
         else
         {
             list.Remove(item);
         }
         throw;
     }
     return context2;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:76,代码来源:ActivityExecutionContextManager.cs


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