/// <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); RequestId = reader.ReadInt64(0); IsFailure = reader.ReadBoolean(1); // determine which result format is being used ResultFormatType format = (ResultFormatType)reader.ReadInt32(2); ResultFormat = format; switch (format) { default: case ResultFormatType.Generic: Result = reader.ReadObject(3); break; case ResultFormatType.Collection: ICollection collection = reader.ReadCollection(4, null); Result = collection; break; case ResultFormatType.Map: IDictionary map = reader.ReadDictionary(5, new HashDictionary()); Result = map; break; } }
/// <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.WriteInt64(0, RequestId); writer.WriteBoolean(1, IsFailure); ResultFormatType format = ResultFormat; writer.WriteInt32(2, (int)format); switch (format) { default: case ResultFormatType.Generic: writer.WriteObject(3, Result); break; case ResultFormatType.Collection: writer.WriteCollection(4, (ICollection)Result); break; case ResultFormatType.Map: writer.WriteDictionary(5, (IDictionary)Result); break; } }
/// <summary> /// Set the result of processing the <b>Request</b> as a /// <b>IDictionary</b>. /// </summary> /// <param name="result"> /// Dictionary representing the result. /// </param> public virtual void SetResultAsEntrySet(IDictionary result) { Result = (result == null ? null : new HashDictionary(result)); ResultFormat = ResultFormatType.Map; }
/// <summary> /// Set the result of processing the <b>Request</b> as a /// <b>ICollection</b>. /// </summary> /// <param name="result"> /// Collection representing the result. /// </param> public virtual void SetResultAsCollection(ICollection result) { Result = result; ResultFormat = ResultFormatType.Collection; }