Parent of the HessianOutput class. Declares write operations (access methods) to an OutputStream
Inheritance: CHessianProtocolConstants
Beispiel #1
0
        /// <summary>
        /// Writes map in the output stream
        /// </summary>
        /// <param name="obj"> Object to write</param>
        /// <param name="abstractHessianOutput">Instance of the hessian output</param>
        public override void WriteObject(object obj, AbstractHessianOutput abstractHessianOutput)
        {
            if (abstractHessianOutput.AddRef(obj))
            {
                return;
            }

            IDictionary dictionary = (IDictionary)obj;


            Type mapType = obj.GetType();

            if (mapType.Equals(typeof(Dictionary <Object, Object>)))
            {
                abstractHessianOutput.WriteMapBegin(null);
            }
            else
            {
                abstractHessianOutput.WriteMapBegin(mapType.Name);
            }

            IDictionaryEnumerator enumerator = dictionary.GetEnumerator();

            while (enumerator.MoveNext())
            {
                object objKey = enumerator.Key;

                abstractHessianOutput.WriteObject(objKey);

                object objValue = enumerator.Value;

                abstractHessianOutput.WriteObject(objValue);
            }
            abstractHessianOutput.WriteMapEnd();
        }
        /// <summary>
        /// Writes enum to the output stream
        /// </summary>
        /// <param name="obj"> Enum to write</param>
        /// <param name="abstractHessianOutput">Instance of the hessian output</param>
        public override void WriteObject(object obj, AbstractHessianOutput abstractHessianOutput)
        {
            // immer den Referenzzähler hochzählen!
            // (manche enums mit nullable funktionieren nicht)
            object unrefobj = new object();

            if (abstractHessianOutput.AddRef(unrefobj))
            {
                return;
            }

            if (obj == null)
            {
                abstractHessianOutput.WriteNull();
            }
            else
            {
                Type   enumType = obj.GetType();
                string name     =                         //Enum.GetName(enumType, obj);
                                  ((Enum)obj).ToString(); // das geht auch mit .NET Mobile
                abstractHessianOutput.WriteMapBegin(enumType.FullName);
                abstractHessianOutput.WriteObject("name");
                abstractHessianOutput.WriteObject(name);
                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   type     = obj.GetType();
            string typeName = type.FullName;

            object[] customAttributes = type.GetCustomAttributes(typeof(CTypeNameAttribute), false);
            if (customAttributes.Length > 0)
            {
                typeName = ((CTypeNameAttribute)customAttributes[0]).Name;
            }
            abstractHessianOutput.WriteMapBegin(typeName);
            List <Object> serFields = GetSerializableFieldList();

            for (int i = 0; i < serFields.Count; i++)
            {
                FieldInfo field = (FieldInfo)serFields[i];
                abstractHessianOutput.WriteString(field.Name);
                abstractHessianOutput.WriteObject(field.GetValue(obj));
            }
            abstractHessianOutput.WriteMapEnd();
        }
        /// <summary>
        /// Writes list objects (That extends from ICollection-Interfaces)
        /// </summary>
        /// <param name="objList">List object</param>
        /// <param name="abstractHessianOutput">HessianOutput - Instance</param>
        public override void WriteObject(object objList, AbstractHessianOutput abstractHessianOutput)
        {
            if (abstractHessianOutput.AddRef(objList))
            {
                return;
            }

            // TODO auch generische Listen schreiben

            ICollection collection = ( ICollection)objList;
            Type        type       = objList.GetType();

            if (type.Equals(typeof(List <Object>)))
            {
                abstractHessianOutput.WriteListBegin(collection.Count, null);
            }
            else
            {
                abstractHessianOutput.WriteListBegin(collection.Count, objList.GetType().FullName);
            }
            IEnumerator enumerator = collection.GetEnumerator();

            while (enumerator.MoveNext())
            {
                Object value = enumerator.Current;
                abstractHessianOutput.WriteObject(value);
            }
            abstractHessianOutput.WriteListEnd();
        }
        /// <summary>
        /// Writes map in the output stream
        /// </summary>
        /// <param name="obj"> Object to write</param>
        /// <param name="abstractHessianOutput">Instance of the hessian output</param>
        public override void WriteObject(object obj, AbstractHessianOutput abstractHessianOutput)
        {
            if (abstractHessianOutput.AddRef(obj))
                return;

            IDictionary dictionary = (IDictionary) obj;

            Type mapType = obj.GetType();
            if (mapType.Equals(typeof(Dictionary<Object, Object>)) )
            {
                abstractHessianOutput.WriteMapBegin(null);
            }
            else
            {
                abstractHessianOutput.WriteMapBegin(mapType.Name);
            }

            IDictionaryEnumerator enumerator = dictionary.GetEnumerator();
            while (enumerator.MoveNext())
            {
                object objKey = enumerator.Key;

                abstractHessianOutput.WriteObject(objKey);

                object objValue = enumerator.Value;

                abstractHessianOutput.WriteObject(objValue);
            }
            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 type = obj.GetType();
     abstractHessianOutput.WriteObject(JsonHelper.SerializeObject(obj));
 }
 /// <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
     {
         abstractHessianOutput.WriteUTCDate(MakeJavaDate((DateTime)objDate));
     }
 }
 /// <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
     {
         abstractHessianOutput.WriteUTCDate(MakeJavaDate((DateTime)objDate));
     }
 }
 /// <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(MakeJavaDate((DateTime)objDate));
         //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);
            }
        }
        /// <summary>
        /// Writes array object
        /// </summary>
        /// <param name="objArrayToWrite">Array - Instance to write</param>
        /// <param name="abstractHessianOutput">HessianOutput-Instance</param>
        public override void  WriteObject(Object objArrayToWrite, AbstractHessianOutput abstractHessianOutput)
        {
            if (abstractHessianOutput.AddRef(objArrayToWrite))
            {
                return;
            }

            System.Object[] array = (Object[])objArrayToWrite;

            abstractHessianOutput.WriteListBegin(array.Length, getArrayType(objArrayToWrite.GetType()));

            for (int i = 0; i < array.Length; i++)
            {
                abstractHessianOutput.WriteObject(array[i]);
            }

            abstractHessianOutput.WriteListEnd();
        }
Beispiel #12
0
        /// <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);
            }
        }
        /// <summary>
        /// Writes list objects (That extends from ICollection-Interfaces)
        /// </summary>
        /// <param name="objList">List object</param>
        /// <param name="abstractHessianOutput">HessianOutput - Instance</param>
        public override void WriteObject(object objList, AbstractHessianOutput abstractHessianOutput)
        {
            if (abstractHessianOutput.AddRef(objList))
                return ;

            // TODO auch generische Listen schreiben

            ICollection collection = ( ICollection) objList;
            Type type = objList.GetType();
            if (type.Equals(typeof(ArrayList)))
                abstractHessianOutput.WriteListBegin(collection.Count, null);
            else
                abstractHessianOutput.WriteListBegin(collection.Count, objList.GetType().FullName);
            IEnumerator enumerator =  collection.GetEnumerator();
            while (enumerator.MoveNext())
            {
                Object value = enumerator.Current;
                abstractHessianOutput.WriteObject(value);
            }
            abstractHessianOutput.WriteListEnd();
        }
        /// <summary>
        /// Writes enum to the output stream
        /// </summary>
        /// <param name="obj"> Enum to write</param>
        /// <param name="abstractHessianOutput">Instance of the hessian output</param>
        public override void WriteObject(object obj, AbstractHessianOutput abstractHessianOutput)
        {
            // immer den Referenzzähler hochzählen!
            // (manche enums mit nullable funktionieren nicht)
            object unrefobj = new object();
            if (abstractHessianOutput.AddRef(unrefobj))
                return;

            if (obj == null)
            {
                abstractHessianOutput.WriteNull();
            }
            else
            {
                Type enumType = obj.GetType();
                string name = //Enum.GetName(enumType, obj);
                    ((Enum)obj).ToString(); // das geht auch mit .NET Mobile
                abstractHessianOutput.WriteMapBegin(enumType.FullName);
                abstractHessianOutput.WriteObject("name");
                abstractHessianOutput.WriteObject(name);
                abstractHessianOutput.WriteMapEnd();
            }
        }
		/// <summary>
		/// Writes primitive objects and arrayy of primitive objects
		/// </summary>
		/// <param name="obj">Object to write</param>
		/// <param name="abstractHessianOutput">HessianOutput - Instance</param>
		/// <exception cref="CHessianException"/>
		public override void WriteObject(object obj, AbstractHessianOutput abstractHessianOutput)
		{
			switch (m_intCode)
			{
				case BOOLEAN:
					abstractHessianOutput.WriteBoolean(((bool) obj));
					break;
				case BYTE:
				case SBYTE:
				case SHORT:
				case INTEGER:
					abstractHessianOutput.WriteInt(Convert.ToInt32(obj));
					break;
				case LONG:
					abstractHessianOutput.WriteLong((long) obj);
					break;
				case FLOAT:
					abstractHessianOutput.WriteDouble(Convert.ToDouble(obj));
					break;
				case DOUBLE:
					abstractHessianOutput.WriteDouble((double) obj);
					break;
				case CHARACTER:
					abstractHessianOutput.WriteInt((char) obj);
					break;
				case STRING:
					abstractHessianOutput.WriteString((string) obj);
					break;
				case DATE:					
                    DateTime dt = (DateTime)obj;
                    long javaTime = CDateSerializer.MakeJavaDate(dt);
                    abstractHessianOutput.WriteUTCDate(javaTime);
                    break; 

				case INTEGER_ARRAY:
				{
					if (abstractHessianOutput.AddRef(obj))
						return;

					int[] arrData = (int[]) obj;
					abstractHessianOutput.WriteListBegin(arrData.Length, "[int");
					for (int i = 0; i < arrData.Length; i++)
						abstractHessianOutput.WriteInt(arrData[i]);
					abstractHessianOutput.WriteListEnd();
					break;
				}

				case STRING_ARRAY:
				{
					if (abstractHessianOutput.AddRef(obj))
						return;

					String[] arrData = (String[]) obj;
					abstractHessianOutput.WriteListBegin(arrData.Length, "[string");
					for (int i = 0; i < arrData.Length; i++)
					{
						abstractHessianOutput.WriteString(arrData[i]);
					}
					abstractHessianOutput.WriteListEnd();
					break;
				}
				case BOOLEAN_ARRAY:
				{
					if (abstractHessianOutput.AddRef(obj))
						return;

					bool[] arrData = (bool[]) obj;
					abstractHessianOutput.WriteListBegin(arrData.Length, "[boolean");
					for (int i = 0; i < arrData.Length; i++)
						abstractHessianOutput.WriteBoolean(arrData[i]);
					abstractHessianOutput.WriteListEnd();
					break;
				}

				case BYTE_ARRAY:
				{
					byte[] arrData = (byte[]) obj;
					abstractHessianOutput.WriteBytes(arrData, 0, arrData.Length);
					break;
				}

                case SBYTE_ARRAY:
                {
                    if (abstractHessianOutput.AddRef(obj))
                        return;

                    sbyte[] arrData = (sbyte[])obj;
                    abstractHessianOutput.WriteListBegin(arrData.Length, "[sbyte");
                    for (int i = 0; i < arrData.Length; i++)
                        abstractHessianOutput.WriteInt(arrData[i]);
                    abstractHessianOutput.WriteListEnd();
                    break;
                }

				case SHORT_ARRAY:
				{
					if (abstractHessianOutput.AddRef(obj))
						return;

					short[] arrData = (short[]) obj;
					abstractHessianOutput.WriteListBegin(arrData.Length, "[short");
					for (int i = 0; i < arrData.Length; i++)
						abstractHessianOutput.WriteInt(arrData[i]);
					abstractHessianOutput.WriteListEnd();
					break;
				}


				case LONG_ARRAY:
				{
					if (abstractHessianOutput.AddRef(obj))
						return;

					long[] arrData = (long[]) obj;
					abstractHessianOutput.WriteListBegin(arrData.Length, "[long");
					for (int i = 0; i < arrData.Length; i++)
						abstractHessianOutput.WriteLong(arrData[i]);
					abstractHessianOutput.WriteListEnd();
					break;
				}

				case FLOAT_ARRAY:
				{
					if (abstractHessianOutput.AddRef(obj))
						return;

					float[] arrData = (float[]) obj;
					abstractHessianOutput.WriteListBegin(arrData.Length, "[float");
					for (int i = 0; i < arrData.Length; i++)
						abstractHessianOutput.WriteDouble(arrData[i]);
					abstractHessianOutput.WriteListEnd();
					break;
				}

				case DOUBLE_ARRAY:
				{
					if (abstractHessianOutput.AddRef(obj))
						return;

					double[] arrData = (double[]) obj;
					abstractHessianOutput.WriteListBegin(arrData.Length, "[double");
					for (int i = 0; i < arrData.Length; i++)
						abstractHessianOutput.WriteDouble(arrData[i]);
					abstractHessianOutput.WriteListEnd();
					break;
				}


				case CHARACTER_ARRAY:
				{
					char[] arrData = (char[]) obj;
					abstractHessianOutput.WriteString(arrData, 0, arrData.Length);
					break;
				}

				case OBJECT_ARRAY:
				{
					if (abstractHessianOutput.AddRef(obj))
						return;

					Object[] arrData = (Object[]) obj;
					abstractHessianOutput.WriteListBegin(arrData.Length, "[object");
					for (int i = 0; i < arrData.Length; i++)
					{
						abstractHessianOutput.WriteObject(arrData[i]);
					}
					abstractHessianOutput.WriteListEnd();
					break;
				}

				default:
					throw new CHessianException(m_intCode + " " + obj.GetType().ToString());
			}
		#endregion
		}
 /// <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);
     ArrayList serFields = GetSerializableFieldList();
     for (int i = 0; i < serFields.Count; i++)
     {
         FieldInfo field = (FieldInfo)serFields[i];
         abstractHessianOutput.WriteString(field.Name);
         abstractHessianOutput.WriteObject(field.GetValue(obj));
     }
     abstractHessianOutput.WriteMapEnd();
 }
        /// <summary>
        /// Invoke the object with the request from the input stream.
        /// </summary>
        /// <param name="inHessian">the Hessian input stream</param>
        /// <param name="outHessian">the Hessian output stream</param>		
        public void invoke(AbstractHessianInput inHessian, AbstractHessianOutput outHessian)
        {
            inHessian.StartCall();
            MethodInfo methodInf = getMethodInfo(inHessian.Method);

            //If the method doesn't exist
            if (methodInf == null)
            {
                outHessian.StartReply();
                outHessian.WriteFault("NoSuchMethodException",
                    "The service has no method named: " + inHessian.Method,
                    null);
                outHessian.CompleteReply();
                return;
            }

            ParameterInfo[] paramInfo = methodInf.GetParameters();
            Object[] valuesParam = new Object[paramInfo.Length];

            for (int i = 0; i < paramInfo.Length; i++)
            {
                valuesParam[i] = inHessian.ReadObject(paramInfo[i].ParameterType);
            }
            inHessian.CompleteCall();

            Object result = null;

            try {
                result = methodInf.Invoke(m_Service,valuesParam);
            } catch(Exception e) {
                //TODO: Exception besser behandeln

                if (e.GetType() == typeof(System.Reflection.TargetInvocationException))
                {
                    if (e.InnerException != null)
                    {
                        e = e.InnerException;
                    }
                }
                outHessian.StartReply();
                outHessian.WriteFault("ServiceException", e.Message, e);

                outHessian.CompleteReply();
                return;
            }
            outHessian.StartReply();

            outHessian.WriteObject(result);

            outHessian.CompleteReply();
        }
        /// <summary>
        /// Writes primitive objects and arrayy of primitive objects
        /// </summary>
        /// <param name="obj">Object to write</param>
        /// <param name="abstractHessianOutput">HessianOutput - Instance</param>
        /// <exception cref="CHessianException"/>
        public override void WriteObject(object obj, AbstractHessianOutput abstractHessianOutput)
        {
            switch (m_intCode)
            {
            case BOOLEAN:
                abstractHessianOutput.WriteBoolean(((bool)obj));
                break;

            case BYTE:
            case SBYTE:
            case SHORT:
            case INTEGER:
                abstractHessianOutput.WriteInt(Convert.ToInt32(obj));
                break;

            case LONG:
                abstractHessianOutput.WriteLong((long)obj);
                break;

            case FLOAT:
                abstractHessianOutput.WriteDouble(Convert.ToDouble(obj));
                break;

            case DOUBLE:
                abstractHessianOutput.WriteDouble((double)obj);
                break;

            case CHARACTER:
                abstractHessianOutput.WriteInt((char)obj);
                break;

            case STRING:
                abstractHessianOutput.WriteString((string)obj);
                break;

            case DATE:
                DateTime dt       = (DateTime)obj;
                long     javaTime = CDateSerializer.MakeJavaDate(dt);
                abstractHessianOutput.WriteUTCDate(javaTime);
                break;

            case INTEGER_ARRAY:
            {
                if (abstractHessianOutput.AddRef(obj))
                {
                    return;
                }

                int[] arrData = (int[])obj;
                abstractHessianOutput.WriteListBegin(arrData.Length, "[int");
                for (int i = 0; i < arrData.Length; i++)
                {
                    abstractHessianOutput.WriteInt(arrData[i]);
                }
                abstractHessianOutput.WriteListEnd();
                break;
            }

            case STRING_ARRAY:
            {
                if (abstractHessianOutput.AddRef(obj))
                {
                    return;
                }

                String[] arrData = (String[])obj;
                abstractHessianOutput.WriteListBegin(arrData.Length, "[string");
                for (int i = 0; i < arrData.Length; i++)
                {
                    abstractHessianOutput.WriteString(arrData[i]);
                }
                abstractHessianOutput.WriteListEnd();
                break;
            }

            case BOOLEAN_ARRAY:
            {
                if (abstractHessianOutput.AddRef(obj))
                {
                    return;
                }

                bool[] arrData = (bool[])obj;
                abstractHessianOutput.WriteListBegin(arrData.Length, "[boolean");
                for (int i = 0; i < arrData.Length; i++)
                {
                    abstractHessianOutput.WriteBoolean(arrData[i]);
                }
                abstractHessianOutput.WriteListEnd();
                break;
            }

            case BYTE_ARRAY:
            {
                byte[] arrData = (byte[])obj;
                abstractHessianOutput.WriteBytes(arrData, 0, arrData.Length);
                break;
            }

            case SBYTE_ARRAY:
            {
                if (abstractHessianOutput.AddRef(obj))
                {
                    return;
                }

                sbyte[] arrData = (sbyte[])obj;
                abstractHessianOutput.WriteListBegin(arrData.Length, "[sbyte");
                for (int i = 0; i < arrData.Length; i++)
                {
                    abstractHessianOutput.WriteInt(arrData[i]);
                }
                abstractHessianOutput.WriteListEnd();
                break;
            }

            case SHORT_ARRAY:
            {
                if (abstractHessianOutput.AddRef(obj))
                {
                    return;
                }

                short[] arrData = (short[])obj;
                abstractHessianOutput.WriteListBegin(arrData.Length, "[short");
                for (int i = 0; i < arrData.Length; i++)
                {
                    abstractHessianOutput.WriteInt(arrData[i]);
                }
                abstractHessianOutput.WriteListEnd();
                break;
            }


            case LONG_ARRAY:
            {
                if (abstractHessianOutput.AddRef(obj))
                {
                    return;
                }

                long[] arrData = (long[])obj;
                abstractHessianOutput.WriteListBegin(arrData.Length, "[long");
                for (int i = 0; i < arrData.Length; i++)
                {
                    abstractHessianOutput.WriteLong(arrData[i]);
                }
                abstractHessianOutput.WriteListEnd();
                break;
            }

            case FLOAT_ARRAY:
            {
                if (abstractHessianOutput.AddRef(obj))
                {
                    return;
                }

                float[] arrData = (float[])obj;
                abstractHessianOutput.WriteListBegin(arrData.Length, "[float");
                for (int i = 0; i < arrData.Length; i++)
                {
                    abstractHessianOutput.WriteDouble(arrData[i]);
                }
                abstractHessianOutput.WriteListEnd();
                break;
            }

            case DOUBLE_ARRAY:
            {
                if (abstractHessianOutput.AddRef(obj))
                {
                    return;
                }

                double[] arrData = (double[])obj;
                abstractHessianOutput.WriteListBegin(arrData.Length, "[double");
                for (int i = 0; i < arrData.Length; i++)
                {
                    abstractHessianOutput.WriteDouble(arrData[i]);
                }
                abstractHessianOutput.WriteListEnd();
                break;
            }


            case CHARACTER_ARRAY:
            {
                char[] arrData = (char[])obj;
                abstractHessianOutput.WriteString(arrData, 0, arrData.Length);
                break;
            }

            case OBJECT_ARRAY:
            {
                if (abstractHessianOutput.AddRef(obj))
                {
                    return;
                }

                Object[] arrData = (Object[])obj;
                abstractHessianOutput.WriteListBegin(arrData.Length, "[object");
                for (int i = 0; i < arrData.Length; i++)
                {
                    abstractHessianOutput.WriteObject(arrData[i]);
                }
                abstractHessianOutput.WriteListEnd();
                break;
            }

            default:
                throw new CHessianException(m_intCode + " " + obj.GetType().ToString());
            }
            #endregion
        }
 /// <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();
     string typeName = type.FullName;
     object[] customAttributes = type.GetCustomAttributes(typeof(CTypeNameAttribute), false);
     if (customAttributes.Length > 0)
       typeName = ((CTypeNameAttribute)customAttributes[0]).Name;
     abstractHessianOutput.WriteMapBegin(typeName);
     List<Object> serFields = GetSerializableFieldList();
     for (int i = 0; i < serFields.Count; i++)
     {
         FieldInfo field = (FieldInfo)serFields[i];
         abstractHessianOutput.WriteString(field.Name);
         abstractHessianOutput.WriteObject(field.GetValue(obj));
     }
     abstractHessianOutput.WriteMapEnd();
 }