Пример #1
0
        protected override bool TryLoad(Stream input, IDeserializerContext context, CompositeType type, ICompositeStorage storage)
        {
            if (base.TryLoad(input, context, type, storage))
            {
                if (storage.TryGet("AggregateRootException", out ICompositeStorage inner))
                {
                    AggregateRootExceptionDecorator decorator = new AggregateRootExceptionDecorator((AggregateRootException)context.Output);

                    IKey key = inner.Get <IKey>(Name.AggregateRootKey);
                    if (key != null)
                    {
                        decorator.SetKey(key);
                    }

                    key = inner.Get <IKey>(Name.CommandKey);
                    if (key != null)
                    {
                        decorator.SetCommandKey(key);
                    }

                    key = inner.Get <IKey>(Name.SourceCommandKey);
                    if (key != null)
                    {
                        decorator.SetSourceCommandKey(key);
                    }
                }

                return(true);
            }

            return(false);
        }
Пример #2
0
        private T DecorateException <T>(ICommand command, StringKey userKey, T ex)
            where T : AggregateRootException
        {
            AggregateRootExceptionDecorator decorator = new AggregateRootExceptionDecorator(ex);

            decorator.SetCommandKey(command.Key);
            decorator.SetSourceCommandKey(command.Key);
            decorator.SetKey(userKey);
            return(ex);
        }