Пример #1
0
        /// <summary>
        /// Loads group from xml.
        /// </summary>
        /// <param name="path">Exact/Relative path to xml file you want to save settings to.</param>
        /// <param name="group">SettingsGroup you want to load from group.</param>
        /// <param name="root">Xml Root name</param>
        public static void Load(string path, out SettingsGroup group, string root)
        {
            XmlSerializer s = new XmlSerializer(typeof(SettingsGroup), new XmlRootAttribute(root));

            if (File.Exists(path))
            {
                TextReader r = new StreamReader(path);
                group = (SettingsGroup)s.Deserialize(r);
                r.Close();
            }
            else
            {
                group = new SettingsGroup();
            }
        }
Пример #2
0
 /// <summary>
 /// Saves shares in directory specified
 /// </summary>
 /// <param name="dir">Directory where we should save settings to</param>
 public void Save(string dir)
 {
     directory = dir;
     SettingsGroup setting = new SettingsGroup();
     System.Text.StringBuilder sb = new System.Text.StringBuilder();
     foreach (KeyValuePair<string, IShare> item in shares)
     {
         sb.Append(item.Key);
         sb.Append("|");
     }
     if (sb.Length > 0)
         setting.Add(IndexShareNames, new SettingItem(sb.ToString(), null));
     FlowLib.Utils.FileOperations.PathExists(dir);
     SettingsGroup.Save(dir + FileName + ".xml", setting, FileName);
     setting = null;
 }
Пример #3
0
        /// <summary>
        /// Load shares from setting files from dir
        /// </summary>
        /// <param name="dir">directory where you want to load your shares from</param>
        public void Load(string dir)
        {
            directory = dir;
            SettingsGroup setting = new SettingsGroup();
            SettingsGroup.Load(dir + FileName + ".xml", out setting, FileName);

            // Share names
            string tmpshareNames = setting.GetString(IndexShareNames);
            if (tmpshareNames != null)
            {
                // Load shares
                string[] tmpNames = tmpshareNames.Split('|');
                foreach (string var in tmpNames)
                {
                    if (var == string.Empty)
                        continue;
                    IShare s = new Share(var);
                    s.Load(dir);
                    shares.Add(s.Name, s);
                }
                tmpNames = null;
            }
            // If default share doesnt exist, create it.
            if (!shares.ContainsKey("Default"))
            {
                IShare s = new Share("Default");
                AddShare(s);
            }
            tmpshareNames = null;
            Reload();
        }
Пример #4
0
 /// <summary>
 /// Saves group to xml.
 /// </summary>
 /// <param name="path">Exact/Relative path to xml file you want to save settings to.</param>
 /// <param name="group">SettingsGroup you want to save to xml file.</param>
 /// <param name="root">Xml Root name</param>
 public static void Save(string path, SettingsGroup group, string root)
 {
     XmlSerializer s = new XmlSerializer(group.GetType(), new XmlRootAttribute(root));
     TextWriter w = new StreamWriter(path);
     s.Serialize(w, group);
     w.Close();
 }
Пример #5
0
 /// <summary>
 /// Saves group to xml.
 /// Xml Root name is "Settings".
 /// </summary>
 /// <param name="path">Exact/Relative path to xml file you want to save settings to.</param>
 /// <param name="group">SettingsGroup you want to save to xml file.</param>
 public static void Save(string path, SettingsGroup group)
 {
     Save(path, group, "Settings");
 }
Пример #6
0
 /// <summary>
 /// Loads group from xml.
 /// </summary>
 /// <param name="path">Exact/Relative path to xml file you want to save settings to.</param>
 /// <param name="group">SettingsGroup you want to load from group.</param>
 /// <param name="root">Xml Root name</param>
 public static void Load(string path, out SettingsGroup group, string root)
 {
     XmlSerializer s = new XmlSerializer(typeof(SettingsGroup), new XmlRootAttribute(root));
     if (File.Exists(path))
     {
         TextReader r = new StreamReader(path);
         group = (SettingsGroup)s.Deserialize(r);
         r.Close();
     }
     else
     {
         group = new SettingsGroup();
     }
 }
Пример #7
0
 /// <summary>
 /// Loads group from xml.
 /// Xml Root name is "Settings".
 /// </summary>
 /// <param name="path">Exact/Relative path to xml file you want to save settings to.</param>
 /// <param name="group">SettingsGroup you want to load from group.</param>
 public static void Load(string path, out SettingsGroup group)
 {
     Load(path, out group, "Settings");
 }
Пример #8
0
 /// <summary>
 /// Loads group from xml.
 /// Xml Root name is "Settings".
 /// </summary>
 /// <param name="path">Exact/Relative path to xml file you want to save settings to.</param>
 /// <param name="group">SettingsGroup you want to load from group.</param>
 public static void Load(string path, out SettingsGroup group)
 {
     Load(path, out group, "Settings");
 }
Пример #9
0
 /// <summary>
 /// Saves group to xml.
 /// Xml Root name is "Settings".
 /// </summary>
 /// <param name="path">Exact/Relative path to xml file you want to save settings to.</param>
 /// <param name="group">SettingsGroup you want to save to xml file.</param>
 public static void Save(string path, SettingsGroup group)
 {
     Save(path, group, "Settings");
 }