Exemplo n.º 1
0
        protected override void Creating()
        {
            var options = new ContractGeneratorOptionsBuilder();

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

            if (GivensDefined("Exclude"))
            {
                options.ExcludeMembersDeclaredOn(Given.Exclude);
            }

            Then.Container = new WrappedTypeContainer(null, Given.CustomNamingStrategy);
            Then.Container.Register(Given.Type);
            Then.Target = new ContractGenerator(options.Build(), Then.Container);
        }
Exemplo n.º 2
0
        protected override void Creating()
        {
            var contractOptions = new ContractGeneratorOptionsBuilder();
            var typeOptions     = new TypeGeneratorOptionsBuilder();

            if (GivensDefined("AsPublicWasCalled"))
            {
                contractOptions.WithPublic();
                typeOptions.WithPublic();
            }

            Then.Container = new WrappedTypeContainer(Given.CustomNamingStrategy);
            Then.Container.Register <SomeType>();

            Then.TypeGenerator     = new TypeGenerator(typeOptions.Build(), Then.Container);
            Then.ContractGenerator = new ContractGenerator(contractOptions.Build(), Then.Container);

            Then.Target = new AutoWrapper.CodeGen.CodeGenerator();
        }
Exemplo n.º 3
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));
        }