protected override void Creating()
        {
            var options = new TypeGeneratorOptionsBuilder();

            if (GivensDefined("AsPublicWasCalled"))
            {
                options.WithPublic();
            }

            Then.Container = new WrappedTypeContainer(Given.CustomNamingStrategy);
            Then.Container.Register <SomeType>();
            Then.Target = new TypeGenerator(options.Build(), Then.Container);
        }
示例#2
0
        public static string FromContainer(IWrappedTypeContainer container, string namespaceForWrappers)
        {
            var typeOptions = new TypeGeneratorOptionsBuilder(TypeNamingStrategy)
                              .WithPartial()
                              .WithPublic()
                              .Build();

            var contractOptions = new ContractGeneratorOptionsBuilder(ContractNamingStrategy)
                                  .WithPartial()
                                  .WithPublic()
                                  .ExcludeMembersDeclaredOn <object>()
                                  .Build();

            var typeGenerator = new TypeGenerator(typeOptions, container);

            var contractGenerator = new ContractGenerator(contractOptions, container);

            var codeGenerator = new CodeGenerator();

            var ns = new CodeNamespace(namespaceForWrappers);

            foreach (var type in container.RegisteredTypes)
            {
                ns.Types.Add(
                    contractGenerator.GenerateDeclaration(type)
                    );
            }

            foreach (var type in container.RegisteredTypes)
            {
                ns.Types.Add(
                    typeGenerator.GenerateDeclaration(type)
                    );
            }

            var targetUnit = new CodeCompileUnit();

            targetUnit.Namespaces.Add(ns);

            return(codeGenerator.GenerateCode(targetUnit));
        }