プログラムの更新に必要な情報を表します。
Example #1
0
        public MainForm(UpdateArgs args)
        {
            InitializeComponent();
            _updater = new CandyUpdater(args);

            lblMessage.Text = String.Format("{0} をアップデート中", args.ApplicationName);
        }
Example #2
0
        /// <summary>
        /// コマンドライン引数から <see cref="UpdateArgs"/> を生成します。
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        public static UpdateArgs Parse(string[] args)
        {
            /*
             * ToolUpdater.exe /n "シャルロッテ" /p "D:\Tools\Charlotte" /u "http://192.168.47.74:8020/Charlotte/Update?v=1.12"
             * のようなコマンドライン引数をパース
             */

            var obj = new UpdateArgs
            {
                StepDelay = 400,
            };

            PropertyInfo property = null;
            foreach (var s in args.Where(x => x.Length > 0))
            {
                // スラッシュまたはハイフンで始まる場合をキーとみなす
                var c = s[0];
                if (c == '/' || c == '-')
                {
                    // キーに一致するプロパティを取得
                    _propertyDic.TryGetValue(s.Substring(1), out property);
                    // プロパティが Boolean の場合は指定された時点で true をセット
                    if (property.PropertyType == typeof(bool))
                    {
                        property.SetValue(obj, true);
                        property = null;
                    }
                    continue;
                }

                // 直前のコマンドライン引数がプロパティのキーだった場合は、今回の文字列を値とみなす
                if (property != null)
                {
                    property.SetValue(obj, s);
                }

                property = null;
            }

            return obj;
        }
Example #3
0
 /// <summary>
 /// <see cref="CandyUpdater"/> クラスの新しいインスタンスを初期化します。
 /// </summary>
 /// <param name="args"></param>
 public CandyUpdater(UpdateArgs args)
 {
     _args = args;
 }
Example #4
0
 /// <summary>
 /// <see cref="CandyUpdater"/> クラスの新しいインスタンスを初期化します。
 /// </summary>
 /// <param name="args"></param>
 public CandyUpdater(UpdateArgs args)
 {
     _args = args;
 }