Ejemplo n.º 1
0
 public static void AddMapping(CommandDomainMap mapping)
 {
     if (!domainObjectMapping.ContainsKey(mapping.CommandName))
     {
         domainObjectMapping.Add(mapping.CommandName, mapping);
     }
 }
        public void Handle(CommandBase command)
        {
            CommandDomainMap map = CommandMapper.GetMappingForCommand(command.GetType().Name);

            if (map != null && String.IsNullOrWhiteSpace(map.DomainClassMethodName))
            {
                //invoke the AR's ctor
                Type t = Type.GetType(map.DomainClassName);
                if (t != null)
                {
                    Activator.CreateInstance(t, command);
                }
            }
            else if (map != null)
            {
                //invoke a AR method
                Type t = Type.GetType(map.DomainClassName);
                if (t != null)
                {
                    Object domain = Activator.CreateInstance(t);
                    domain.GetType().InvokeMember(map.DomainClassMethodName,
                                                  System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.InvokeMethod,
                                                  null,
                                                  domain,
                                                  new object[] { command });
                }
            }
            else
            {
                //punt?
            }
        }