Ejemplo n.º 1
0
        public void write( object obj, IProtocolFormatter writer )
        {
            int refId = -1;
            ReferenceCache referenceCache = null;

            if( isReferenceable )
            {
                referenceCache = writer.GetReferenceCache();
                refId = referenceCache.GetStringId( obj );
            }

            if( refId != -1 )
            {
                writer.WriteStringReference( refId );
            }
            else
            {
                if( isReferenceable )
                    referenceCache.AddString( obj );

                //formatter.getContextWriter().write( obj, formatter );
                if( obj is string )
                    writer.WriteString( (string) obj );
                else if( obj is StringBuilder )
                    writer.WriteString( ((StringBuilder) obj).ToString() );
                else if( obj is Char )
                    writer.WriteString( obj.ToString() );
                else if( obj is char[] )
                    writer.WriteString( new String( (char[]) obj ) );
            }
        }
Ejemplo n.º 2
0
        public void write(object obj, IProtocolFormatter writer)
        {
            int            refId          = -1;
            ReferenceCache referenceCache = null;

            if (isReferenceable)
            {
                referenceCache = writer.GetReferenceCache();
                refId          = referenceCache.GetStringId(obj);
            }

            if (refId != -1)
            {
                writer.WriteStringReference(refId);
            }
            else
            {
                if (isReferenceable)
                {
                    referenceCache.AddString(obj);
                }

                //formatter.getContextWriter().write( obj, formatter );
                if (obj is string)
                {
                    writer.WriteString((string)obj);
                }
                else if (obj is StringBuilder)
                {
                    writer.WriteString(((StringBuilder)obj).ToString());
                }
                else if (obj is Char)
                {
                    writer.WriteString(obj.ToString());
                }
                else if (obj is char[])
                {
                    writer.WriteString(new String((char[])obj));
                }
            }
        }