///// <summary>
        ///// Serialiaztion of objects
        ///// </summary>
        ///// <param name="obj">Object to serialize</param>
        ///// <param name="abstractHessianOutput">HessianOutput - Instance</param>
        //public override void WriteObject(object obj, AbstractHessianOutput abstractHessianOutput)
        //{
        //    if (abstractHessianOutput.AddRef(obj))
        //        return;
        //    Type type = obj.GetType();
        //    abstractHessianOutput.WriteMapBegin(type.FullName);
        //    List<MemberInfo> serFields = GetSerializableFieldList();
        //    for (int i = 0; i < serFields.Count; i++)
        //    {
        //        MemberInfo field = serFields[i];
        //        //if (!field.CanWrite) continue;
        //        if (field.GetCustomAttributes(typeof(IgnoreAttribute), true).Length > 0) continue;
        //        abstractHessianOutput.WriteString(field.Name);
        //        abstractHessianOutput.WriteObject(ReflectionUtils.GetMemberValue(field, obj));
        //    }
        //    abstractHessianOutput.WriteMapEnd();
        //}

        /// <summary>
        /// Serialiaztion of objects
        /// </summary>
        /// <param name="obj">Object to serialize</param>
        /// <param name="abstractHessianOutput">HessianOutput - Instance</param>
        public override void WriteObject(object obj, AbstractHessianOutput abstractHessianOutput)
        {
            if (abstractHessianOutput.AddRef(obj))
            {
                return;
            }

            Type cl = obj.GetType();

            int iref = abstractHessianOutput.WriteObjectBegin(cl.FullName);

            SerializationInfo serializationInfo = new SerializationInfo(cl, new FormatterConverter());

            ((ISerializable)obj).GetObjectData(serializationInfo, new StreamingContext());

            if (iref >= 0)
            {
                WriteInstance(serializationInfo, abstractHessianOutput);
            }
            else if (iref == -1)
            {
                writeDefinition20(serializationInfo, abstractHessianOutput);
                abstractHessianOutput.WriteObjectBegin(cl.FullName);
                WriteInstance(serializationInfo, abstractHessianOutput);
            }
            else
            {
                WriteObject10(serializationInfo, abstractHessianOutput);
            }
        }
예제 #2
0
        ///// <summary>
        ///// Serialiaztion of objects
        ///// </summary>
        ///// <param name="obj">Object to serialize</param>
        ///// <param name="abstractHessianOutput">HessianOutput - Instance</param>
        //public override void WriteObject(object obj, AbstractHessianOutput abstractHessianOutput)
        //{
        //    if (abstractHessianOutput.AddRef(obj))
        //        return;
        //    Type type = obj.GetType();
        //    abstractHessianOutput.WriteMapBegin(type.FullName);
        //    List<MemberInfo> serFields = GetSerializableFieldList();
        //    for (int i = 0; i < serFields.Count; i++)
        //    {
        //        MemberInfo field = serFields[i];
        //        //if (!field.CanWrite) continue;
        //        if (field.GetCustomAttributes(typeof(IgnoreAttribute), true).Length > 0) continue;
        //        abstractHessianOutput.WriteString(field.Name);
        //        abstractHessianOutput.WriteObject(ReflectionUtils.GetMemberValue(field, obj));
        //    }
        //    abstractHessianOutput.WriteMapEnd();
        //}

        /// <summary>
        /// Serialiaztion of objects
        /// </summary>
        /// <param name="obj">Object to serialize</param>
        /// <param name="abstractHessianOutput">HessianOutput - Instance</param>
        public override void WriteObject(object obj, AbstractHessianOutput abstractHessianOutput)
        {
            if (abstractHessianOutput.AddRef(obj))
            {
                return;
            }

            Type cl = obj.GetType();

            int iref = abstractHessianOutput.WriteObjectBegin(cl.FullName);

            if (iref >= 0)
            {
                WriteInstance(obj, abstractHessianOutput);
            }
            else if (iref == -1)
            {
                writeDefinition20(abstractHessianOutput);
                abstractHessianOutput.WriteObjectBegin(cl.FullName);
                WriteInstance(obj, abstractHessianOutput);
            }
            else
            {
                WriteObject10(obj, abstractHessianOutput);
            }
        }
예제 #3
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());
                }
            }
        }
예제 #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());
                }
            }
        }