public static DomainModel LoadDomainModelTemplate()
        {
            ConfigSection configSection = new Config(@"MoreComplexExamples\AutoGenWithNonEmptyConstructor\autogenctor.config", "domainModelTemplate").GetSection("model");

            ConfigValueDictionary mappings = new ConfigValueDictionary();
            mappings.Add("mySecretNum", "MySecretNumber");  //pass in the param name for the constructor and the key of the corresponding ValueItem from config
            mappings.Add("numberUnits", "NumberUnits");    //remember that all params are case sensitive

            //if mappings had not been used it would not have known what values to use for both of these values which it got from config
            return configSection.Create<DomainModel>(mappings, true);
        }
Exemplo n.º 2
0
        public static DomainModel LoadDomainModelTemplate()
        {
            ConfigSection configSection = new Config(@"MoreComplexExamples\AutoGenWithNonEmptyConstructor\autogenctor.config", "domainModelTemplate").GetSection("model");

            ConfigValueDictionary mappings = new ConfigValueDictionary();

            mappings.Add("mySecretNum", "MySecretNumber"); //pass in the param name for the constructor and the key of the corresponding ValueItem from config
            mappings.Add("numberUnits", "NumberUnits");    //remember that all params are case sensitive

            //if mappings had not been used it would not have known what values to use for both of these values which it got from config
            return(configSection.Create <DomainModel>(mappings, true));
        }
        public static AutoGenerateModelsFromConfig.DomainModel LoadDomainModelTemplate()
        {
            ConfigValueDictionary mappings = new ConfigValueDictionary();
            mappings.Add("NoUnits", "NumberUnits");

            return new Config(@"MoreComplexExamples\MappingFieldsAutoGen\mapping.config", "domainModelTemplate")
                .GetSection("model")
                .Create<AutoGenerateModelsFromConfig.DomainModel>(mappings, true);
        }
        public static AutoGenerateModelsFromConfig.DomainModel LoadDomainModelTemplate()
        {
            ConfigValueDictionary mappings = new ConfigValueDictionary();

            mappings.Add("NoUnits", "NumberUnits");

            return(new Config(@"MoreComplexExamples\MappingFieldsAutoGen\mapping.config", "domainModelTemplate")
                   .GetSection("model")
                   .Create <AutoGenerateModelsFromConfig.DomainModel>(mappings, true));
        }
        public void TestCanCreateObjectThatDoesntHaveEmptyConstructor()
        {
            CustomConfigurations.ConfigSection configSection = new CustomConfigurations.Config("TypedDataConfig").GetSection("model");
            Assert.IsNotNull(configSection);

            ConfigValueDictionary mappings = new ConfigValueDictionary();
            mappings.Add("NoUnits", "NumberUnits");
            mappings.Add("name", "Name");
            mappings.Add("canExecute", "CanExecute");

            ComplexDomainModel model = configSection.Create<ComplexDomainModel>(mappings, true);

            Assert.AreEqual("model", model.GetResultOfConstructorSetName());
            Assert.IsTrue(model.GetResultOfConstructorSetCanExecute());
            Assert.AreEqual("domain model template desciption field", model.Description);
            Assert.AreEqual(23, model.NumberUnits);
            Assert.AreEqual(DomainModelType.TheirType, model.ModelType);
            Assert.AreEqual(int.MinValue, model.GetResultFromMySecretNumberPrivateSetter());
        }
Exemplo n.º 6
0
        public void TestCanCreateObjectThatDoesntHaveEmptyConstructor()
        {
            CustomConfigurations.ConfigSection configSection = new CustomConfigurations.Config("TypedDataConfig").GetSection("model");
            Assert.IsNotNull(configSection);

            ConfigValueDictionary mappings = new ConfigValueDictionary();

            mappings.Add("NoUnits", "NumberUnits");
            mappings.Add("name", "Name");
            mappings.Add("canExecute", "CanExecute");

            ComplexDomainModel model = configSection.Create <ComplexDomainModel>(mappings, true);

            Assert.AreEqual("model", model.GetResultOfConstructorSetName());
            Assert.IsTrue(model.GetResultOfConstructorSetCanExecute());
            Assert.AreEqual("domain model template desciption field", model.Description);
            Assert.AreEqual(23, model.NumberUnits);
            Assert.AreEqual(DomainModelType.TheirType, model.ModelType);
            Assert.AreEqual(int.MinValue, model.GetResultFromMySecretNumberPrivateSetter());
        }
Exemplo n.º 7
0
        public void TestCanCreateTypedObjectAndPopulateWithFieldMappings()
        {
            CustomConfigurations.ConfigSection configSection = new CustomConfigurations.Config("TypedDataConfig").GetSection("model");
            Assert.IsNotNull(configSection);

            ConfigValueDictionary mappings = new ConfigValueDictionary();

            mappings.Add("NoUnits", "NumberUnits");

            DomainModel model = configSection.Create <DomainModel>(mappings, true);

            Assert.AreEqual("model", model.Name);
            Assert.IsTrue(model.CanExecute);
            Assert.AreEqual("domain model template desciption field", model.Description);
            Assert.AreEqual(23, model.NumberUnits);
            Assert.AreEqual(DomainModelType.TheirType, model.ModelType);
            Assert.AreEqual(int.MinValue, model.GetResultFromMySecretNumberPrivateSetter());
        }
        public void TestCanCreateTypedObjectAndPopulateWithFieldMappings()
        {
            CustomConfigurations.ConfigSection configSection = new CustomConfigurations.Config("TypedDataConfig").GetSection("model");
            Assert.IsNotNull(configSection);

            ConfigValueDictionary mappings = new ConfigValueDictionary();
            mappings.Add("NoUnits", "NumberUnits");

            DomainModel model = configSection.Create<DomainModel>(mappings, true);

            Assert.AreEqual("model", model.Name);
            Assert.IsTrue(model.CanExecute);
            Assert.AreEqual("domain model template desciption field", model.Description);
            Assert.AreEqual(23, model.NumberUnits);
            Assert.AreEqual(DomainModelType.TheirType, model.ModelType);
            Assert.AreEqual(int.MinValue, model.GetResultFromMySecretNumberPrivateSetter());
        }