Exemplo n.º 1
0
 private static WaterModuleConfigInfo GetInstance()
 {
     if (configMod == null)
     {
         configMod = ConfigReadFromFile();
     }
     return(configMod);
 }
 /// <summary>
 /// 更新配置文件
 /// </summary>
 /// <param name="config"></param>
 public void Update(WaterModuleConfigInfo config)
 {
     try
     {
         XmlSerializer serializer = new XmlSerializer(typeof(WaterModuleConfigInfo));
         using (Stream stream = new FileStream(this.filePath, FileMode.Create, FileAccess.Write, FileShare.None))
         {
             XmlSerializerNamespaces namespaces = new XmlSerializerNamespaces();
             namespaces.Add("", "");
             serializer.Serialize(stream, config, namespaces);
         }
     }
     catch (SecurityException exception)
     {
         throw new SecurityException(exception.Message, exception.DenySetInstance, exception.PermitOnlySetInstance, exception.Method, exception.Demanded, exception.FirstPermissionThatFailed);
     }
 }