コード例 #1
0
        public static XElement LoadMappingFile(string fileKey)
        {
            MappingFileElement element = MappingFileSection.GetConfig().FileLocations[fileKey];

            ExceptionHelper.TrueThrow(element == null, string.Format("没有与fileKey :{0}匹配的配置信息", fileKey));
            return(LoadMappingFile(element));
        }
コード例 #2
0
        private static string GetFilePath(MappingFileElement element)
        {
            ExceptionHelper.TrueThrow(string.IsNullOrWhiteSpace(element.FileName), string.Format("配置信息fileName不能为空"));
            string filePath = Path.Combine(GetBaseDir(), element.FileName);

            ExceptionHelper.FalseThrow(File.Exists(filePath), string.Format("未找到filePath:{0}对应的文件", filePath));
            return(filePath);
        }
コード例 #3
0
 public static XElement LoadMappingFile(MappingFileElement element)
 {
     using (XmlReader reader = XmlReader.Create(GetFilePath(element)))
     {
         while (reader.NodeType != XmlNodeType.Element)
         {
             reader.Read();
         }
         return(XElement.Load(reader));
     }
 }