예제 #1
0
        public static Activity Resolve(Activity root, string id)
        {
            if (root == null)
            {
                throw FxTrace.Exception.ArgumentNull(nameof(root));
            }

            if (string.IsNullOrEmpty(id))
            {
                throw FxTrace.Exception.ArgumentNullOrEmpty(nameof(id));
            }

            if (!root.IsMetadataCached)
            {
                IList <ValidationError> validationErrors = null;

                ActivityUtilities.CacheRootMetadata(root, new ActivityLocationReferenceEnvironment(), ProcessActivityTreeOptions.FullCachingOptions, null, ref validationErrors);

                ActivityValidationServices.ThrowIfViolationsExist(validationErrors);
            }

            var parsedId = QualifiedId.Parse(id);

            if (!QualifiedId.TryGetElementFromRoot(root, parsedId, out var result))
            {
                throw FxTrace.Exception.Argument(nameof(id), SR.IdNotFoundInWorkflow(id));
            }

            return(result);
        }
예제 #2
0
        public static Activity Resolve(Activity root, string id)
        {
            Activity activity;

            if (root == null)
            {
                throw FxTrace.Exception.ArgumentNull("root");
            }
            if (string.IsNullOrEmpty(id))
            {
                throw FxTrace.Exception.ArgumentNullOrEmpty("id");
            }
            if (!root.IsMetadataCached)
            {
                IList <ValidationError> validationErrors = null;
                ActivityUtilities.CacheRootMetadata(root, new ActivityLocationReferenceEnvironment(), ProcessActivityTreeOptions.FullCachingOptions, null, ref validationErrors);
                ActivityValidationServices.ThrowIfViolationsExist(validationErrors);
            }
            QualifiedId id2 = QualifiedId.Parse(id);

            if (!QualifiedId.TryGetElementFromRoot(root, id2, out activity))
            {
                throw FxTrace.Exception.Argument("id", System.Activities.SR.IdNotFoundInWorkflow(id));
            }
            return(activity);
        }
예제 #3
0
        public static bool CanInduceIdle(Activity activity)
        {
            if (activity == null)
            {
                throw FxTrace.Exception.ArgumentNull(nameof(activity));
            }

            if (!activity.IsMetadataCached)
            {
                IList <ValidationError> validationErrors = null;

                ActivityUtilities.CacheRootMetadata(activity, new ActivityLocationReferenceEnvironment(), ProcessActivityTreeOptions.FullCachingOptions, null, ref validationErrors);

                ActivityValidationServices.ThrowIfViolationsExist(validationErrors);
            }

            return(activity.InternalCanInduceIdle);
        }
예제 #4
0
 void ValidateWorkflow(WorkflowInstanceExtensionManager extensionManager)
 {
     if (!WorkflowDefinition.IsRuntimeReady)
     {
         LocationReferenceEnvironment localEnvironment = this.hostEnvironment;
         if (localEnvironment == null)
         {
             LocationReferenceEnvironment parentEnvironment = null;
             if (extensionManager != null && extensionManager.SymbolResolver != null)
             {
                 parentEnvironment = extensionManager.SymbolResolver.AsLocationReferenceEnvironment();
             }
             localEnvironment = new ActivityLocationReferenceEnvironment(parentEnvironment);
         }
         IList <ValidationError> validationErrors = null;
         ActivityUtilities.CacheRootMetadata(WorkflowDefinition, localEnvironment, ProcessActivityTreeOptions.FullCachingOptions, null, ref validationErrors);
         ActivityValidationServices.ThrowIfViolationsExist(validationErrors);
     }
 }
예제 #5
0
        public static void CacheMetadata(Activity rootActivity, LocationReferenceEnvironment hostEnvironment)
        {
            if (rootActivity == null)
            {
                throw FxTrace.Exception.ArgumentNull("rootActivity");
            }
            if (rootActivity.HasBeenAssociatedWithAnInstance)
            {
                throw FxTrace.Exception.AsError(new InvalidOperationException(System.Activities.SR.RootActivityAlreadyAssociatedWithInstance(rootActivity.DisplayName)));
            }
            IList <ValidationError> validationErrors = null;

            if (hostEnvironment == null)
            {
                hostEnvironment = new ActivityLocationReferenceEnvironment();
            }
            ActivityUtilities.CacheRootMetadata(rootActivity, hostEnvironment, ProcessActivityTreeOptions.FullCachingOptions, null, ref validationErrors);
            ActivityValidationServices.ThrowIfViolationsExist(validationErrors);
        }
예제 #6
0
        public static IEnumerable <Activity> GetActivities(Activity activity)
        {
            if (activity == null)
            {
                throw FxTrace.Exception.ArgumentNull(nameof(activity));
            }

            if (!activity.IsMetadataCached)
            {
                IList <ValidationError> validationErrors = null;

                ActivityUtilities.CacheRootMetadata(activity, new ActivityLocationReferenceEnvironment(), ProcessActivityTreeOptions.FullCachingOptions, null, ref validationErrors);

                ActivityValidationServices.ThrowIfViolationsExist(validationErrors);
            }

            var i = 0;

            for (; i < activity.RuntimeArguments.Count; i++)
            {
                var argument = activity.RuntimeArguments[i];

                if (argument.BoundArgument != null && argument.BoundArgument.Expression != null)
                {
                    yield return(argument.BoundArgument.Expression);
                }
            }

            for (i = 0; i < activity.RuntimeVariables.Count; i++)
            {
                var variable = activity.RuntimeVariables[i];

                if (variable.Default != null)
                {
                    yield return(variable.Default);
                }
            }

            for (i = 0; i < activity.ImplementationVariables.Count; i++)
            {
                var variable = activity.ImplementationVariables[i];

                if (variable.Default != null)
                {
                    yield return(variable.Default);
                }
            }

            for (i = 0; i < activity.Children.Count; i++)
            {
                yield return(activity.Children[i]);
            }

            for (i = 0; i < activity.ImportedChildren.Count; i++)
            {
                yield return(activity.ImportedChildren[i]);
            }

            for (i = 0; i < activity.ImplementationChildren.Count; i++)
            {
                yield return(activity.ImplementationChildren[i]);
            }

            for (i = 0; i < activity.Delegates.Count; i++)
            {
                var activityDelegate = activity.Delegates[i];

                if (activityDelegate.Handler != null)
                {
                    yield return(activityDelegate.Handler);
                }
            }

            for (i = 0; i < activity.ImportedDelegates.Count; i++)
            {
                var activityDelegate = activity.ImportedDelegates[i];

                if (activityDelegate.Handler != null)
                {
                    yield return(activityDelegate.Handler);
                }
            }

            for (i = 0; i < activity.ImplementationDelegates.Count; i++)
            {
                var activityDelegate = activity.ImplementationDelegates[i];

                if (activityDelegate.Handler != null)
                {
                    yield return(activityDelegate.Handler);
                }
            }
        }
예제 #7
0
        public static IEnumerable <Activity> GetActivities(Activity activity)
        {
            int iteratorVariable0;

            if (activity == null)
            {
                throw FxTrace.Exception.ArgumentNull("activity");
            }
            if (!activity.IsMetadataCached)
            {
                IList <ValidationError> validationErrors = null;
                ActivityUtilities.CacheRootMetadata(activity, new ActivityLocationReferenceEnvironment(), ProcessActivityTreeOptions.FullCachingOptions, null, ref validationErrors);
                ActivityValidationServices.ThrowIfViolationsExist(validationErrors);
            }
            for (iteratorVariable0 = 0; iteratorVariable0 < activity.RuntimeArguments.Count; iteratorVariable0++)
            {
                RuntimeArgument iteratorVariable1 = activity.RuntimeArguments[iteratorVariable0];
                if ((iteratorVariable1.BoundArgument != null) && (iteratorVariable1.BoundArgument.Expression != null))
                {
                    yield return(iteratorVariable1.BoundArgument.Expression);
                }
            }
            for (iteratorVariable0 = 0; iteratorVariable0 < activity.RuntimeVariables.Count; iteratorVariable0++)
            {
                Variable iteratorVariable2 = activity.RuntimeVariables[iteratorVariable0];
                if (iteratorVariable2.Default != null)
                {
                    yield return(iteratorVariable2.Default);
                }
            }
            for (iteratorVariable0 = 0; iteratorVariable0 < activity.ImplementationVariables.Count; iteratorVariable0++)
            {
                Variable iteratorVariable3 = activity.ImplementationVariables[iteratorVariable0];
                if (iteratorVariable3.Default != null)
                {
                    yield return(iteratorVariable3.Default);
                }
            }
            for (iteratorVariable0 = 0; iteratorVariable0 < activity.Children.Count; iteratorVariable0++)
            {
                yield return(activity.Children[iteratorVariable0]);
            }
            for (iteratorVariable0 = 0; iteratorVariable0 < activity.ImportedChildren.Count; iteratorVariable0++)
            {
                yield return(activity.ImportedChildren[iteratorVariable0]);
            }
            for (iteratorVariable0 = 0; iteratorVariable0 < activity.ImplementationChildren.Count; iteratorVariable0++)
            {
                yield return(activity.ImplementationChildren[iteratorVariable0]);
            }
            for (iteratorVariable0 = 0; iteratorVariable0 < activity.Delegates.Count; iteratorVariable0++)
            {
                ActivityDelegate iteratorVariable4 = activity.Delegates[iteratorVariable0];
                if (iteratorVariable4.Handler != null)
                {
                    yield return(iteratorVariable4.Handler);
                }
            }
            for (iteratorVariable0 = 0; iteratorVariable0 < activity.ImportedDelegates.Count; iteratorVariable0++)
            {
                ActivityDelegate iteratorVariable5 = activity.ImportedDelegates[iteratorVariable0];
                if (iteratorVariable5.Handler != null)
                {
                    yield return(iteratorVariable5.Handler);
                }
            }
            for (iteratorVariable0 = 0; iteratorVariable0 < activity.ImplementationDelegates.Count; iteratorVariable0++)
            {
                ActivityDelegate iteratorVariable6 = activity.ImplementationDelegates[iteratorVariable0];
                if (iteratorVariable6.Handler != null)
                {
                    yield return(iteratorVariable6.Handler);
                }
            }
        }