Example #1
0
        public static void Register(this IOperation operation, bool replace = false)
        {
            if (!operation.OverridenType.IsIEntity())
            {
                throw new InvalidOperationException("Type '{0}' has to implement at least {1}".FormatWith(operation.OverridenType.Name));
            }

            operation.AssertIsValid();

            var dic = operations.GetOrAddDefinition(operation.OverridenType);

            if (replace)
            {
                dic[operation.OperationSymbol] = operation;
            }
            else
            {
                dic.AddOrThrow(operation.OperationSymbol, operation, "Operation {0} has already been registered");
            }

            operations.ClearCache();

            operationsFromKey.Reset();
        }