Include() public method

Includes a specific script using current configuration.
public Include ( string relativeSourcePath, bool once ) : object
relativeSourcePath string Source root relative path to the script.
once bool Specifies whether script should be included only once.
return object
コード例 #1
0
        protected void Setup(ScriptContext c)
        {
            // Set a variable to the My Documents path.
            var section = (ClientSettingsSection)ConfigurationManager
                .GetSection("applicationSettings/wordpress.net.Properties.Settings");
            var settings = section.Settings;

            foreach (SettingElement setting in settings)
            {
                var value = setting.Value.ValueXml.InnerText;
                if (!string.IsNullOrWhiteSpace(value))
                {
                    c.DefineConstant(setting.Name, setting.Value.ValueXml.InnerText);
                }
                else
                {
                    switch (setting.Name)
                    {
                        case "ABSPATH":
                            var path = System.IO.Directory.GetParent(Server.MapPath("~")).Parent.FullName +
                                       "\\components\\WordPress\\";
                            c.DefineConstant("ABSPATH", path.Replace("\\", "/"));
                            break;
                    }
                }
            }

            /** Sets up WordPress vars and included files. */
            c.Include("..\\components\\WordPress\\wp-settings.php", true);
        }
コード例 #2
0
ファイル: PHPPlugin.cs プロジェクト: Notulp/Pluton
        public override void Load(string code = "")
        {
            try
            {
                context = ScriptContext.CurrentContext;
                context.Include(rpath  + "\\" + Name + ".php", true);
                Class = (PhpObject) context.NewObject(Name);
                PHPGlobals = context.GlobalVariables;
                context.GlobalVariables.Add("Commands", chatCommands);
                context.GlobalVariables.Add("DataStore", DataStore.GetInstance());
                context.GlobalVariables.Add("Find", Find.GetInstance());
                context.GlobalVariables.Add("GlobalData", GlobalData);
                context.GlobalVariables.Add("Plugin", this);
                context.GlobalVariables.Add("Server", Pluton.Server.GetInstance());
                context.GlobalVariables.Add("ServerConsoleCommands", consoleCommands);
                context.GlobalVariables.Add("Util", Util.GetInstance());
                context.GlobalVariables.Add("Web", Web.GetInstance());
                context.GlobalVariables.Add("World", World.GetInstance());
                foreach (var x in PHPGlobals)
                {
                    Globals.Add(x.Key.ToString());
                }

                State = PluginState.Loaded;
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
                State = PluginState.FailedToLoad;
            }

            PluginLoader.GetInstance().OnPluginLoaded(this);
        }