Ejemplo n.º 1
0
        private void WriteObjectMap(IDictionary objectFields, IProtocolFormatter writer)
        {
            int maxInt = -1;

            for (int i = 0; i < objectFields.Count; i++)
            {
                if (!objectFields.Contains(i))
                {
                    break;
                }

                maxInt = i;
            }

            writer.BeginWriteObjectMap(maxInt + 1);

            IEnumerator en = objectFields.Keys.GetEnumerator();

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

                if (fieldName.Equals("length"))
                {
                    continue;
                }

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

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

                MessageWriter.writeObject(objectFields[fieldName], writer);

                writer.EndWriteFieldValue();
            }

            if (maxInt >= 0)
            {
                writer.WriteFieldName("length");
                MessageWriter.writeObject(maxInt + 1, writer);
            }

            writer.EndWriteObjectMap();
        }
Ejemplo n.º 2
0
    private void WriteObjectMap( IDictionary objectFields, IProtocolFormatter writer )
      {
      int maxInt = -1;
      for ( int i = 0; i < objectFields.Count; i++ )
        {
        if ( !objectFields.Contains( i ) )
            break;          

        maxInt = i;
        }

      writer.BeginWriteObjectMap( maxInt + 1 );        

      IEnumerator en = objectFields.Keys.GetEnumerator();

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

        if ( fieldName.Equals( "length" ) )
          continue;

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

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

          MessageWriter.writeObject( objectFields[ fieldName ], writer );

          writer.EndWriteFieldValue();          
        }

        if ( maxInt >= 0 )
          {
          writer.WriteFieldName( "length" );
          MessageWriter.writeObject( maxInt + 1, writer );
          }

        writer.EndWriteObjectMap();        
      }