Example #1
0
        public static IActionExecutor GetActionExecutor(ActionToken actionToken)
        {
            if (actionToken == null) throw new ArgumentNullException("actionToken");


            IActionExecutor actionExecutor;


            if (_actionExecutorCache.TryGetValue(actionToken.GetType(), out actionExecutor) == false)
            {
                object[] attributes = actionToken.GetType().GetCustomAttributes(typeof(ActionExecutorAttribute), true);

                if (attributes.Length == 0) throw new InvalidOperationException(string.Format("Missing {0} attribute on the flow token {1}", typeof(ActionExecutorAttribute), actionToken.GetType()));

                ActionExecutorAttribute attribute = (ActionExecutorAttribute)attributes[0];

                if (attribute.ActionExecutorType == null) throw new InvalidOperationException(string.Format("Action executor type can not be null on the action token {0}", actionToken.GetType()));
                if (typeof(IActionExecutor).IsAssignableFrom(attribute.ActionExecutorType) == false) throw new InvalidOperationException(string.Format("Action executor {0} should implement the interface {1}", attribute.ActionExecutorType, typeof(IActionExecutor)));

                actionExecutor = (IActionExecutor)Activator.CreateInstance(attribute.ActionExecutorType);

                _actionExecutorCache.Add(actionToken.GetType(), actionExecutor);
            }


            return actionExecutor;
        }
Example #2
0
        public static bool IsIgnoreEntityTokenLocking(this ActionToken actionToken)
        {
            if (actionToken == null)
            {
                throw new ArgumentNullException("actionToken");
            }

            Type type = actionToken.GetType();

            lock (_lock)
            {
                bool ignoreLocking;
                if (_ignoreEntityTokenLockingCache.TryGetValue(type, out ignoreLocking) == false)
                {
                    ignoreLocking = type.GetCustomAttributesRecursively <IgnoreEntityTokenLocking>().Any();

                    _ignoreEntityTokenLockingCache.Add(type, ignoreLocking);
                }

                return(ignoreLocking | actionToken.IgnoreEntityTokenLocking);
            }
        }
Example #3
0
        /// <exclude />
        public static string Serialize(ActionToken actionToken, bool includeHashValue)
        {
            StringBuilder sb = new StringBuilder();

            StringConversionServices.SerializeKeyValuePair(sb, "actionTokenType", TypeManager.SerializeType(actionToken.GetType()));

            string serializedActionToken = actionToken.Serialize();

            StringConversionServices.SerializeKeyValuePair(sb, "actionToken", serializedActionToken);

            if (includeHashValue)
            {
                StringConversionServices.SerializeKeyValuePair(sb, "actionTokenHash", HashSigner.GetSignedHash(serializedActionToken).Serialize());
            }

            return(sb.ToString());
        }