Exemple #1
0
        private void SetPattern(SoundConfig parent)
        {
            switch (this.Type)
            {
            case PatternType.String:
                StringPattern = StrPattern;
                break;

            case PatternType.Regex:
                RegexPattern = new Regex(StrPattern);
                break;

            case PatternType.Function:
                var file = Config.LoadFile(this.FunctionFile, parent.ConfigFileDir);
                if (file.Length > 0)
                {
                    this.StrPattern = file;
                }
                if (FunctionName.Length == 0 || StrPattern.Length == 0)
                {
                    // TRANSLATORS: Log message. SoundEffectCommand plugin.
                    Logger.Log(T._("Could not set function."));
                    break;
                }
                JSWrapper.Instance.SetFunction(FunctionName, StrPattern);
                FunctionPattern = (JSArgument arg) => {
                    try {
                        var r = JSWrapper.Instance.ExecuteFunction(FunctionName, arg);
                        return(r as ReplaceResult);
                    } catch (System.Exception e) {
                        // TRANSLATORS: Log message. SoundEffectCommand plugin.
                        Logger.Log(T._("Could not get JS result."));
                        Logger.DebugLog(e.ToString());
                        return(null);
                    }
                };
                break;

            default:
                break;
            }
        }
Exemple #2
0
 public void Initialize(SoundConfig parent)
 {
     SetType();
     SetPattern(parent);
 }