Came up with a useful little extension method today. I wanted the fluent nhibernate configuration to export the hbm files when the site is being run in debug mode.
1: /// <summary>
2: /// Export hbm to path if debug environment
3: /// </summary>
4: /// <param name="fluentMappingsContainer">Container</param>
5: /// <param name="path">Path</param>
6: /// <returns>container</returns>
7: public static FluentMappingsContainer ExportPathIfDebug(this FluentMappingsContainer fluentMappingsContainer, string path)
8: {
9: #if DEBUG
10: if (ConfigurationManager.AppSettings[path] != null)
11: {
12: if (!Directory.Exists(ConfigurationManager.AppSettings[path])) Directory.CreateDirectory(ConfigurationManager.AppSettings[path]);
13: fluentMappingsContainer.ExportTo(ConfigurationManager.AppSettings[path]);
14: }
15: #endif
16: return fluentMappingsContainer;
17: }
No comments:
Post a Comment