/// <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); }