WriteMapBegin() public abstract method

Writes the map header to the stream. Map writers will call writeMapBegin followed by the map contents and then call writeMapEnd Mt b16 b8 type ( )z
public abstract WriteMapBegin ( string strType ) : void
strType string Type of map
return void
Example #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();
        }
Example #2
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>
        /// 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 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();
            }
        }
Example #5
0
        /// <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();
     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>
 /// 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();
 }