public IndexMapping GetMapping(string indexName) { if (!_mappings.ContainsKey(indexName)) { CheckForUnloading(indexName); _mappings[indexName] = new MappingResource(_rootPath, indexName); } return(_mappings[indexName].Mapping); }
public string LoadMappingXml() { if (MappingResource.IsEmpty()) { throw new Exception("No MappingResource is specified for this data provider factory."); } if (MappingResource.Contains("/") || MappingResource.Contains("\\")) { // Physical file: var path = AppDomain.CurrentDomain.BaseDirectory + MappingResource; path = path.Replace("/", "\\").Replace("\\\\", "\\"); if (path.StartsWith("\\")) { path = "\\" + path; } if (!File.Exists(path)) { throw new FileNotFoundException("Could not find the data mapping xml at : " + path); } return(File.ReadAllText(path)); } else { // Embedded resource: foreach (var resourceName in GetAssembly().GetManifestResourceNames()) { if (resourceName.ToLower() == MappingResource.ToLower() || resourceName.ToLower().EndsWith("." + MappingResource.ToLower())) { return(LoadMappingText(resourceName)); } // using (var resource = GetAssembly().GetManifestResourceStream(resourceName)) // { // using (var reader = new StreamReader(resource)) // { // return reader.ReadToEnd(); // } // } } throw new Exception("Could not build a data provider factory for " + GetAssembly().FullName + " because: Could not load the manifest resource " + MappingResource + " from the assembly" + GetAssembly().FullName + "."); } }