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)); }
public T Create <T>(ObjectCreationSettingsCollection mappings) { if (mappings == null) { throw new ArgumentException("mappings is null"); } return(ObjectCreationAndPopulationFactory.Create <T>(mappings)); }
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); }