本文整理匯總了C#中PHP.Core.ScriptContext類的典型用法代碼示例。如果您正苦於以下問題:C# ScriptContext類的具體用法?C# ScriptContext怎麽用?C# ScriptContext使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ScriptContext類屬於PHP.Core命名空間,在下文中一共展示了ScriptContext類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: InitWebRequest
/// <summary>
/// Initializes the script context for a web request.
/// </summary>
/// <param name="appContext">Application context.</param>
/// <param name="context">HTTP context of the request.</param>
/// <returns>A instance of <see cref="ScriptContext"/> to be used by the request.</returns>
/// <exception cref="System.Configuration.ConfigurationErrorsException">
/// Web configuration is invalid. The context is not initialized then.
/// </exception>
internal static ScriptContext/*!*/ InitWebRequest(ApplicationContext/*!*/ appContext, HttpContext/*!*/ context)
{
Debug.Assert(appContext != null && context != null);
// reloads configuration of the current thread from ASP.NET caches or web.config files;
// cached configuration is reused;
Configuration.Reload(appContext, false);
// takes a writable copy of a global configuration (may throw ConfigurationErrorsException):
LocalConfiguration config = (LocalConfiguration)Configuration.DefaultLocal.DeepCopy();
// following initialization statements shouldn't throw an exception: // can throw on Integrated Pipeline, events must be attached within HttpApplication.Init()
ScriptContext result = new ScriptContext(appContext, config, context.Response.Output, context.Response.OutputStream);
result.IsOutputBuffered = config.OutputControl.OutputBuffering;
result.ThrowExceptionOnError = true;
result.WorkingDirectory = Path.GetDirectoryName(context.Request.PhysicalPath);
if (config.OutputControl.ContentType != null) context.Response.ContentType = config.OutputControl.ContentType;
if (config.OutputControl.CharSet != null) context.Response.Charset = config.OutputControl.CharSet;
result.AutoGlobals.Initialize(config, context);
ScriptContext.CurrentContext = result;
Externals.BeginRequest();
return result;
}
示例2: GetOrCreateFilterCallback
private PhpCallback/*!*/ GetOrCreateFilterCallback(ScriptContext/*!*/ context)
{
if (filterCallback == null)
filterCallback = new PhpCallback(new RoutineDelegate(Filter), context);
return filterCallback;
}
示例3: Load
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);
}
示例4: fetch
public object fetch(ScriptContext context, object fetch_style/*=null*/, object cursor_orientation/*FETCH_ORI_NEXT*/, object cursor_offset/*0*/)
{
PDOFetchType ft;
if (fetch_style == null || fetch_style == Arg.Default)
fetch_style = this.m_pdo.getAttribute(context, (int)PDOAttributeType.PDO_ATTR_DEFAULT_FETCH_MODE);
int fetch_style_int = PHP.Core.Convert.ObjectToInteger(fetch_style);
if (!Enum.IsDefined(typeof(PDOFetchType), fetch_style_int))
{
PDOException.Throw(context, "Invalid fetch_style value", null, null, null);
return null;
}
ft = (PDOFetchType)fetch_style_int;
var dr = this.CurrentReader;
switch (ft)
{
case PDOFetchType.PDO_FETCH_ASSOC:
return Fetch_Assoc(m_pdo.Driver, dr, false) ?? (object)false;
case PDOFetchType.PDO_FETCH_NUM:
return Fetch_Num(m_pdo.Driver, dr) ?? (object)false;
case PDOFetchType.PDO_FETCH_BOTH:
case PDOFetchType.PDO_FETCH_USE_DEFAULT:
return Fetch_Assoc(m_pdo.Driver, dr, true) ?? (object)false;
default:
throw new NotImplementedException();
}
}
示例5: Setup
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);
}
示例6: Quote
public override object Quote(ScriptContext context, object strobj, PDOParamType param_type)
{
// From mysql extension
// in addition, resulting string is quoted as '...'
if (strobj == null)
return string.Empty;
// binary aware:
if (strobj.GetType() == typeof(PhpBytes))
{
var strbytes = (PhpBytes)strobj;
if (strbytes.Length == 0) return strobj;
var bytes = strbytes.ReadonlyData;
List<byte>/*!*/result = new List<byte>(bytes.Length + 2);
result.Add((byte)'\'');
for (int i = 0; i < bytes.Length; i++)
{
switch (bytes[i])
{
case (byte)'\0': result.Add((byte)'\\'); goto default;
case (byte)'\\': result.Add((byte)'\\'); goto default;
case (byte)'\n': result.Add((byte)'\\'); result.Add((byte)'n'); break;
case (byte)'\r': result.Add((byte)'\\'); result.Add((byte)'r'); break;
case (byte)'\u001a': result.Add((byte)'\\'); result.Add((byte)'Z'); break;
case (byte)'\'': result.Add((byte)'\\'); goto default;
case (byte)'"': result.Add((byte)'\\'); goto default;
default: result.Add(bytes[i]); break;
}
}
result.Add((byte)'\'');
return new PhpBytes(result.ToArray());
}
// else
string str = Core.Convert.ObjectToString(strobj);
StringBuilder sb = new StringBuilder();
sb.Append('\'');
for (int i = 0; i < str.Length; i++)
{
char c = str[i];
switch (c)
{
case '\0': sb.Append(@"\0"); break;
case '\\': sb.Append(@"\\"); break;
case '\n': sb.Append(@"\n"); break;
case '\r': sb.Append(@"\r"); break;
case '\u001a': sb.Append(@"\Z"); break;
case '\'': sb.Append(@"''"); break;
case '"': sb.Append("\"\""); break;
default: sb.Append(c); break;
}
}
sb.Append('\'');
return sb.ToString();
}
示例7: __construct
public object __construct(ScriptContext __context, object name, [System.Runtime.InteropServices.OptionalAttribute()]
object value)
{
string tmp1 = PhpVariable.AsString(name);
if (tmp1 == null)
{
PhpException.InvalidImplicitCast(name, "string", "__construct");
return null;
}
string tmp2 = null;
if (value != Arg.Default)
{
tmp2 = PhpVariable.AsString(value);
if (tmp2 == null)
{
PhpException.InvalidImplicitCast(value, "string", "__construct");
return null;
}
}
__construct(tmp1, tmp2);
return null;
}
示例8: GetLocal
/// <summary>
/// Gets local configuration associated with a specified script context.
/// </summary>
/// <param name="context">Scritp context.</param>
/// <returns>Local library configuration.</returns>
public static MySqlLocalConfig GetLocal(ScriptContext/*!*/ context)
{
if (context == null)
throw new ArgumentNullException("context");
return (MySqlLocalConfig)context.Config.GetLibraryConfig(MySqlLibraryDescriptor.Singleton);
}
示例9: PhpMyDbConnection
/// <summary>
/// Creates a connection resource.
/// </summary>
/// <param name="connectionString">Connection string.</param>
/// <param name="context">Script context associated with the connection.</param>
public PhpMyDbConnection(string/*!*/ connectionString, ScriptContext/*!*/ context)
: base(connectionString, new MySqlConnection(), "mysql connection")
{
if (context == null)
throw new ArgumentNullException("context");
_context = context;
_sharedConnection = false;
}
示例10: TypesProvider
/// <param name="context">A script context to get declarators from.</param>
/// <param name="caller">A current type context.</param>
public TypesProvider(ScriptContext/*!*/ context, DTypeDesc/*!*/ caller)
{
Debug.Assert(context != null && caller != null);
this.context = context;
this.caller = caller;
Debug.WriteLine("PROVIDER", "created");
}
示例11: GetLastInsertId
public override object GetLastInsertId(ScriptContext context, PDO pdo, string name)
{
var cmd = pdo.PDOConnection.LastCommand;
if (cmd is MySqlCommand)
return ((MySqlCommand)cmd).LastInsertedId;
else
return false;
}
示例12: __construct
public object __construct(ScriptContext/*!*/context,
object faultcode, object faultstring, [Optional]object faultactor,
[Optional]object detail, [Optional]object faultname,
[Optional]object headerfault)
{
base.__construct(context, faultstring, faultcode);
return null;
}
示例13: PhpSqlDbConnection
/// <summary>
/// Creates a new connection resource.
/// </summary>
/// <param name="connectionString">Connection string.</param>
/// <param name="context">Script context associated with the connection.</param>
public PhpSqlDbConnection(string/*!*/ connectionString, ScriptContext/*!*/ context)
: base(connectionString, new SqlConnection(), "mssql connection")
{
if (context == null)
throw new ArgumentNullException("context");
this.context = context;
// TODO: Connection.InfoMessage += new SqlInfoMessageEventHandler(InfoMessage);
}
示例14: PhpStack
/// <summary>
/// Creates a new instance of <see cref="PhpStack"/>.
/// </summary>
/// <param name="context">The script context.</param>
internal PhpStack(ScriptContext/*!*/ context)
{
Debug.Assert(context != null);
this.Items = new object[25];
this.Types = new DTypeDesc[10];
this.Top = 0;
this.TypesTop = 0;
this.Context = context;
}
示例15: item
public object item(ScriptContext __context, object index)
{
if (!(index is int))
{
PhpException.InvalidImplicitCast(index, "int", "item");
return null;
}
return item((int)index);
}