/// <summary> /// Save the contents of a POF user type instance by writing its /// state using the specified <see cref="IPofWriter"/> object. /// </summary> /// <param name="writer"> /// The <b>IPofWriter</b> to which to write the object's state. /// </param> /// <exception cref="IOException"> /// If an I/O error occurs. /// </exception> /// <seealso cref="Request.WriteExternal"/> public override void WriteExternal(IPofWriter writer) { base.WriteExternal(writer); writer.WriteObject(2, Processor); writer.WriteBinary(3, Cookie); }
/// <summary> /// Save the contents of a POF user type instance by writing its /// state using the specified <see cref="IPofWriter"/> object. /// </summary> /// <param name="writer"> /// The <b>IPofWriter</b> to which to write the object's state. /// </param> /// <exception cref="IOException"> /// If an I/O error occurs. /// </exception> /// <seealso cref="Request.WriteExternal"/> public override void WriteExternal(IPofWriter writer) { base.WriteExternal(writer); writer.WriteObject(2, KeysOnly); writer.WriteBinary(3, Cookie); writer.WriteObject(4, FilterCookie); }
/// <summary> /// Save the contents of a POF user type instance by writing its /// state using the specified <see cref="IPofWriter"/> object. /// </summary> /// <param name="writer"> /// The <b>IPofWriter</b> to which to write the object's state. /// </param> /// <exception cref="IOException"> /// If an I/O error occurs. /// </exception> public virtual void WriteExternal(IPofWriter writer) { // note: this object is not responsible for writing out its parent object o = m_value; if (o == null) { writer.WriteByte(0, 0); } else if (o is string) { writer.WriteByte(0, (byte)XmlValueType.String); writer.WriteString(1, (string)o); } else if (o is bool) { writer.WriteByte(0, (byte)XmlValueType.Boolean); writer.WriteBoolean(1, (bool)o); } else if (o is int) { writer.WriteByte(0, (byte)XmlValueType.Integer); writer.WriteInt32(1, (int)o); } else if (o is long) { writer.WriteByte(0, (byte)XmlValueType.Long); writer.WriteInt64(1, (long)o); } else if (o is double) { writer.WriteByte(0, (byte)XmlValueType.Double); writer.WriteDouble(1, (Double)o); } else if (o is decimal) { writer.WriteByte(0, (byte )XmlValueType.Decimal); writer.WriteDecimal(1, (decimal)o); } else if (o is Binary) { writer.WriteByte(0, (byte)XmlValueType.Binary); writer.WriteBinary(1, (Binary)o); } else if (o is DateTime) { writer.WriteByte(0, (byte)XmlValueType.DateTime); writer.WriteDateTime(1, (DateTime)o); } else { throw new IOException("unsupported type to write: " + o.GetType().FullName); } writer.WriteBoolean(2, m_isAttribute); writer.WriteBoolean(3, m_isMutable); }
/// <summary> /// Save the contents of a POF user type instance by writing its /// state using the specified <see cref="IPofWriter"/> object. /// </summary> /// <param name="writer"> /// The <b>IPofWriter</b> to which to write the object's state. /// </param> /// <exception cref="IOException"> /// If an I/O error occurs. /// </exception> public void WriteExternal(IPofWriter writer) { writer.WriteInt64(VERSION, m_version); writer.WriteInt64(LOCK_ID, m_lockId); writer.WriteDateTime(LOCK_TIME, m_lockTime); writer.WriteBoolean(INITIALIZED, m_initialized); writer.WriteInt64(TIMEOUT, (long)m_timeout.TotalMilliseconds); writer.WriteBinary(ITEMS, m_binModel); }
/// <summary> /// Serializes this processor into a POF stream. /// </summary> /// <param name="writer"> /// The POF writer. /// </param> public override void WriteExternal(IPofWriter writer) { writer.WriteInt64(0, m_lockId); writer.WriteBoolean(1, m_newSession); writer.WriteBoolean(2, m_initialized); writer.WriteInt64(3, m_timeout); writer.WriteBinary(4, m_binModel); writer.WriteDictionary(5, m_externalAttributes, typeof(String), typeof(Binary)); writer.WriteCollection(6, m_obsoleteExternalAttributes, typeof(String)); }
/// <summary> /// Serialize a user type instance to a POF stream by writing its /// state using the specified <see cref="IPofWriter"/> object. /// </summary> /// <remarks> /// An implementation of <b>IPofSerializer</b> is required to follow /// the following steps in sequence for writing out an object of a /// user type: /// <list type="number"> /// <item> /// <description> /// If the object is evolvable, the implementation must set the /// version by calling <see cref="IPofWriter.VersionId"/>. /// </description> /// </item> /// <item> /// <description> /// The implementation may write any combination of the properties of /// the user type by using the "write" methods of the /// <b>IPofWriter</b>, but it must do so in the order of the property /// indexes. /// </description> /// </item> /// <item> /// <description> /// After all desired properties of the user type have been written, /// the implementation must terminate the writing of the user type by /// calling <see cref="IPofWriter.WriteRemainder"/>. /// </description> /// </item> /// </list> /// </remarks> /// <param name="writer"> /// The <b>IPofWriter</b> with which to write the object's state. /// </param> /// <param name="o"> /// The object to serialize. /// </param> /// <exception cref="IOException"> /// If an I/O error occurs. /// </exception> public void Serialize(IPofWriter writer, Object o) { var buffer = new BinaryMemoryStream(1024 * 8); PofStreamWriter userTypeWriter = new PofStreamWriter.UserTypeWriter( new DataWriter(buffer), m_pofContext, TYPE_PORTABLE, -1); // COH-5065: due to the complexity of maintaining references // in future data, we won't support them for IEvolvable objects if (m_pofContext.IsReferenceEnabled && !(o is IEvolvable)) { userTypeWriter.EnableReference(); } m_serializer.Serialize(userTypeWriter, o); String typeName = o.GetType().AssemblyQualifiedName; writer.WriteString(0, typeName); writer.WriteBinary(1, buffer.ToBinary()); writer.WriteRemainder(null); Register(typeName); }
/// <summary> /// Save the contents of a POF user type instance by writing its /// state using the specified <see cref="IPofWriter"/> object. /// </summary> /// <param name="writer"> /// The <b>IPofWriter</b> to which to write the object's state. /// </param> /// <exception cref="IOException"> /// If an I/O error occurs. /// </exception> public override void WriteExternal(IPofWriter writer) { base.WriteExternal(writer); writer.WriteBinary(6, Cookie); }
/// <summary> /// Serialize a user type instance to a POF stream by writing its /// state using the specified <see cref="IPofWriter"/> object. /// </summary> /// <remarks> /// An implementation of <b>IPofSerializer</b> is required to follow /// the following steps in sequence for writing out an object of a /// user type: /// <list type="number"> /// <item> /// <description> /// If the object is evolvable, the implementation must set the /// version by calling <see cref="IPofWriter.VersionId"/>. /// </description> /// </item> /// <item> /// <description> /// The implementation may write any combination of the properties of /// the user type by using the "write" methods of the /// <b>IPofWriter</b>, but it must do so in the order of the property /// indexes. /// </description> /// </item> /// <item> /// <description> /// After all desired properties of the user type have been written, /// the implementation must terminate the writing of the user type by /// calling <see cref="IPofWriter.WriteRemainder"/>. /// </description> /// </item> /// </list> /// </remarks> /// <param name="writer"> /// The <b>IPofWriter</b> with which to write the object's state. /// </param> /// <param name="o"> /// The object to serialize. /// </param> /// <exception cref="IOException"> /// If an I/O error occurs. /// </exception> public void Serialize(IPofWriter writer, Object o) { writer.WriteBinary(0, ToBinary(o, m_serializer)); writer.WriteRemainder(null); Register(o); }