Ejemplo n.º 1
0
        public void WriteObject(string className, IDictionary objectFields, IProtocolFormatter writer)
        {
            if (objectFields.Contains("serializeAsArrayMap"))
            {
                objectFields.Remove("serializeAsArrayMap");
                WriteObjectMap(objectFields, writer);
                return;
            }

            if (className != null)
            {
                writer.BeginWriteNamedObject(className, objectFields.Count);
            }
            else
            {
                //writer.BeginWriteObjectMap( objectFields.Count );
                writer.BeginWriteObject(objectFields.Count);
            }

            IEnumerator en = objectFields.Keys.GetEnumerator();

            while (en.MoveNext())
            {
                object fieldName = en.Current;

                if (Log.isLogging(LoggingConstants.SERIALIZATION))
                {
                    Log.log(LoggingConstants.SERIALIZATION, "serializing property/field : " + fieldName);
                }

                writer.WriteFieldName(fieldName.ToString());
                writer.BeginWriteFieldValue();

                try
                {
                    MessageWriter.writeObject(objectFields[fieldName], writer);
                }
                catch (Exception exception)
                {
                    if (Log.isLogging(LoggingConstants.ERROR))
                    {
                        Log.log(LoggingConstants.ERROR, "unable to serialize object's field " + fieldName, exception);
                    }
                }
                finally
                {
                    writer.EndWriteFieldValue();
                }
            }

            if (className != null)
            {
                writer.EndWriteNamedObject();
            }
            else
            {
                //writer.EndWriteObjectMap();
                writer.EndWriteObject();
            }
        }
Ejemplo n.º 2
0
        public override void write( object obj, IProtocolFormatter writer )
		{
			IDictionary propertyBag = ((AnonymousObject) obj).Properties;
			writer.BeginWriteObject( propertyBag.Count );

			foreach( object key in propertyBag.Keys )
			{
                writer.WriteFieldName( key.ToString() );
                writer.BeginWriteFieldValue();
				MessageWriter.writeObject( propertyBag[ key ], writer );
                writer.EndWriteFieldValue();
			}

            writer.EndWriteObject();
		}
Ejemplo n.º 3
0
		public void WriteObject( string className, IDictionary objectFields, IProtocolFormatter writer )
		{
    if ( objectFields.Contains( "serializeAsArrayMap" ) )
      {
      objectFields.Remove( "serializeAsArrayMap" );
      WriteObjectMap( objectFields, writer );
      return;
      }

		  if( className != null )
				writer.BeginWriteNamedObject( className, objectFields.Count );
			else
				//writer.BeginWriteObjectMap( objectFields.Count );
                writer.BeginWriteObject( objectFields.Count );

			IEnumerator en = objectFields.Keys.GetEnumerator();

			while( en.MoveNext() )
			{
				object fieldName = en.Current;

				if( Log.isLogging( LoggingConstants.SERIALIZATION ) )
                    Log.log( LoggingConstants.SERIALIZATION, "serializing property/field : " + fieldName );

				writer.WriteFieldName( fieldName.ToString() );
				writer.BeginWriteFieldValue();

				try
				{
					MessageWriter.writeObject( objectFields[ fieldName ], writer );
				}
				catch( Exception exception )
				{
					if( Log.isLogging( LoggingConstants.ERROR ) )
						Log.log( LoggingConstants.ERROR, "unable to serialize object's field " + fieldName, exception );
				}
				finally
				{
					writer.EndWriteFieldValue();
				}
			}
            
			if( className != null )
				writer.EndWriteNamedObject();
			else
				//writer.EndWriteObjectMap();
                writer.EndWriteObject();
		}
Ejemplo n.º 4
0
        public override void write(object obj, IProtocolFormatter writer)
        {
            IDictionary propertyBag = ((AnonymousObject)obj).Properties;

            writer.BeginWriteObject(propertyBag.Count);

            foreach (object key in propertyBag.Keys)
            {
                writer.WriteFieldName(key.ToString());
                writer.BeginWriteFieldValue();
                MessageWriter.writeObject(propertyBag[key], writer);
                writer.EndWriteFieldValue();
            }

            writer.EndWriteObject();
        }