Esempio n. 1
0
        /// <summary>
        /// Serialiaztion of objects
        /// </summary>
        /// <param name="objData">Object to serialize</param>
        /// <param name="abstractHessianOutput">HessianOutput - Instance</param>
        public override void WriteObject(object objData, AbstractHessianOutput abstractHessianOutput)
        {
            if (abstractHessianOutput.AddRef(objData))
            {
                return;
            }
            if (objData == null)
            {
                abstractHessianOutput.WriteNull();
            }
            else
            {
                int iref = abstractHessianOutput.WriteObjectBegin(PROT_GUID_TYPE);

                if (iref < -1)
                {
                    abstractHessianOutput.WriteString("value");
                    abstractHessianOutput.WriteString(objData.ToString());
                    abstractHessianOutput.WriteMapEnd();
                }
                else
                {
                    if (iref == -1)
                    {
                        abstractHessianOutput.WriteClassFieldLength(1);
                        abstractHessianOutput.WriteString("value");
                        abstractHessianOutput.WriteObjectBegin(PROT_GUID_TYPE);
                    }

                    abstractHessianOutput.WriteString(objData.ToString());
                }
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Writes Instance of the DateTime class
 /// </summary>
 /// <param name="objDate">Instance of the DateTime class</param>
 /// <param name="abstractHessianOutput">HessianOutput - Stream</param>
 public override void  WriteObject(Object objDate, AbstractHessianOutput abstractHessianOutput)
 {
     if (objDate == null)
     {
         abstractHessianOutput.WriteNull();
     }
     else
     {
         /*Type type = objDate.GetType();
          * abstractHessianOutput.WriteMapBegin(type.FullName);
          * abstractHessianOutput.WriteString("value");
          * abstractHessianOutput.WriteUTCDate(((((DateTime) objDate).Ticks - ticksDifference) / ticksDivider) - (long) TimeZone.CurrentTimeZone.GetUtcOffset(((DateTime) objDate)).TotalMilliseconds);
          * abstractHessianOutput.WriteMapEnd();
          */
         abstractHessianOutput.WriteUTCDate(((DateTime)objDate).ToFileTimeUtc());
     }
 }
        /// <summary>
        /// Serialization of stream valued objects
        /// </summary>
        /// <param name="obj">Object to serialize</param>
        /// <param name="abstractHessianOutput">HessianOutput - Instance</param>
        public override void WriteObject(object obj, AbstractHessianOutput abstractHessianOutput)
        {
            Stream inStream = (Stream)obj;

            if (inStream == null)
            {
                abstractHessianOutput.WriteNull();
            }
            else
            {
                byte[] buf = new byte[1024];
                int    len;
                while ((len = inStream.Read(buf, 0, buf.Length)) > 0)
                {
                    abstractHessianOutput.WriteByteBufferPart(buf, 0, len);
                }
                abstractHessianOutput.WriteByteBufferEnd(buf, 0, 0);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Serialiaztion of string valued objects
        /// </summary>
        /// <param name="obj">Object to serialize</param>
        /// <param name="abstractHessianOutput">HessianOutput - Instance</param>
        public override void WriteObject(object obj, AbstractHessianOutput abstractHessianOutput)
        {
            if (obj == null)
            {
                abstractHessianOutput.WriteNull();
            }
            else
            {
                if (abstractHessianOutput.AddRef(obj))
                {
                    return;
                }

                Type type = obj.GetType();

                int iref = abstractHessianOutput.WriteObjectBegin(type.Name);

                if (iref < -1)
                {
                    abstractHessianOutput.WriteString("value");
                    abstractHessianOutput.WriteString(obj.ToString());
                    abstractHessianOutput.WriteMapEnd();
                }
                else
                {
                    if (iref == -1)
                    {
                        abstractHessianOutput.WriteInt(1);
                        abstractHessianOutput.WriteString("value");
                        abstractHessianOutput.WriteObjectBegin(type.Name);
                    }

                    abstractHessianOutput.WriteString(obj.ToString());
                }
            }
        }