Esempio n. 1
0
        /// <summary>
        /// Loads variables from ASP.NET session to an array.
        /// </summary>
        internal protected override PhpArray Load(ScriptContext context, HttpContext httpContext)
        {
            HttpSessionState state = httpContext.Session;

            PhpArray result = null;

            if (state.Mode == SessionStateMode.InProc)
            {
                result = new PhpArray();

                foreach (string name in state)
                {
                    result[name] = state[name];
                }

                context.AcquireArray(result);
            }
            else
            {
                byte[] data = state[PhpNetSessionVars] as byte[];

                if (data != null)
                {
                    MemoryStream    stream    = new MemoryStream(data);
                    BinaryFormatter formatter = new BinaryFormatter(null,
                                                                    new StreamingContext(StreamingContextStates.Persistence));

                    result = formatter.Deserialize(stream) as PhpArray;
                }
            }

            return((result != null) ? result : new PhpArray());
        }
Esempio n. 2
0
		/// <summary>
		/// Loads variables from ASP.NET session to an array.
		/// </summary>
		internal protected override PhpArray Load(ScriptContext context, HttpContext httpContext)
		{
			HttpSessionState state = httpContext.Session;
            
			PhpArray result = null;

            if (state.Mode == SessionStateMode.InProc)
			{
				result = new PhpArray();

				foreach (string name in state)
				{
					result[name] = state[name];
				}

				context.AcquireArray(result);
			}
			else
			{
                byte[] data = state[PhpNetSessionVars] as byte[];

				if (data != null)
				{
					MemoryStream stream = new MemoryStream(data);
					BinaryFormatter formatter = new BinaryFormatter(null,
						new StreamingContext(StreamingContextStates.Persistence));

					result = formatter.Deserialize(stream) as PhpArray;
				}
			}

			return (result != null) ? result : new PhpArray();
		}