private static void LoadResourceItem(string Folder, string TypeName, string ConfigNamespace, System.Reflection.Assembly configAssembly, string item) { string itemName = item.Substring(ConfigNamespace.Length + 1); string[] tokens = itemName.Split('.'); using (Stream fileStream = configAssembly.GetManifestResourceStream(item)) { using (XmlTextReader xreader = new XmlTextReader(fileStream)) { XDocument doc = XDocument.Load(xreader); IConfigurationObject config = ConfigurationObjectFactory.CreateConfigurationObject(TypeName); if (tokens.Length == 3) { //simple folder/child relationship config.Load(doc, Folder); } else { config.Load(doc, tokens[1]); } } } }
private static void LoadFile(string entityName, string file) { try { XDocument doc = XDocument.Load(file); string folder = Path.GetDirectoryName(file).Substring(Path.GetDirectoryName(file).LastIndexOf("\\") + 1); IConfigurationObject config = ConfigurationObjectFactory.CreateConfigurationObject(entityName); config.Load(doc, folder); } catch (Exception ex) { throw new ApplicationException(String.Format("Error loading {0} configuration file: {1}", entityName, file), ex); } }