ReadObject() public method

public ReadObject ( ) : object
return object
Example #1
0
		/// <exception cref="System.IO.IOException"></exception>
		/// <exception cref="System.TypeLoadException"></exception>
		private void ReadObject(ObjectInputStream @is)
		{
			@is.DefaultReadObject();
			// It reads size
			int N = size;
			if (N > FIELDS_STORE_SIZE)
			{
				data = new object[N - FIELDS_STORE_SIZE];
			}
			for (int i = 0; i != N; ++i)
			{
				object obj = @is.ReadObject();
				SetImpl(i, obj);
			}
		}
Example #2
0
		public virtual void TestConsStringSerialization()
		{
			ConsString r1 = new ConsString("foo", "bar");
			MemoryStream baos = new MemoryStream();
			ObjectOutputStream oos = new ObjectOutputStream(baos);
			oos.WriteObject(r1);
			oos.Flush();
			MemoryStream bais = new MemoryStream(baos.ToArray());
			ObjectInputStream ois = new ObjectInputStream(bais);
			CharSequence r2 = (CharSequence)ois.ReadObject();
			NUnit.Framework.Assert.AreEqual("still the same at the other end", r1.ToString(), r2.ToString());
		}
Example #3
0
		public virtual void TestContinuationsPrototypesAndSerialization()
		{
			byte[] serializedData = null;
			{
				Scriptable globalScope;
				Context cx = Context.Enter();
				try
				{
					globalScope = cx.InitStandardObjects();
					cx.SetOptimizationLevel(-1);
					// must use interpreter mode
					globalScope.Put("myObject", globalScope, Context.JavaToJS(new ContinuationsApiTest.MyClass(), globalScope));
				}
				finally
				{
					Context.Exit();
				}
				cx = Context.Enter();
				try
				{
					cx.SetOptimizationLevel(-1);
					// must use interpreter mode
					cx.EvaluateString(globalScope, "function f(a) { Number.prototype.blargh = function() {return 'foo';}; var k = myObject.f(a); var t = []; return new Number(8).blargh(); }", "function test source", 1, null);
					Function f = (Function)globalScope.Get("f", globalScope);
					object[] args = new object[] { 7 };
					cx.CallFunctionWithContinuations(f, globalScope, args);
					NUnit.Framework.Assert.Fail("Should throw ContinuationPending");
				}
				catch (ContinuationPending pending)
				{
					// serialize
					MemoryStream baos = new MemoryStream();
					ObjectOutputStream sos = new ObjectOutputStream(baos);
					sos.WriteObject(globalScope);
					sos.WriteObject(pending.GetContinuation());
					sos.Close();
					baos.Close();
					serializedData = baos.ToArray();
				}
				finally
				{
					Context.Exit();
				}
			}
			{
				try
				{
					Context cx = Context.Enter();
					Scriptable globalScope;
					// deserialize
					MemoryStream bais = new MemoryStream(serializedData);
					ObjectInputStream sis = new ObjectInputStream(bais);
					globalScope = (Scriptable)sis.ReadObject();
					object continuation = sis.ReadObject();
					sis.Close();
					bais.Close();
					object result = cx.ResumeContinuation(continuation, globalScope, 8);
					NUnit.Framework.Assert.AreEqual("foo", result);
				}
				finally
				{
					Context.Exit();
				}
			}
		}
 /// <exception cref="System.IO.IOException"></exception>
 /// <exception cref="System.TypeLoadException"></exception>
 private void ReadObject(ObjectInputStream @in)
 {
     string name = (string)@in.ReadObject();
     string value = (string)@in.ReadObject();
     clientCookie = new BasicClientCookie(name, value);
     clientCookie.SetComment((string)@in.ReadObject());
     clientCookie.SetDomain((string)@in.ReadObject());
     clientCookie.SetExpiryDate((DateTime)@in.ReadObject());
     clientCookie.SetPath((string)@in.ReadObject());
     clientCookie.SetVersion(@in.ReadInt());
     clientCookie.SetSecure(@in.ReadBoolean());
 }
Example #5
0
		/// <exception cref="System.IO.IOException"></exception>
		/// <exception cref="System.TypeLoadException"></exception>
		private void ReadObject(ObjectInputStream @in)
		{
			@in.DefaultReadObject();
			int writtenKeyCount = keyCount;
			if (writtenKeyCount != 0)
			{
				keyCount = 0;
				int N = 1 << power;
				keys = new object[N];
				values = new int[2 * N];
				for (int i = 0; i != writtenKeyCount; ++i)
				{
					object key = @in.ReadObject();
					int hash = key.GetHashCode();
					int index = InsertNewKey(key, hash);
					values[index] = @in.ReadInt();
				}
			}
		}
Example #6
0
		/// <exception cref="System.IO.IOException"></exception>
		/// <exception cref="System.TypeLoadException"></exception>
		private void ReadObject(ObjectInputStream @in)
		{
			@in.DefaultReadObject();
			int writtenKeyCount = keyCount;
			if (writtenKeyCount != 0)
			{
				keyCount = 0;
				bool hasIntValues = @in.ReadBoolean();
				bool hasObjectValues = @in.ReadBoolean();
				int N = 1 << power;
				if (hasIntValues)
				{
					keys = new int[2 * N];
					ivaluesShift = N;
				}
				else
				{
					keys = new int[N];
				}
				for (int i = 0; i != N; ++i)
				{
					keys[i] = EMPTY;
				}
				if (hasObjectValues)
				{
					values = new object[N];
				}
				for (int i_1 = 0; i_1 != writtenKeyCount; ++i_1)
				{
					int key = @in.ReadInt();
					int index = InsertNewKey(key);
					if (hasIntValues)
					{
						int ivalue = @in.ReadInt();
						keys[ivaluesShift + index] = ivalue;
					}
					if (hasObjectValues)
					{
						values[index] = @in.ReadObject();
					}
				}
			}
		}