/// <summary> /// Restore the contents of a user type instance by reading its state /// using the specified <see cref="IPofReader"/> object. /// </summary> /// <param name="reader"> /// The <b>IPofReader</b> from which to read the object's state. /// </param> /// <exception cref="IOException"> /// If an I/O error occurs. /// </exception> /// <seealso cref="Request.ReadExternal"/> public override void ReadExternal(IPofReader reader) { base.ReadExternal(reader); Processor = (IEntryProcessor)reader.ReadObject(2); Cookie = reader.ReadBinary(3); }
/// <summary> /// Restore the contents of a user type instance by reading its state /// using the specified <see cref="IPofReader"/> object. /// </summary> /// <param name="reader"> /// The <b>IPofReader</b> from which to read the object's state. /// </param> /// <exception cref="IOException"> /// If an I/O error occurs. /// </exception> /// <seealso cref="Request.ReadExternal"/> public override void ReadExternal(IPofReader reader) { base.ReadExternal(reader); KeysOnly = reader.ReadBoolean(2); Cookie = reader.ReadBinary(3); FilterCookie = reader.ReadObject(4); }
/// <summary> /// Restore the contents of a user type instance by reading its state /// using the specified <see cref="IPofReader"/> object. /// </summary> /// <param name="reader"> /// The <b>IPofReader</b> from which to read the object's state. /// </param> /// <exception cref="IOException"> /// If an I/O error occurs. /// </exception> public void ReadExternal(IPofReader reader) { m_version = reader.ReadInt64(VERSION); m_lockId = reader.ReadInt64(LOCK_ID); m_lockTime = reader.ReadDateTime(LOCK_TIME); m_initialized = reader.ReadBoolean(INITIALIZED); m_timeout = TimeSpan.FromMilliseconds(reader.ReadInt64(TIMEOUT)); m_binModel = reader.ReadBinary(ITEMS); }
/// <summary> /// Deserialize a user type instance from a POF stream by reading its /// state using the specified <see cref="IPofReader"/> object. /// </summary> /// <remarks> /// An implementation of <b>IPofSerializer</b> is required to follow /// the following steps in sequence for reading in an object of a /// user type: /// <list type="number"> /// <item> /// <description> /// If the object is evolvable, the implementation must get the /// version by calling <see cref="IPofWriter.VersionId"/>. /// </description> /// </item> /// <item> /// <description> /// The implementation may read any combination of the /// properties of the user type by using "read" methods of the /// <b>IPofReader</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 read, /// the implementation must terminate the reading of the user type by /// calling <see cref="IPofReader.ReadRemainder"/>. /// </description> /// </item> /// </list> /// </remarks> /// <param name="reader"> /// The <b>IPofReader</b> with which to read the object's state. /// </param> /// <returns> /// The deserialized user type instance. /// </returns> /// <exception cref="IOException"> /// If an I/O error occurs. /// </exception> public Object Deserialize(IPofReader reader) { Object o = FromBinary(reader.ReadBinary(0), m_serializer); reader.RegisterIdentity(o); reader.ReadRemainder(); Register(o); return(o); }
/// <summary> /// Restore the contents of a user type instance by reading its state /// using the specified <see cref="IPofReader"/> object. /// </summary> /// <param name="reader"> /// The <b>IPofReader</b> from which to read the object's state. /// </param> /// <exception cref="IOException"> /// If an I/O error occurs. /// </exception> public virtual void ReadExternal(IPofReader reader) { if (m_value != null || m_isAttribute || !m_isMutable) { throw new Exception("deserialization not active"); } switch (reader.ReadByte(0)) { case 0: break; case (byte)XmlValueType.Boolean: m_value = reader.ReadBoolean(1); break; case (byte)XmlValueType.Integer: m_value = reader.ReadInt32(1); break; case (byte)XmlValueType.Long: m_value = reader.ReadInt64(1); break; case (byte)XmlValueType.Double: m_value = reader.ReadDouble(1); break; case (byte)XmlValueType.Decimal: m_value = reader.ReadDecimal(1); break; case (byte)XmlValueType.String: m_value = reader.ReadString(1); break; case (byte)XmlValueType.Binary: m_value = reader.ReadBinary(1); break; case (byte)XmlValueType.DateTime: m_value = reader.ReadDateTime(1); break; default: throw new IOException(); } m_isAttribute = reader.ReadBoolean(2); m_isMutable = reader.ReadBoolean(3); }
/// <summary> /// Deserialize a user type instance from a POF stream by reading its /// state using the specified <see cref="IPofReader"/> object. /// </summary> /// <remarks> /// An implementation of <b>IPofSerializer</b> is required to follow /// the following steps in sequence for reading in an object of a /// user type: /// <list type="number"> /// <item> /// <description> /// If the object is evolvable, the implementation must get the /// version by calling <see cref="IPofWriter.VersionId"/>. /// </description> /// </item> /// <item> /// <description> /// The implementation may read any combination of the /// properties of the user type by using "read" methods of the /// <b>IPofReader</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 read, /// the implementation must terminate the reading of the user type by /// calling <see cref="IPofReader.ReadRemainder"/>. /// </description> /// </item> /// </list> /// </remarks> /// <param name="reader"> /// The <b>IPofReader</b> with which to read the object's state. /// </param> /// <returns> /// The deserialized user type instance. /// </returns> /// <exception cref="IOException"> /// If an I/O error occurs. /// </exception> public Object Deserialize(IPofReader reader) { String typeName = reader.ReadString(0); Binary bin = reader.ReadBinary(1); reader.ReadRemainder(); ConfigurablePofContext ctx = m_pofContext; IPortableObject po; try { po = (IPortableObject)ObjectUtils.CreateInstance(TypeResolver.Resolve(typeName)); } catch (Exception e) { throw new Exception("Unable to instantiate PortableObject class: " + typeName, e); } DataReader dataReader = bin.GetReader(); int nType = dataReader.ReadPackedInt32(); if (nType != TYPE_PORTABLE) { throw new IOException("Invalid POF type: " + nType + " (" + TYPE_PORTABLE + " expected)"); } int iVersion = dataReader.ReadPackedInt32(); IPofReader pofReader = new PofStreamReader.UserTypeReader( dataReader, ctx, TYPE_PORTABLE, iVersion); m_serializer.Initialize(po, pofReader); Register(typeName); return(po); }
/// <summary> /// Restore the contents of a user type instance by reading its state /// using the specified <see cref="IPofReader"/> object. /// </summary> /// <param name="reader"> /// The <b>IPofReader</b> from which to read the object's state. /// </param> /// <exception cref="IOException"> /// If an I/O error occurs. /// </exception> public override void ReadExternal(IPofReader reader) { base.ReadExternal(reader); Cookie = reader.ReadBinary(6); }