Example #1
0
 ActionCacheExecutor GetServiceUnderTest(
     IActionCacheStorage storage,
     params IActionCacheAction[] actions)
 {
     return(new ActionCacheExecutor(
                storage,
                actions));
 }
Example #2
0
        public ActionCacheExecutor(
            IActionCacheStorage storage,
            IEnumerable <IActionCacheAction> actions)
        {
            _storage = storage;
            _actions = new Dictionary <Type, IActionCacheAction>();
            foreach (var action in actions)
            {
                var actionInType =
                    (from i in action.GetType().GetInterfaces()
                     where
                     i.IsGenericType &&
                     i.GetGenericTypeDefinition() == GenericActionType
                     select i.GenericTypeArguments.First()).SingleOrDefault();

                if (actionInType == null)
                {
                    throw new ActionCacheActionTypeException();
                }

                _actions.Add(
                    actionInType, action);
            }
        }