예제 #1
0
        protected override void ProcessRecord()
        {
            if (Language == null && !string.IsNullOrEmpty(Name))
            {
                Language[] langs = _setting.GetLanguage(Name);
                if (langs != null && langs.Length > 0)
                {
                    //  すでに同じ名前のLanguageがある為、追加不可
                    return;
                }
                else
                {
                    //  名前を指定の場合は1つずつ追加
                    _setting.Languages.Add(new Language()
                    {
                        Name               = this.Name,
                        Extensions         = this.Extensions,
                        Command            = this.Command,
                        Command_x86        = this.Command_x86,
                        ArgsPrefix         = this.ArgsPrefix,
                        ArgsMidWithoutArgs = this.ArgsMidWithoutArgs,
                        ArgsMidWithArgs    = this.ArgsMidWithArgs,
                        ArgsSuffix         = this.ArgsSuffix
                    });
                }
            }
            else if (Language != null)
            {
                foreach (Language lang in Language)
                {
                    if (_setting.Languages.Any(x => x.Name.Equals(lang.Name, StringComparison.OrdinalIgnoreCase)))
                    {
                        //  すでに同じ名前のLanguageがある為、追加不可
                        return;
                    }
                    else
                    {
                        _setting.Languages.Add(lang);
                    }
                }
            }

            DataSerializer.Serialize <EnumRunSetting>(_setting, SettingPath);

            WriteObject(_setting);
        }
예제 #2
0
 protected override void ProcessRecord()
 {
     if (Version)
     {
         WriteObject("EnumRun - v" + Function.GetVersion());
     }
     else
     {
         if (Name == null)
         {
             WriteObject(_setting.Languages, true);
         }
         else
         {
             WriteObject(_setting.GetLanguage(Name), true);
         }
     }
 }
예제 #3
0
 protected override void ProcessRecord()
 {
     if (Language == null && !string.IsNullOrEmpty(Name))
     {
         foreach (Language lang in _setting.GetLanguage(Name))
         {
             _setting.Languages.Remove(lang);
         }
     }
     else if (Language != null)
     {
         //  名前判定せず、インスタンスの中身が一致したら削除
         foreach (Language lang in Language)
         {
             _setting.Languages.Remove(lang);
         }
     }
     DataSerializer.Serialize <EnumRunSetting>(_setting, SettingPath);
 }
예제 #4
0
        protected override void ProcessRecord()
        {
            //  ClearもしくはEnumRunSettingがnullの場合、デフォルト設定で再作成
            if (_setting == null || Clear)
            {
                _setting = new EnumRunSetting();
                _setting.SetDefaultParameter();
            }

            if (Language == null && !string.IsNullOrEmpty(Name))
            {
                Language[] langs = _setting.GetLanguage(Name);
                if (langs != null && langs.Length > 0)
                {
                    foreach (Language lang in langs)
                    {
                        if (Extensions != null)
                        {
                            lang.Extensions = Extensions;
                        }
                        if (Command != null)
                        {
                            lang.Command = Command;
                        }
                        if (Command_x86 != null)
                        {
                            lang.Command_x86 = Command_x86;
                        }
                        if (ArgsPrefix != null)
                        {
                            lang.ArgsPrefix = ArgsPrefix;
                        }
                        if (ArgsMidWithoutArgs != null)
                        {
                            lang.ArgsMidWithoutArgs = ArgsMidWithoutArgs;
                        }
                        if (ArgsMidWithArgs != null)
                        {
                            lang.ArgsMidWithArgs = ArgsMidWithArgs;
                        }
                        if (ArgsSuffix != null)
                        {
                            lang.ArgsSuffix = ArgsSuffix;
                        }
                    }
                }
                else
                {
                    //  存在しない場合は何もしない
                    return;
                }
            }
            else if (Language != null)
            {
                //  パイプラインで渡されたLanguageと名前が一致している場合に上書き
                foreach (Language lang in Language)
                {
                    int index = _setting.Languages.FindIndex(x => x.Name.Equals(lang.Name, StringComparison.OrdinalIgnoreCase));
                    if (index >= 0)
                    {
                        _setting.Languages[index] = lang;
                    }
                    else
                    {
                        //  存在しない場合は何もしない
                        return;
                    }
                }
            }
            DataSerializer.Serialize <EnumRunSetting>(_setting, SettingPath);

            WriteObject(_setting.Languages, true);
        }