Beispiel #1
0
        public static void Save(this IXSettings obj)
        {
            XElement  xElement  = obj.Serialize();
            XDocument xDocument = new XDocument(new XComment(obj._Comment), xElement);

            if (!Directory.Exists(Path.GetDirectoryName(obj._FileName("xml"))))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(obj._FileName("xml")));
            }
            xDocument.Save(obj._FileName("xml"));
        }
Beispiel #2
0
 public static void Load(this IXSettings obj)
 {
     if (File.Exists(obj._FileName("xml")))
     {
         XDocument xDocument;
         try
         {
             xDocument = XDocument.Load(obj._FileName("xml"));
         }
         catch (Exception)//>>说明文件被破坏
         {
             File.Delete(obj._FileName("xml"));
             return;
         }
         obj.DeSerialize(xDocument.Root);
     }
     obj.OnSettingsInitialized();
 }