示例#1
0
 public PowerShellScript(string path) : base(path)
 {
     Runtime = new PowerShellRuntime(Name);
     Runtime.ExecuteFile(path);
     SupportedEvents = GetSupportedEvents();
     SupportedMenus  = GetSupportedMenus();
 }
        public PowerShellScript(string path) : base(path, ScriptLanguage.PowerShell)
        {
            Runtime = new PowerShellRuntime();
            Runtime.ExecuteFile(path);
            var attributes = Runtime.GetVariable("__attributes");

            if (attributes != null)
            {
                Attributes = ((Hashtable)attributes).Cast <DictionaryEntry>().ToDictionary(kvp => (string)kvp.Key, kvp => (string)kvp.Value);
            }

            var exports = Runtime.GetVariable("__exports");

            if (exports != null)
            {
                FunctionExports = new List <ScriptFunctionExport>();
                var funcs = (IEnumerable <object>)exports;
                foreach (Hashtable func in funcs)
                {
                    FunctionExports.Add(new ScriptFunctionExport(func["Name"].ToString(), func["Function"].ToString(), this));
                }
            }
        }
示例#3
0
 public PowerShellScript(string path) : base(path)
 {
     Runtime = new PowerShellRuntime();
     Runtime.ExecuteFile(path);
 }