本文整理匯總了C#中PHP.Core.ScriptContext.ReleaseArray方法的典型用法代碼示例。如果您正苦於以下問題:C# ScriptContext.ReleaseArray方法的具體用法?C# ScriptContext.ReleaseArray怎麽用?C# ScriptContext.ReleaseArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PHP.Core.ScriptContext
的用法示例。
在下文中一共展示了ScriptContext.ReleaseArray方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Persist
/// <summary>
/// Stores session variables to ASP.NET session.
/// </summary>
internal protected override void Persist(PhpArray variables, ScriptContext context, HttpContext httpContext)
{
HttpSessionState state = httpContext.Session;
if (state.Mode == SessionStateMode.InProc)
{
context.ReleaseArray(variables);
// removes all items (some could be changed or removed in PHP):
// TODO: some session variables could be added in ASP.NET application
state.Clear();
// populates session collection from variables:
foreach (KeyValuePair<IntStringKey, object> entry in variables)
{
// skips resources:
if (!(entry.Value is PhpResource))
state.Add(entry.Key.ToString(), entry.Value);
}
}
else
{
// if the session is maintained out-of-process, serialize the entire $_SESSION autoglobal
MemoryStream stream = new MemoryStream();
BinaryFormatter formatter = new BinaryFormatter(null,
new StreamingContext(StreamingContextStates.Persistence));
formatter.Serialize(stream, variables);
// add the serialized $_SESSION to ASP.NET session:
state[PhpNetSessionVars] = stream.ToArray();
}
}