Пример #1
0
        /// <summary>
        /// The default exit point for an activity
        /// </summary>
        public static ExitPoint GetDefaultExitPoint(this WfActivity activity)
        {
            ExitPoint result = null;

            var ioe = activity.As <EntityWithArgsAndExits>();

            if (ioe != null)
            {
                result = ioe.ExitPoints.FirstOrDefault(ep => ep.IsDefaultExitPoint ?? false);
            }

            if (result == null)
            {
                var aType = activity.IsOfType.FirstOrDefault(t => t.Is <ActivityType>());

                if (aType != null)
                {
                    result = aType.Cast <ActivityType>().ExitPoints.FirstOrDefault(ep => ep.IsDefaultExitPoint ?? false);
                }
            }

            if (result == null)
            {
                throw new ApplicationException(string.Format("Unable to find the default exit point for {0}({1})", activity.Name ?? "[Unnamed]", activity.Id));
            }

            return(result);
        }
Пример #2
0
        public static IEnumerable <ActivityArgument> GetInputArguments(this WfActivity activity)
        {
            // for a workflow the input arguments are on the instance, for an activity they are on the type
            var typeArguments = activity.IsOfType.Select(t => t.As <ActivityType>()).First(t => t != null).InputArguments;

            var entityWithArgsAndExits = activity.As <EntityWithArgsAndExits>();

            if (entityWithArgsAndExits != null)
            {
                return(entityWithArgsAndExits.InputArguments.Union(typeArguments));
            }
            else
            {
                return(typeArguments); // note that his code assumes the first type is an activity type
            }
        }
        public static IEnumerable <ActivityArgument> GetOutputArguments(this WfActivity activity)
        {
            IEnumerable <ActivityArgument> result;
            // get the type defined arguments
            var type = activity.IsOfType.Select(t => t.As <ActivityType>()).First(t => t != null);

            result = type.OutputArguments;

            // get the instance defined arguments
            var entityWithArgsAndExits = activity.As <EntityWithArgsAndExits>();

            if (entityWithArgsAndExits != null)
            {
                result = result.Union(entityWithArgsAndExits.OutputArguments);
            }

            return(result);
        }
Пример #4
0
        ///// <summary>
        ///// The default time before an activity timeouts
        ///// </summary>
        //public static TimeSpan DefaultActivityTimeout { get { return new TimeSpan(0, 1, 0); } } //TODO: move into system configuration

        ///// <summary>
        ///// The default number of times a workflow will execute directly contained activities.
        ///// </summary>
        //public static int DefaultWorkflowMaxActivityExecutes { get { return 1000; } } //TODO: move into system configuration


        /// <summary>
        /// The default exit point for an activity
        /// </summary>
        public static IEnumerable <ExitPoint> GetExitPoints(this WfActivity activity)
        {
            IEnumerable <ExitPoint> result = new List <ExitPoint>();

            var ioe = activity.As <EntityWithArgsAndExits>();

            if (ioe != null)
            {
                result = ioe.ExitPoints.ToList();
            }

            var aType = activity.IsOfType.FirstOrDefault(t => t.Is <ActivityType>());

            if (aType != null)
            {
                result = result.Union(aType.Cast <ActivityType>().ExitPoints.ToList());
            }

            return(result);
        }
Пример #5
0
        public static ExitPoint GetNamedExitPoint(this WfActivity activity, string name)
        {
            ExitPoint result = null;

            var actAsDyn = activity.As <EntityWithArgsAndExits>();

            if (actAsDyn != null)
            {
                result = actAsDyn.ExitPoints.FirstOrDefault(ep => ep.Name == name);
            }

            if (result != null)
            {
                return(result);
            }
            else
            {
                return(activity.IsOfType.Select(t => t.As <EntityWithArgsAndExits>()).First(t => t != null).ExitPoints.FirstOrDefault(ep => ep.Name == name));
            }
        }