System.Web.UI.LosFormatter.Deserialize C# (CSharp) Method

Deserialize() public method

public Deserialize ( Stream stream ) : object
stream Stream
return object
		public object Deserialize (Stream stream)
		{
			if (stream == null)
				throw new ArgumentNullException ("stream");
#if NET_4_0
			using (StreamReader sr = new StreamReader (stream)) {
				return Deserialize (sr.ReadToEnd ());
			}
#else
			long streamLength = -1;
			if (stream.CanSeek)
				streamLength = stream.Length;
			
			MemoryStream ms = null;
			if (streamLength  != -1 && (stream is MemoryStream) && stream.Position == 0) {
				// We save allocating a new stream and reading in this case.
				ms = (MemoryStream) stream;
			} else {
				byte [] bytes = new byte [streamLength >= 0 ? streamLength : 2048];	
				ms = new MemoryStream ();
				int n;
				while ((n = stream.Read (bytes, 0, bytes.Length)) > 0)
					ms.Write (bytes, 0, n);
				streamLength = ms.Length;
			}

			string b64 = Encoding.ASCII.GetString (ms.GetBuffer (),
				0, (int) streamLength);
			return Deserialize (b64);
#endif
		}

Same methods

LosFormatter::Deserialize ( TextReader input ) : object
LosFormatter::Deserialize ( string input ) : object

Usage Example

 protected object LoadPageStateFromCompressedViewState()
 {
     string viewState = Request.Form["__VSTATE"];
     byte[] bytes = Convert.FromBase64String(viewState);
     bytes = IntegrationWebSiteMvc.Classes.Compressor.Decompress(bytes);
     LosFormatter formatter = new LosFormatter();
     return formatter.Deserialize(Convert.ToBase64String(bytes));
 }
All Usage Examples Of System.Web.UI.LosFormatter::Deserialize