예제 #1
0
        private static Settings Load()
        {
            Settings res;

            if (File.Exists(FileSettings))
            {
                try
                {
                    SerializerXml ser = new SerializerXml(FileSettings);
                    res = ser.DeserializeXmlFile <Settings>();
                }
                catch
                {
                    res = new Settings();
                    res.SetDefault();
                }
            }
            else
            {
                res = new Settings();
                res.SetDefault();
                res.Save();
            }
            return(res);
        }
예제 #2
0
 public static void Init()
 {
     // загрузка из файла
     FileXml =General.GetUserDataFile("","CommandCounter.xml");
     if (File.Exists(FileXml))
     {
         SerializerXml xmlSer = new SerializerXml(FileXml);
         try
         {
             Counter = xmlSer.DeserializeXmlFile<CommandCounter>();
             if (Counter != null)
             {
                 Counter._commands = Counter.Commands.Where(c=>!string.IsNullOrEmpty(c.CommandName)).ToDictionary(c=>c.CommandName, c=>c);
                 Logger.Log.Debug($"Counter.Commands.Count={Counter.Commands.Count}");
                 return;
             }
         }
         catch (Exception ex)
         {
             Logger.Log.Error(ex, $"Не удалось десериализовать файл {FileXml}");
         }
     }
     Logger.Log.Debug($"Counter = new CommandCounter();");
     Counter = new CommandCounter();
 }
예제 #3
0
        public static HorizontalElevationOptions Load()
        {
            HorizontalElevationOptions options = null;

            // загрузка из файла настроек
            if (File.Exists(fileOptions))
            {
                SerializerXml xmlSer = new SerializerXml(fileOptions);
                try
                {
                    options = xmlSer.DeserializeXmlFile <HorizontalElevationOptions>();
                    if (options != null)
                    {
                        return(options);
                    }
                }
                catch (Exception ex)
                {
                    Logger.Log.Error(ex, $"Не удалось десериализовать настройки из файла {fileOptions}");
                }
            }
            options = new HorizontalElevationOptions();
            options.Save();
            return(options);
        }
예제 #4
0
 protected static OptionsAbstract load(string file)
 {
     OptionsAbstract options = null;
      // загрузка из файла настроек
      if (File.Exists(file))
      {
     SerializerXml xmlSer = new SerializerXml(file);
     try
     {
        options = xmlSer.DeserializeXmlFile<OptionsAbstract>();
        if (options != null)
        {
           return options;
        }
     }
     catch (Exception ex)
     {
        Log.Error(ex, "Не удалось десериализовать настройки из файла {0}", file);
     }
      }
      return defaultOptions();
 }
예제 #5
0
 public static IsolineOptions Load()
 {
    IsolineOptions options = null;
    // загрузка из файла настроек
    if (File.Exists(fileOptions))
    {
       SerializerXml xmlSer = new SerializerXml(fileOptions);
       try
       {
          options = xmlSer.DeserializeXmlFile<IsolineOptions>();
          if (options != null)
          {
             options.LoadDrawingOptions();
             return options;
          }
       }
       catch (Exception ex)
       {
          Logger.Log.Error(ex, "Не удалось десериализовать настройки из файла {0}", fileOptions);
       }
    }
    return DefaultOptions();
 }
예제 #6
0
        public static IsolineOptions Load()
        {
            IsolineOptions options = null;

            // загрузка из файла настроек
            if (File.Exists(fileOptions))
            {
                SerializerXml xmlSer = new SerializerXml(fileOptions);
                try
                {
                    options = xmlSer.DeserializeXmlFile <IsolineOptions>();
                    if (options != null)
                    {
                        options.LoadDrawingOptions();
                        return(options);
                    }
                }
                catch (Exception ex)
                {
                    Logger.Log.Error(ex, "Не удалось десериализовать настройки из файла {0}", fileOptions);
                }
            }
            return(DefaultOptions());
        }
예제 #7
0
        private static LineParkingOptions load()
        {
            LineParkingOptions options = null;

            // загрузка из файла настроек
            if (File.Exists(fileOptions))
            {
                SerializerXml xmlSer = new SerializerXml(fileOptions);
                try
                {
                    options = xmlSer.DeserializeXmlFile <LineParkingOptions>();
                    if (options != null)
                    {
                        options.checkValues();
                        return(options);
                    }
                }
                catch (Exception ex)
                {
                    Log.Error(ex, "Не удалось десериализовать настройки из файла {0}", fileOptions);
                }
            }
            return(defaultOptions());
        }
예제 #8
0
 public static Options Load()
 {
     Options options = null;
     // загрузка из файла настроек
     if (File.Exists(fileOptions))
     {
         SerializerXml xmlSer = new SerializerXml(fileOptions);
         try
         {
             options = xmlSer.DeserializeXmlFile<Options>();
             if (options != null)
             {
                 return options;
             }
         }
         catch (Exception ex)
         {
             Logger.Log.Error(ex, $"Не удалось десериализовать настройки из файла {fileOptions}");
         }
     }
     options = new Options();
     options.Save();
     return options;
 }
예제 #9
0
 private static LineParkingOptions load()
 {
     LineParkingOptions options = null;
      // загрузка из файла настроек
      if (File.Exists(fileOptions))
      {
     SerializerXml xmlSer = new SerializerXml(fileOptions);
     try
     {
        options = xmlSer.DeserializeXmlFile<LineParkingOptions>();
        if (options != null)
        {
           options.checkValues();
           return options;
        }
     }
     catch (Exception ex)
     {
        Log.Error(ex, "Не удалось десериализовать настройки из файла {0}", fileOptions);
     }
      }
      return defaultOptions();
 }