예제 #1
0
        private static Type GetAggregateRootType(ICommand command)
        {
            MapsToAggregateRootMethodAttribute mappingAttribute = GetMappingAttribute(command);

            try
            {
                return(Type.GetType(mappingAttribute.TypeName, true));
            }
            catch (Exception e)
            {
                var message = String.Format("Couldn't determ aggregate root type from typename '{0}'.", mappingAttribute.TypeName);
                throw new AutoMappingException(message, e);
            }
        }
예제 #2
0
        public static DirectMethodCommandInfo CreateFromDirectMethodCommand(ICommand command)
        {
            if (command == null)
            {
                throw new ArgumentNullException("command");
            }

            Type aggregateRootType    = GetAggregateRootType(command);
            long aggregateRootVersion = GetAggregateRootVersion(command);
            Guid aggregateRootId      = GetAggregateRootId(command);
            MapsToAggregateRootMethodAttribute attribute = GetMappingAttribute(command);
            string methodName = String.IsNullOrEmpty(attribute.MethodName) ? command.GetType().Name : attribute.MethodName;

            return(new DirectMethodCommandInfo(command, aggregateRootType, aggregateRootId, aggregateRootVersion, methodName));
        }