コード例 #1
0
        public void WriteExternal(IPofWriter writer)
        {
            writer.WriteInt32(0, INTEGER);

            IPofWriter nested1 = writer.CreateNestedPofWriter(1);

            IPofWriter nested2 = nested1.CreateNestedPofWriter(0);

            nested2.WriteString(0, STRING);
            nested2.WriteSingleArray(2, FLOAT_ARRAY);

            IPofWriter nested3 = nested2.CreateNestedPofWriter(3);

            nested3.WriteArray(0, STRING_ARRAY, typeof(String));

            nested2.WriteBoolean(4, false);
            nested2.WriteRemainder(null);

            IList list = (IList)set;

            nested1.WriteCollection(1, list);
            nested1.WriteDouble(2, 2.0);
            nested1.WriteInt32(3, 5);
            nested1.WriteCollection(4, set);
            nested1.WriteDouble(10, 2.222);

            writer.WriteDouble(2, 4.444);
            writer.WriteInt32(3, 15);
        }
コード例 #2
0
        public void WriteExternal(IPofWriter writer)
        {
            writer.WriteInt32(0, INTEGER);

            IPofWriter nested1 = writer.CreateNestedPofWriter(1);

            IPofWriter nested2 = nested1.CreateNestedPofWriter(0);

            nested2.WriteString(0, STRING);
            nested2.WriteObject(1, PERSON);
            nested2.WriteDoubleArray(2, DOUBLE_ARRAY);

            IPofWriter nested3 = nested2.CreateNestedPofWriter(3);

            nested3.WriteArray(0, STRING_ARRAY, typeof(String));

            nested2.WriteBoolean(4, false);
            nested2.WriteRemainder(null);

            nested1.WriteCollection(1, (ICollection <String>)set);
            nested1.WriteDouble(2, 2.0);
            nested1.WriteInt32(3, 5);
            nested1.WriteCollection(4, set, typeof(String));
            nested1.WriteObject(5, PERSON);
            nested1.WriteDouble(10, 2.222);

            writer.WriteDouble(2, 4.444);
            writer.WriteInt32(3, 15);
            writer.WriteObject(4, PERSON);
        }
コード例 #3
0
 /// <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(OID, m_oid);
     writer.WriteString(ORIGAIRPORT, m_origAirport);
     writer.WriteString(DESTAIRPORT, m_destAirport);
     writer.WriteDouble(DEALAPPEAL, m_dealAppeal);
 }
コード例 #4
0
            public void Serialize(IPofWriter pofWriter, object o)
            {
                var bal = (Balance)o;

                pofWriter.WriteDouble(0, bal.getBalance());
                pofWriter.WriteObject(1, bal.getCustomer());
                pofWriter.WriteRemainder(null);
            }
コード例 #5
0
        /// <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);
        }