public void write(object obj, IProtocolFormatter formatter) { ReferenceCache referenceCache = formatter.GetReferenceCache(); int refId = referenceCache.GetObjectId(obj); if (refId != -1) { #if FULL_BUILD if (VectorUtils.IsVector(obj) && formatter is AmfV3Formatter) { Type collectionType = obj.GetType(); AmfV3Formatter amfV3Formatter = (AmfV3Formatter)formatter; if (VectorUtils.isIntType(collectionType)) { amfV3Formatter.WriteVarIntWithoutMarker(Datatypes.INT_VECTOR_V3); } else if (VectorUtils.isUIntType(collectionType)) { amfV3Formatter.WriteVarIntWithoutMarker(Datatypes.UINT_VECTOR_V3); } else if (VectorUtils.isNumberType(collectionType)) { amfV3Formatter.WriteVarIntWithoutMarker(Datatypes.DOUBLE_VECTOR_V3); } else { amfV3Formatter.WriteVarIntWithoutMarker(Datatypes.OBJECT_VECTOR_V3); } amfV3Formatter.WriteVarIntWithoutMarker(refId << 1); } else #endif if (obj is IWebORBArrayCollection || obj is IDictionary) { formatter.WriteObjectReference(refId); } else if (obj is ICollection || obj is Array || obj is IWebORBArray) { formatter.WriteArrayReference(refId); } } else { referenceCache.AddObject(obj); formatter.getContextWriter().write(obj, formatter); } }
public void write( object obj, IProtocolFormatter formatter ) { ReferenceCache referenceCache = formatter.GetReferenceCache(); int refId = referenceCache.GetObjectId( obj ); if( refId != -1 ) { formatter.WriteObjectReference( refId ); } else { referenceCache.AddObject( obj ); formatter.getContextWriter().write( obj, formatter ); } }
public void write(object obj, IProtocolFormatter formatter) { ReferenceCache referenceCache = formatter.GetReferenceCache(); int refId = referenceCache.GetStringId(obj); if (refId != -1) { formatter.WriteStringReference(refId); } else { referenceCache.AddString(obj); formatter.getContextWriter().write(obj, formatter); } }
public virtual void write(object obj, IProtocolFormatter formatter) { ReferenceCache referenceCache = formatter.GetReferenceCache(); DateTime date = (DateTime)obj; int refId = referenceCache.GetObjectId(date.ToUniversalTime()); if (refId != -1) { formatter.WriteDateReference(refId); } else { referenceCache.AddObject(date.ToUniversalTime()); formatter.getContextWriter().write(obj, formatter); } }
public virtual void write( object obj, IProtocolFormatter formatter ) { ReferenceCache referenceCache = formatter.GetReferenceCache(); DateTime date = (DateTime) obj; int refId = referenceCache.GetObjectId( date.ToUniversalTime() ); if( refId != -1 ) { formatter.WriteDateReference( refId ); } else { referenceCache.AddObject( date.ToUniversalTime() ); formatter.getContextWriter().write( obj, formatter ); } }
public void write( object obj, IProtocolFormatter formatter ) { ReferenceCache referenceCache = formatter.GetReferenceCache(); int refId = referenceCache.GetObjectId( obj ); if( refId != -1 ) { #if FULL_BUILD if( VectorUtils.IsVector( obj ) && formatter is AmfV3Formatter ) { Type collectionType = obj.GetType(); AmfV3Formatter amfV3Formatter = (AmfV3Formatter) formatter; if( VectorUtils.isIntType( collectionType ) ) amfV3Formatter.WriteVarIntWithoutMarker( Datatypes.INT_VECTOR_V3 ); else if( VectorUtils.isUIntType( collectionType ) ) amfV3Formatter.WriteVarIntWithoutMarker( Datatypes.UINT_VECTOR_V3 ); else if( VectorUtils.isNumberType( collectionType ) ) amfV3Formatter.WriteVarIntWithoutMarker( Datatypes.DOUBLE_VECTOR_V3 ); else amfV3Formatter.WriteVarIntWithoutMarker( Datatypes.OBJECT_VECTOR_V3 ); amfV3Formatter.WriteVarIntWithoutMarker( refId << 1 ); } else #endif if( obj is IWebORBArrayCollection || obj is IDictionary ) { formatter.WriteObjectReference( refId ); } else if( obj is ICollection || obj is Array || obj is IWebORBArray ) { formatter.WriteArrayReference( refId ); } } else { referenceCache.AddObject( obj ); formatter.getContextWriter().write( obj, formatter ); } }
public void write(object obj, IProtocolFormatter writer) { Array arrayObj = null; if (obj is IWebORBArray) { IEnumerator en = ((IWebORBArray)obj).GetEnumerator(); arrayObj = new object[((IWebORBArray)obj).Count]; int i = 0; while (en.MoveNext()) { arrayObj.SetValue(en.Current, i++); } } else { //TODO: test out this cast! arrayObj = (Array)obj; } if (obj.GetType().IsAssignableFrom(typeof(Byte[]))) { Byte[] byteArray = new byte[arrayObj.Length]; for (int i = 0; i < arrayObj.Length; i++) { byteArray[i] = (Byte)arrayObj.GetValue(i); } writer.WriteByteArray(byteArray); return; } if (arrayObj.Rank > 1) { multiDimArrayWriter.write(arrayObj, writer); return; } writer.BeginWriteArray(arrayObj.Length); bool genericArray = arrayObj.GetType().GetElementType().BaseType == null; if (genericArray) { for (int i = 0; i < arrayObj.Length; i++) { //Log.log( "REFCACHE", "WRITING ARRAY ELEMENT " + i ); object value = arrayObj.GetValue(i); ITypeWriter typeWriter = MessageWriter.getWriter(value, writer); typeWriter.write(value, writer); //Log.log( "REFCACHE", "DONE WRITING ARRAY ELEMENT " + i ); } } else { ITypeWriter typeWriter = null; ITypeWriter contextWriter = null; for (int i = 0; i < arrayObj.Length; i++) { object value = arrayObj.GetValue(i); if (contextWriter == null) { typeWriter = MessageWriter.getWriter(value, writer); contextWriter = writer.getContextWriter(); } else { writer.setContextWriter(contextWriter); } typeWriter.write(value, writer); } } writer.EndWriteArray(); }
public void write( object obj, IProtocolFormatter writer ) { Array arrayObj = null; if ( obj is IWebORBArray ) { IEnumerator en = ( (IWebORBArray)obj ).GetEnumerator(); arrayObj = new object[( (IWebORBArray)obj ).Count]; int i = 0; while ( en.MoveNext() ) arrayObj.SetValue( en.Current, i++ ); } else { //TODO: test out this cast! arrayObj = (Array)obj; } if ( obj.GetType().IsAssignableFrom(typeof(Byte[]))) { Byte[] byteArray = new byte[arrayObj.Length]; for ( int i = 0; i < arrayObj.Length; i++ ) byteArray[i] = (Byte)arrayObj.GetValue( i ); writer.WriteByteArray(byteArray); return; } if ( arrayObj.Rank > 1 ) { multiDimArrayWriter.write( arrayObj, writer ); return; } writer.BeginWriteArray( arrayObj.Length ); bool genericArray = arrayObj.GetType().GetElementType().BaseType == null; if ( genericArray ) { for ( int i = 0; i < arrayObj.Length; i++ ) { //Log.log( "REFCACHE", "WRITING ARRAY ELEMENT " + i ); object value = arrayObj.GetValue( i ); ITypeWriter typeWriter = MessageWriter.getWriter( value, writer ); typeWriter.write( value, writer ); //Log.log( "REFCACHE", "DONE WRITING ARRAY ELEMENT " + i ); } } else { ITypeWriter typeWriter = null; ITypeWriter contextWriter = null; for ( int i = 0; i < arrayObj.Length; i++ ) { object value = arrayObj.GetValue( i ); if ( contextWriter == null ) { typeWriter = MessageWriter.getWriter( value, writer ); contextWriter = writer.getContextWriter(); } else { writer.setContextWriter( contextWriter ); } typeWriter.write( value, writer ); } } writer.EndWriteArray(); }