/// <exception cref="System.IO.IOException"></exception> private void WriteObject(ObjectOutputStream @out) { @out.WriteObject(cookie.GetName()); @out.WriteObject(cookie.GetValue()); @out.WriteObject(cookie.GetComment()); @out.WriteObject(cookie.GetDomain()); @out.WriteObject(cookie.GetExpiryDate()); @out.WriteObject(cookie.GetPath()); @out.WriteInt(cookie.GetVersion()); @out.WriteBoolean(cookie.IsSecure()); }
/// <exception cref="System.IO.IOException"></exception> private void WriteObject(ObjectOutputStream os) { os.DefaultWriteObject(); int N = size; for (int i = 0; i != N; ++i) { object obj = GetImpl(i); os.WriteObject(obj); } }
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()); }
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> private void WriteObject(ObjectOutputStream @out) { @out.DefaultWriteObject(); int count = keyCount; for (int i = 0; count != 0; ++i) { object key = keys[i]; if (key != null && key != DELETED) { --count; @out.WriteObject(key); @out.WriteInt(values[i]); } } }
/// <exception cref="System.IO.IOException"></exception> private void WriteObject(ObjectOutputStream @out) { @out.DefaultWriteObject(); int count = keyCount; if (count != 0) { bool hasIntValues = (ivaluesShift != 0); bool hasObjectValues = (values != null); @out.WriteBoolean(hasIntValues); @out.WriteBoolean(hasObjectValues); for (int i = 0; count != 0; ++i) { int key = keys[i]; if (key != EMPTY && key != DELETED) { --count; @out.WriteInt(key); if (hasIntValues) { @out.WriteInt(keys[ivaluesShift + i]); } if (hasObjectValues) { @out.WriteObject(values[i]); } } } } }