コード例 #1
0
        public static DomainModel LoadDomainModelTemplateWithSettings()
        {
            ConfigSection configSection = new Config(@"MoreComplexExamples\AutoGenerateModelsFromConfigWithDefaultValues\autogendefaults.config", "domainModelTemplate").GetSection("model");
            ObjectCreationSettingsCollection creationSettings = configSection.CreateCreationSettingsCollection(false); //set private properties as well.

            creationSettings.SetValue("NumberUnits", "123");

            return(configSection.Create <DomainModel>(creationSettings));
        }
コード例 #2
0
        public T Create <T>(ObjectCreationSettingsCollection mappings)
        {
            if (mappings == null)
            {
                throw new ArgumentException("mappings is null");
            }

            return(ObjectCreationAndPopulationFactory.Create <T>(mappings));
        }
コード例 #3
0
        public void TestCanCreateObjectWithDefaultValuesUsingObjectCreationSettingsCollection()
        {
            const string description    = "This is my Test description";
            const string numberUnitsStr = "4456";
            const int    numberUnitsInt = 4456;

            CustomConfigurations.ConfigSection configSection = new CustomConfigurations.Config("MinDefaultedTypedDataConfig").GetSection("model");
            ObjectCreationSettingsCollection   settings      = configSection.CreateCreationSettingsCollection();

            settings.SetValue("NumberUnits", numberUnitsStr);
            settings.SetValue("Description", description);

            DefaultsDomainModel model = configSection.Create <DefaultsDomainModel>(settings);

            Assert.AreEqual("model", model.Name);
            Assert.IsTrue(model.CanExecute);
            Assert.AreEqual(description, model.Description);
            Assert.AreEqual(numberUnitsInt, model.NumberUnits);
            Assert.AreEqual(DomainModelType.TheirType, model.ModelType);
            Assert.AreEqual(2, model.MySecretNumber);
        }