View difference between Paste ID: fyr8QREN and dsM09Mbe
SHOW: | | - or go back to the newest paste.
1
using System;
2
using System.Collections.Generic;
3
using System.Configuration;
4
using System.Linq;
5
using System.Net;
6
using System.Text;
7
using System.Threading.Tasks;
8
using YGOPro2_Updater;
9
10
namespace YGOPro_Updater
11
{
12-
    internal class Updater
12+
    public class Updater
13
    {
14-
       public static void Command(string[] args)
14+
       public void Command(string[] args)
15
        {
16
            Console.Title = "YGOPro_Updater";
17
            // 线程数
18
            ServicePointManager.DefaultConnectionLimit = Int32.Parse(ConfigurationManager.AppSettings[name: "ConnectionLimit"]);
19
            // 忽略列表
20
            for (int i = 1; !string.IsNullOrEmpty(value: ConfigurationManager.AppSettings[name: $"ignore{i}"]); i++)
21
                Config.ignores.Add(item: ConfigurationManager.AppSettings[name: $"ignore{i}"].Replace(oldValue: "*", newValue: "[^/]*?"));
22
            int arguments = args.Length;
23
            // whether the Arguments are Correct
24
            bool isOK = false;
25
26
            // Check the Ignore Sound Option
27
            if (arguments > 0 && args[arguments - 1] == "--ignore-sound")
28
            {
29
                Config.ignoreSound = true;
30
                arguments--;
31
            }
32
33
            switch (arguments)
34
            {
35
                case 0: // Download and Update the All Files
36
                    for (Config.count = 1; !string.IsNullOrEmpty(value: ConfigurationManager.AppSettings[name: $"name{Config.count}"]); Config.count++)
37
                    {
38
                        Config.SetWorkPath(workPath: null, name: null, repo: null);
39
                        Client.Run(); // 开始実行
40
                    }
41
                    break;
42
                case 1: // Workpath Setting Option
43
                    for (Config.count = 1; !string.IsNullOrEmpty(value: ConfigurationManager.AppSettings[name: $"name{Config.count}"]); Config.count++)
44
                    {
45
                        Config.SetWorkPath(workPath: args[0], name: null, repo: null);
46
                        Client.Run(); // 开始実行
47
                    }
48
                    break;
49
                case 2: // Download and Update the Files from the Specific Repository
50
                    for (int i = 1; !string.IsNullOrEmpty(value: ConfigurationManager.AppSettings[name: $"name{i}"]); i++)
51
                    {
52
                        if (args[0] == ConfigurationManager.AppSettings[name: $"name{i}"]
53
                            && args[1] == ConfigurationManager.AppSettings[name: $"repo{i}"])
54
                        {
55
                            Config.count = i;
56
                            isOK = Config.SetWorkPath(workPath: null, name: args[0], repo: args[1]);
57
                            Client.Run(); // 开始実行
58
                        }
59
                    }
60
                    if (!isOK)
61
                        Console.WriteLine(value: "You typed the wrong username or incorerct repository.");
62
                    break;
63
                case 3: // Download and Update the Files from the Specific Repository with Workpath Setting Option
64
                    for (int i = 1; !string.IsNullOrEmpty(value: ConfigurationManager.AppSettings[name: $"user{i}"]); i++)
65
                    {
66
                        if (args[1] == ConfigurationManager.AppSettings[name: $"name{i}"]
67
                            && args[2] == ConfigurationManager.AppSettings[name: $"repo{i}"])
68
                        {
69
                            Config.count = i;
70
                            isOK = Config.SetWorkPath(workPath: args[0], name: args[1], repo: args[2]);
71
                            Client.Run(); // 开始実行
72
                        }
73
                    }
74
                    if (!isOK)
75
                        Console.WriteLine(value: "You mistyped the workpath, username or repository.");
76
                    break;
77
                default:
78
                    Console.WriteLine(value: "The arguments which you typed are unavailble.");
79
                    break;
80
            }
81
            Console.WriteLine(value: "Press Any Key to continue ... ... ");
82
            Console.ReadKey(intercept: true);
83
        }
84
    }
85
}