Exemple #1
0
    public void Init(PluginInitContext context)
    {
        s_StartupThreadId = System.Threading.Thread.CurrentThread.ManagedThreadId;
        s_Context         = context;
        var txtWriter = new StringWriter(s_LogBuilder);

        Console.SetOut(txtWriter);
        Console.SetError(txtWriter);
        using (var sw = new StreamWriter(s_LogFile, false)) {
            sw.WriteLine("Startup Thread {0}.", s_StartupThreadId);
            sw.Close();
        }
        BatchScript.Init();
        BatchScript.Register("context", new ExpressionFactoryHelper <ContextExp>());
        BatchScript.Register("api", new ExpressionFactoryHelper <ApiExp>());
        BatchScript.Register("metadata", new ExpressionFactoryHelper <MetadataExp>());
        BatchScript.Register("reloaddsl", new ExpressionFactoryHelper <ReloadDslExp>());
        BatchScript.Register("evaldsl", new ExpressionFactoryHelper <EvalDslExp>());
        BatchScript.Register("addresult", new ExpressionFactoryHelper <AddResultExp>());
        BatchScript.Register("addcontextmenu", new ExpressionFactoryHelper <AddContextMenuExp>());
        BatchScript.Register("keywordregistered", new ExpressionFactoryHelper <ActionKeywordRegisteredExp>());
        BatchScript.Register("clearkeywords", new ExpressionFactoryHelper <ClearActionKeywordsExp>());
        BatchScript.Register("addkeyword", new ExpressionFactoryHelper <AddActionKeywordExp>());
        BatchScript.Register("showcontextmenu", new ExpressionFactoryHelper <ShowContextMenuExp>());
        BatchScript.Register("everythingreset", new ExpressionFactoryHelper <EverythingResetExp>());
        BatchScript.Register("everythingsetdefault", new ExpressionFactoryHelper <EverythingSetDefaultExp>());
        BatchScript.Register("everythingmatchpath", new ExpressionFactoryHelper <EverythingMatchPathExp>());
        BatchScript.Register("everythingmatchcase", new ExpressionFactoryHelper <EverythingMatchCaseExp>());
        BatchScript.Register("everythingmatchwholeword", new ExpressionFactoryHelper <EverythingMatchWholeWordExp>());
        BatchScript.Register("everythingregex", new ExpressionFactoryHelper <EverythingRegexExp>());
        BatchScript.Register("everythingsort", new ExpressionFactoryHelper <EverythingSortExp>());
        BatchScript.Register("everythingsearch", new ExpressionFactoryHelper <EverythingSearchExp>());
        ReloadDsl();
    }
Exemple #2
0
        static void Main(string[] args)
        {
            int exitCode = 0;

            try {
                BatchScript.Init();
                var r     = DslExpression.CalculatorValue.NullObject;
                var vargs = BatchScript.NewCalculatorValueList();
                if (args.Length <= 0)
                {
                    r = BatchScript.Run(string.Empty, vargs);
                }
                else
                {
                    foreach (var arg in args)
                    {
                        vargs.Add(arg);
                    }
                    r = BatchScript.Run(args[0], vargs);
                }
                BatchScript.RecycleCalculatorValueList(vargs);
                if (!r.IsNullObject)
                {
                    exitCode = r.Get <int>();
                }
            } catch (Exception ex) {
                BatchScript.Log("exception:{0}\n{1}", ex.Message, ex.StackTrace);
                exitCode = -1;
            }
            Environment.Exit(exitCode);
        }