public FactoryClass Create(Type factoryInterface, IDivineInjector injector, Type domainObjectType, ConstructorArgList constructorArgList)
 {
     var methods = factoryInterface.GetMethods()
         .Select(m => m_methodFactory.Create(m, injector, domainObjectType))
         .ToList();
     return new FactoryClass(constructorArgList, methods);
 }
        public void EmptyList()
        {
            ConstructorArgList argList;
            Scenario()
                .Given(argList = new ConstructorArgList(null))

                .Then(argList.Arguments, Is(AList.NoItems<IConstructorArg>()));
        }
 public object CreateNewObject()
 {
     var constructorArgList = new ConstructorArgList(m_tb);
     var myType = CompileResultType(constructorArgList);
     var propertyValues = constructorArgList.Arguments
         .OfType<IInjectableConstructorArg>()
         .Select(a => m_injector.Get(a.PropertyType))
         .ToArray();
     return Activator.CreateInstance(myType, propertyValues);
 }
        private Type CompileResultType(ConstructorArgList constructorArgList)
        {
            var factoryClass = m_factoryClassFactory.Create(m_interfaceType, m_injector, m_domainObjectType, constructorArgList);

            factoryClass.EmitConstructor(m_tb);

            foreach (var method in factoryClass.Methods)
                method.EmitMethod(m_tb, constructorArgList);

            return m_tb.CreateType();
        }
        public void OnePassedArg()
        {
            ConstructorArgList argList;
            IPassedConstructorArgDefinition argDef1;
            IConstructorArg arg1;

            Scenario()
                .Given(arg1 = AMock<IConstructorArg>().Instance)
                .Given(argDef1 = AMock<IPassedConstructorArgDefinition>()
                    .WhereMethod(d => d.FindExisting(ArgIsAny<IList<IConstructorArg>>())).ReturnsNull()
                    .WhereMethod(d => d.Define(ArgIsAny<TypeBuilder>())).Returns(arg1)
                    .Instance)
                .Given(argList = new ConstructorArgList(null))

                .When(() => argList.Add(argDef1))

                .Then(argList.Arguments, Is(AList.InOrder().WithOnly(AnInstance.SameAs(arg1))));
        }