Пример #1
0
        private void SaveConfigList()
        {
            var updatedConfigs = new ConfigList();

            foreach (var config in _configList)
            {
                updatedConfigs.Add(config);
            }
            Settings.Default.ConfigList = updatedConfigs;
            Settings.Default.Save();
        }
    /// <summary>
    /// 新增方案
    /// </summary>
    /// <param name="name"></param>
    /// <returns></returns>
    public static SchemeData AddScheme(string name)
    {
        SchemeData data = new SchemeData();

        data.SchemeName = name;

        ConfigList.Add(data);
        ConfigNameList.Add(data.SchemeName);
        SaveEditorSchemeData();

        return(data);
    }
Пример #3
0
        private void LoadConfigurations()
        {
            var systemPath = System.Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);

            // string[] filePaths = Directory.GetFiles(systemPath);
            ConfigList.Clear();
            foreach (var file in Directory.EnumerateFiles(systemPath, "*.xml"))
            {
                string fileName_ = file.ToString().Replace(systemPath.ToString() + "\\", "");
                fileName_ = fileName_.Replace(".xml", "");
                ConfigList.Add(fileName_);
            }
        }
        private void Button_ClickAddConfigKey(object sender, RoutedEventArgs e)
        {
            if (!string.IsNullOrEmpty(TextBox_ConfigName.Text))
            {
                KeyValue kv = new KeyValue();
                kv.Key = TextBox_ConfigName.Text;

                ConfigList.Add(kv);

                ConfigList = ConfigList;

                TextBox_ConfigName.Text = "";
            }
        }
Пример #5
0
        public void ExportConfigs(string filePath, int[] indiciesToSave)
        {
            var savingConfigs = new ConfigList();

            foreach (int index in indiciesToSave)
            {
                savingConfigs.Add(_configList[index]);
            }
            var tempSettings = new Settings();

            tempSettings.ConfigList = savingConfigs;
            tempSettings.Save();
            var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);

            config.SaveAs(filePath);
            Settings.Default.Save();
        }
Пример #6
0
 public void AddNeedScan(EmailConfig ec)
 {
     ConfigList.Add(ec);
 }
Пример #7
0
		static ConfigList ConvertObject(object o)
		{
			var lst = new ConfigList();

			if (o is IEnumerable<KeyValuePair<string, object>>)
			{
				var oe = (IEnumerable<KeyValuePair<string, object>>)o;
				foreach(var kvp in oe)
				{
					if (kvp.Value is ValueType || kvp.Value is string)
						lst.Add(kvp);
					else
						lst.Add(kvp.Key, ConvertObject(kvp.Value));
				}
			}
			else if (o is System.Collections.IEnumerable)
			{
				var oe = (System.Collections.IEnumerable)o;
				
				foreach(var oo in oe)
				{
					if (oo is ValueType || oo is string)
						lst.Add(null, oo);
					else
						lst.Add(null, ConvertObject(oo));
				}
			}

			return lst;
		}
Пример #8
0
		static void Main(string[] args)
		{
			if (args.Length < 2)
			{
				Console.WriteLine("USAGE: BookExtractor <json output> <json inputs...>");
				return;
			}

			var json = new JSONSerializer();

			var booksOutput = new ConfigList();

			var sb = new StringBuilder();
			
			for (int i = 1; i < args.Length; i++)
			{
				long fsz = new FileInfo(args[i]).Length;
				using (var sr = new StreamReader(args[i]))
				{
					Console.WriteLine("Reading {0}", args[i]);
					string line;
					int lastPercent = 0;
					bool skip = true;

					while ((line = sr.ReadLine()) != null)
					{
						int newPercent = (int)((sr.BaseStream.Position * 100L) / fsz);

						if (newPercent != lastPercent)
						{
							lastPercent = newPercent;
							Console.WriteLine("{0}: {1,3}%", args[i], lastPercent);
						}

						if (line.StartsWith("\t{"))
						{
							sb.Clear();
							sb.AppendLine("{");
							skip = true;
						}
						else if (line.StartsWith("\t}"))
						{
							if (skip)
								continue;

							sb.AppendLine("}");
							var lst = json.Deserialize(sb.ToString());

							if (lst.ContainsKey("Items"))
							{
								var lstt = lst["Items"] as ConfigList;
								if (lstt != null)
								{
									foreach (ConfigPair pair in lstt)
									{
										ConfigList pairData = (ConfigList)pair.Value;

										string pdi = pairData["id"] as string;
										if (pdi == null)
											continue;
										if (pdi == "minecraft:written_book")
											booksOutput.Add(null, pairData["tag"]);
									}
								}
							}
						}
						else
						{
							if (line.StartsWith("\t\t\"Items\":"))
								skip = false;
							sb.AppendLine(line);
						}
					}
				}
			}

			using (var sw = new StreamWriter(args[0]))
				json.Serialize(booksOutput, sw);
		}