當前位置: 首頁>>代碼示例>>C#>>正文


C# Activity.GetActivityByName方法代碼示例

本文整理匯總了C#中System.Workflow.ComponentModel.Activity.GetActivityByName方法的典型用法代碼示例。如果您正苦於以下問題:C# Activity.GetActivityByName方法的具體用法?C# Activity.GetActivityByName怎麽用?C# Activity.GetActivityByName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Workflow.ComponentModel.Activity的用法示例。


在下文中一共展示了Activity.GetActivityByName方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: InitializeCorrelationTokenCollection

 internal static void InitializeCorrelationTokenCollection(Activity activity, CorrelationToken correlator)
 {
     if ((correlator != null) && !string.IsNullOrEmpty(correlator.OwnerActivityName))
     {
         string ownerActivityName = correlator.OwnerActivityName;
         Activity activityByName = activity.GetActivityByName(ownerActivityName);
         if (activityByName == null)
         {
             activityByName = Helpers.ParseActivityForBind(activity, ownerActivityName);
         }
         if (activityByName == null)
         {
             throw new ArgumentException("ownerActivity");
         }
         CorrelationTokenCollection tokens = activityByName.GetValue(CorrelationTokenCollection.CorrelationTokenCollectionProperty) as CorrelationTokenCollection;
         if (tokens == null)
         {
             tokens = new CorrelationTokenCollection();
             activityByName.SetValue(CorrelationTokenCollection.CorrelationTokenCollectionProperty, tokens);
         }
         if (!tokens.Contains(correlator.Name))
         {
             tokens.Add(correlator);
         }
     }
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:26,代碼來源:ActivityHelpers.cs

示例2: CollectCompensatableCompletedContexts

 private static void CollectCompensatableCompletedContexts(ActivityExecutionContext context, Activity targetActivity, SortedDictionary<int, CompensationInfo> sortedListOfCompensatableTargets, bool immediateCompensation)
 {
     ActivityExecutionContextManager executionContextManager = context.ExecutionContextManager;
     for (int i = executionContextManager.CompletedExecutionContexts.Count - 1; i >= 0; i--)
     {
         ActivityExecutionContextInfo targetExecutionInfo = executionContextManager.CompletedExecutionContexts[i];
         if (((byte) (targetExecutionInfo.Flags & PersistFlags.NeedsCompensation)) != 0)
         {
             Activity activityByName = targetActivity.GetActivityByName(targetExecutionInfo.ActivityQualifiedName, true);
             if ((activityByName != null) && (!immediateCompensation || !IsActivityInBackWorkBranch(targetActivity, activityByName)))
             {
                 sortedListOfCompensatableTargets.Add(targetExecutionInfo.CompletedOrderId, new CompensationInfo(targetExecutionInfo, executionContextManager));
             }
         }
     }
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:16,代碼來源:CompensationUtils.cs

示例3: Evaluate

 public override bool Evaluate(Activity activity, IServiceProvider provider)
 {
     if (activity == null)
     {
         throw new ArgumentNullException("activity");
     }
     if (string.IsNullOrEmpty(this._condition))
     {
         throw new InvalidOperationException(SR.GetString("Error_MissingConditionName", new object[] { activity.Name }));
     }
     RuleDefinitions ruleDefinitions = null;
     if (string.IsNullOrEmpty(this.declaringActivityId))
     {
         CompositeActivity declaringActivity = null;
         ruleDefinitions = GetRuleDefinitions(activity, out declaringActivity);
     }
     else
     {
         ruleDefinitions = (RuleDefinitions) activity.GetActivityByName(this.declaringActivityId).GetValue(RuleDefinitions.RuleDefinitionsProperty);
     }
     if ((ruleDefinitions == null) || (ruleDefinitions.Conditions == null))
     {
         throw new InvalidOperationException(SR.GetString("Error_MissingRuleConditions"));
     }
     RuleCondition condition = ruleDefinitions.Conditions[this._condition];
     if (condition == null)
     {
         return true;
     }
     Activity enclosingActivity = Helpers.GetEnclosingActivity(activity);
     RuleValidation validation = new RuleValidation(enclosingActivity);
     if (!condition.Validate(validation))
     {
         throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Messages.ConditionValidationFailed, new object[] { this._condition }));
     }
     RuleExecution execution = new RuleExecution(validation, enclosingActivity, provider as ActivityExecutionContext);
     return condition.Evaluate(execution);
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:38,代碼來源:RuleConditionReference.cs

示例4: InitializeCorrelationTokenCollection

        internal static void InitializeCorrelationTokenCollection(Activity activity, CorrelationToken correlator)
        {
            if (correlator != null && !String.IsNullOrEmpty(correlator.OwnerActivityName))
            {
                string ownerActivityId = correlator.OwnerActivityName;
                Activity owner = activity.GetActivityByName(ownerActivityId);
                if (owner == null)
                    owner = System.Workflow.Activities.Common.Helpers.ParseActivityForBind(activity, ownerActivityId);
                if (owner == null)
                    throw new ArgumentException("ownerActivity");

                CorrelationTokenCollection collection = owner.GetValue(CorrelationTokenCollection.CorrelationTokenCollectionProperty) as CorrelationTokenCollection;
                if (collection == null)
                {
                    collection = new CorrelationTokenCollection();
                    owner.SetValue(CorrelationTokenCollection.CorrelationTokenCollectionProperty, collection);
                }

                if (!collection.Contains(correlator.Name))
                {
                    collection.Add(correlator);
                }
            }
        }
開發者ID:iskiselev,項目名稱:JSIL.NetFramework,代碼行數:24,代碼來源:Helpers.cs

示例5: CollectCompensatableActiveContexts

 private static bool CollectCompensatableActiveContexts(ActivityExecutionContext context, Activity targetActivity, SortedDictionary<int, CompensationInfo> sortedListOfCompensatableTargets, bool immediateCompensation)
 {
     foreach (ActivityExecutionContext context2 in context.ExecutionContextManager.ExecutionContexts)
     {
         if ((targetActivity.GetActivityByName(context2.Activity.QualifiedName, true) != null) && (!immediateCompensation || !IsActivityInBackWorkBranch(targetActivity, context2.Activity)))
         {
             if ((context2.Activity is ICompensatableActivity) && (((context2.Activity.ExecutionStatus == ActivityExecutionStatus.Compensating) || (context2.Activity.ExecutionStatus == ActivityExecutionStatus.Faulting)) || (context2.Activity.ExecutionStatus == ActivityExecutionStatus.Canceling)))
             {
                 return true;
             }
             if (context2.Activity is CompositeActivity)
             {
                 Activity[] compensatableChildren = GetCompensatableChildren(context2.Activity as CompositeActivity);
                 if (compensatableChildren != null)
                 {
                     int key = 0;
                     foreach (Activity activity in compensatableChildren)
                     {
                         int num2 = (int) activity.GetValue(Activity.CompletedOrderIdProperty);
                         if (key < num2)
                         {
                             key = num2;
                         }
                     }
                     if (key != 0)
                     {
                         sortedListOfCompensatableTargets.Add(key, new CompensationInfo(context2));
                     }
                 }
                 CollectCompensatableActiveContexts(context2, targetActivity, sortedListOfCompensatableTargets, immediateCompensation);
                 CollectCompensatableCompletedContexts(context2, targetActivity, sortedListOfCompensatableTargets, immediateCompensation);
             }
         }
     }
     return false;
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:36,代碼來源:CompensationUtils.cs

示例6: CompleteRevokedExecutionContext

 private static void CompleteRevokedExecutionContext(Activity targetActivity, ActivityExecutionContext context)
 {
     ActivityExecutionContext[] array = new ActivityExecutionContext[context.ExecutionContextManager.ExecutionContexts.Count];
     context.ExecutionContextManager.ExecutionContexts.CopyTo(array, 0);
     foreach (ActivityExecutionContext context2 in array)
     {
         if (targetActivity.GetActivityByName(context2.Activity.QualifiedName, true) != null)
         {
             if (context2.Activity.ExecutionStatus == ActivityExecutionStatus.Closed)
             {
                 CompleteRevokedExecutionContext(context2.Activity, context2);
             }
             context.ExecutionContextManager.CompleteExecutionContext(context2);
         }
     }
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:16,代碼來源:CompensationUtils.cs

示例7: IsOwnerActivitySame

 private static bool IsOwnerActivitySame(string ownerActivityName, string existingOwnerActivityName, Activity currentActivity, Activity existingActivity)
 {
     if (ownerActivityName.Equals(existingOwnerActivityName))
     {
         return true;
     }
     Activity activityByName = currentActivity.GetActivityByName(ownerActivityName);
     if (activityByName == null)
     {
         activityByName = Helpers.ParseActivityForBind(currentActivity, ownerActivityName);
     }
     Activity activity2 = currentActivity.GetActivityByName(existingOwnerActivityName);
     if (activity2 == null)
     {
         activity2 = Helpers.ParseActivityForBind(existingActivity, existingOwnerActivityName);
     }
     return (((activityByName != null) && (activity2 != null)) && activityByName.QualifiedName.Equals(activity2.QualifiedName));
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:18,代碼來源:CorrelationSetsValidator.cs

示例8: Evaluate

        public override bool Evaluate(Activity activity, IServiceProvider provider)
        {
            if (activity == null)
            {
                throw new ArgumentNullException("activity");
            }
            if (string.IsNullOrEmpty(this._condition))
            {
                throw new InvalidOperationException(SR.GetString(SR.Error_MissingConditionName, activity.Name));
            }

            RuleDefinitions defs = null;

            if (string.IsNullOrEmpty(this.declaringActivityId))
            {
                // No Runtime Initialization.
                CompositeActivity declaringActivity = null;
                defs = RuleConditionReference.GetRuleDefinitions(activity, out declaringActivity);
            }
            else
            {
                // Runtime Initialized.
                defs = (RuleDefinitions)activity.GetActivityByName(declaringActivityId).GetValue(RuleDefinitions.RuleDefinitionsProperty);
            }

            if ((defs == null) || (defs.Conditions == null))
            {
                throw new InvalidOperationException(SR.GetString(SR.Error_MissingRuleConditions));
            }

            RuleCondition conditionDefinitionToEvaluate = defs.Conditions[this._condition];
            if (conditionDefinitionToEvaluate != null)
            {
                Activity contextActivity = System.Workflow.Activities.Common.Helpers.GetEnclosingActivity(activity);
                RuleValidation validation = new RuleValidation(contextActivity);
                if (!conditionDefinitionToEvaluate.Validate(validation))
                {
                    string message = string.Format(CultureInfo.CurrentCulture, Messages.ConditionValidationFailed, this._condition);
                    throw new InvalidOperationException(message);
                }

                RuleExecution context = new RuleExecution(validation, contextActivity, provider as ActivityExecutionContext);
                return conditionDefinitionToEvaluate.Evaluate(context);
            }
            else
            {
                // no condition, so defaults to true
                return true;
            }
        }
開發者ID:iskiselev,項目名稱:JSIL.NetFramework,代碼行數:50,代碼來源:DeclarativeExpressionConditionDeclaration.cs

示例9: IsOwnerActivitySame

        private static bool IsOwnerActivitySame(string ownerActivityName, string existingOwnerActivityName, Activity currentActivity, Activity existingActivity)
        {
            if (ownerActivityName.Equals(existingOwnerActivityName))
                return true;

            Activity owner = currentActivity.GetActivityByName(ownerActivityName);
            if (owner == null)
                owner = Helpers.ParseActivityForBind(currentActivity, ownerActivityName);

            Activity existingowner = currentActivity.GetActivityByName(existingOwnerActivityName);
            if (existingowner == null)
                existingowner = Helpers.ParseActivityForBind(existingActivity, existingOwnerActivityName);

            if (owner != null && existingowner != null && owner.QualifiedName.Equals(existingowner.QualifiedName))
                return true;

            return false;
        }
開發者ID:krytht,項目名稱:DotNetReferenceSource,代碼行數:18,代碼來源:CorrelationValidator.cs


注:本文中的System.Workflow.ComponentModel.Activity.GetActivityByName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。