public Apply ( NHibernate.Cfg.Configuration cfg ) : void | ||
cfg | NHibernate.Cfg.Configuration | NHibernate Configuration instance |
return | void |
/// <summary> /// Verifies the configuration and populates the NHibernate Configuration instance. /// </summary> /// <returns>NHibernate Configuration instance</returns> public Configuration BuildConfiguration() { try { var mappingCfg = new MappingConfiguration(logger); foreach (var builder in mappingsBuilders) { builder(mappingCfg); } mappingCfg.Apply(Configuration); if (cache.IsDirty) { Configuration.AddProperties(cache.Create()); } foreach (var configAlteration in configAlterations) { configAlteration(Configuration); } return(Configuration); } catch (Exception ex) { throw CreateConfigurationException(ex); } }
/// <summary> /// Verifies the configuration and populates the NHibernate Configuration instance. /// </summary> /// <returns>NHibernate Configuration instance</returns> public Configuration BuildConfiguration() { try { var mappingCfg = new MappingConfiguration(logger); if (mappingsBuilder != null) { mappingsBuilder(mappingCfg); } mappingCfg.Apply(Configuration); foreach (var configAlteration in configAlterations) { configAlteration(Configuration); } return(Configuration); } catch (Exception ex) { throw CreateConfigurationException(ex); } }
public override void ContributeMappings(Configuration configuration) { Arg.NotNull("configuration", configuration); MappingConfiguration mappingConfiguration = new MappingConfiguration(); ContributeMappings(mappingConfiguration); mappingConfiguration.Apply(configuration); }
/// <summary> /// Verifies the configuration and populates the NHibernate Configuration instance. /// </summary> /// <returns>NHibernate Configuration instance</returns> public Configuration BuildConfiguration() { try { mappingCfg.Apply(Configuration); foreach (var configAlteration in configAlterations) { configAlteration(Configuration); } return(Configuration); } catch (Exception ex) { throw CreateConfigurationException(ex); } }
public void CoreMappings_Generates_Correct_NHibernate_Mapping_Xml() { if(!Directory.Exists(MappingFileOutputPath)) { Directory.CreateDirectory(MappingFileOutputPath); } if (!Directory.Exists(MappingBaselinePath)) { Directory.CreateDirectory(MappingBaselinePath); } // Arrange MappingConfiguration configuration = new MappingConfiguration(); CoreMappings mappings = new CoreMappings(); mappings.ContributeMappings(configuration); configuration.FluentMappings.ExportTo(MappingFileOutputPath); // Act // NOTE: Exceptions should only occur AFTER export, since Configuration only occurs after export. // NOTE: So, any unhandled exceptions here should simply be suppressed. try { configuration.Apply(null); } catch(ApplicationException) {} // All the exceptions we want to suppress are wrapped in ApplicationExceptions // Assert #if !GENERATE_BASELINES foreach(string fullResourceName in Assembly.GetExecutingAssembly().GetManifestResourceNames()) { if(fullResourceName.StartsWith(MappingBaselineResourceNamespace)) { string asmRelativeName = fullResourceName.Substring(MappingBaselineResourceAssembly.Length); string folderRelativeName = fullResourceName.Substring(MappingBaselineResourceNamespace.Length); TestFileManager.ExtractTestFile(asmRelativeName, Path.Combine(MappingBaselinePath, folderRelativeName)); } } TestFileManager.CompareFilesAgainstBaseline(MappingFileOutputPath, MappingBaselinePath, "*.hbm.xml", (e, a) => { FileAssert.TextFilesAreEqual(e, a, TokenTransformer, "The mapping files did not match"); }); Directory.Delete(TestFilesPath, true); #else foreach (string file in Directory.GetFiles(MappingFileOutputPath, "*.hbm.xml")) { File.Copy(file, Path.Combine(MappingBaselinePath, Path.GetFileName(file))); } #endif }
/// <summary> /// Verifies the configuration and populates the NHibernate Configuration instance. /// </summary> /// <returns>NHibernate Configuration instance</returns> public Configuration BuildConfiguration() { try { var mappingCfg = new MappingConfiguration(logger); if (mappingsBuilder != null) mappingsBuilder(mappingCfg); mappingCfg.Apply(Configuration); foreach (var configAlteration in configAlterations) configAlteration(Configuration); return Configuration; } catch (Exception ex) { throw CreateConfigurationException(ex); } }