public IAdaptingType read(FlashorbBinaryReader reader, ParseContext parseContext) { int refId = reader.ReadVarInteger(); if ((refId & 0x1) == 0) { return(parseContext.getReference(refId >> 1)); } int arraySize = refId >> 1; IAdaptingType adaptingType = null; object container = null; while (true) { string str = ReaderUtils.readString(reader, parseContext); if (str == null || str.Length == 0) { break; } if (container == null) { container = new Dictionary <object, object>(); adaptingType = new AnonymousObject((IDictionary)container); parseContext.addReference(adaptingType); } object obj = RequestParser.readData(reader, parseContext); ((IDictionary)container)[str] = obj; } if (adaptingType == null) { container = new object[arraySize]; adaptingType = new ArrayType((object[])container); parseContext.addReference(adaptingType); for (int i = 0; i < arraySize; i++) { ((object[])container)[i] = RequestParser.readData(reader, parseContext); } } else { for (int i = 0; i < arraySize; i++) { object obj = RequestParser.readData(reader, parseContext); ((IDictionary)container)[i.ToString()] = obj; } } return(adaptingType); }
public IAdaptingType read( FlashorbBinaryReader reader, ParseContext parseContext ) { int refId = reader.ReadVarInteger(); if( (refId & 0x1) == 0 ) return parseContext.getReference( refId >> 1 ); int arraySize = refId >> 1; IAdaptingType adaptingType = null; object container = null; while( true ) { string str = ReaderUtils.readString( reader, parseContext ); if( str == null || str.Length == 0 ) break; if( container == null ) { container = new Dictionary<object, object>(); adaptingType = new AnonymousObject( (IDictionary) container ); parseContext.addReference( adaptingType ); } object obj = RequestParser.readData( reader, parseContext ); ((IDictionary) container)[ str ] = obj; } if( adaptingType == null ) { container = new object[ arraySize ]; adaptingType = new ArrayType( (object[]) container ); parseContext.addReference( adaptingType ); for( int i = 0; i < arraySize; i++ ) ((object[]) container)[ i ] = RequestParser.readData( reader, parseContext ); } else { for( int i = 0; i < arraySize; i++ ) { object obj = RequestParser.readData( reader, parseContext ); ((IDictionary) container)[ i.ToString() ] = obj; } } return adaptingType; }
public IAdaptingType read( FlashorbBinaryReader reader, ParseContext parseContext ) { //int capacity = reader.ReadInt32(); int capacity = reader.ReadInteger(); Dictionary<String, Object> properties = new Dictionary<String, Object>( capacity ); AnonymousObject anonymousObject = new AnonymousObject( properties ); parseContext.addReference( anonymousObject ); while( true ) { String propName = reader.ReadUTF(); object obj = RequestParser.readData( reader, parseContext ); if( obj == null ) break; properties[ propName ] = obj; } return anonymousObject; }
public IAdaptingType read(FlashorbBinaryReader reader, ParseContext parseContext) { Dictionary <object, object> properties = new Dictionary <object, object>(); AnonymousObject anonymousObject = new AnonymousObject(properties); parseContext.addReference(anonymousObject); while (true) { string propName = reader.ReadUTF(); object obj = null; int dataType = reader.ReadByte(); if (dataType.Equals(Datatypes.REMOTEREFERENCE_DATATYPE_V1) && !propName.Equals("nc")) { obj = 0d; // must be an instance of Flash's Number } else { obj = RequestParser.readData(dataType, reader, parseContext); } if (obj == null) { break; } properties[propName] = obj; } if (properties.Count == 1 && properties.ContainsKey("nc")) { return((IAdaptingType)properties["nc"]); } return(anonymousObject); }
public IAdaptingType read(FlashorbBinaryReader reader, ParseContext parseContext) { //int capacity = reader.ReadInt32(); int capacity = reader.ReadInteger(); Dictionary <String, Object> properties = new Dictionary <String, Object>(capacity); AnonymousObject anonymousObject = new AnonymousObject(properties); parseContext.addReference(anonymousObject); while (true) { String propName = reader.ReadUTF(); object obj = RequestParser.readData(reader, parseContext); if (obj == null) { break; } properties[propName] = obj; } return(anonymousObject); }
// in order to avoid cyclic comparasion we need to remember visited objects public bool Equals(object _obj, Dictionary <DictionaryEntry, bool> visitedPairs) { AnonymousObject obj = _obj as AnonymousObject; // DictionaryEntry comparisionPair = new DictionaryEntry( this, _obj ); // visitedPairs[ comparisionPair ] = true; if (obj == null) { return(false); } if (Object.ReferenceEquals(this, _obj)) { return(true); } return(this.anonymousObjectGuid.Equals(obj.anonymousObjectGuid)); /* * if( properties.Count != obj.properties.Count ) * return false; * * foreach( DictionaryEntry dictionaryEntry in properties ) * if( !obj.properties.Contains( dictionaryEntry.Key ) || * ( !visitedPairs.ContainsKey( new DictionaryEntry(obj.properties[ dictionaryEntry.Key ], dictionaryEntry.Value) ) * && !( (IAdaptingType) obj.properties[ dictionaryEntry.Key ] ).Equals( dictionaryEntry.Value, visitedPairs ) ) * ) * { * visitedPairs.Remove( comparisionPair ); * return false; * } * * visitedPairs.Remove( comparisionPair ); * return true;*/ }
public IAdaptingType read( FlashorbBinaryReader reader, ParseContext parseContext ) { int refId = reader.ReadVarInteger(); if( (refId & 0x1) == 0 ) return (IAdaptingType) parseContext.getReference( refId >> 1 ); ClassInfo classInfo = getClassInfo( refId, reader, parseContext ); Type mappedType = null; if ( !string.IsNullOrEmpty( classInfo.className ) ) mappedType = Types.Types.getServerTypeForClientClass( classInfo.className ); if ( classInfo.externalizable || typeof( IExternalizable ).IsAssignableFrom( mappedType ) ) { Type type = Types.Types.getServerTypeForClientClass( classInfo.className ); object extobj = null; if( type != null ) extobj = ObjectFactories.CreateServiceObject( type ); else extobj = ObjectFactories.CreateServiceObject( classInfo.className ); if( !(extobj is IExternalizable) ) { throw new Exception( "object must implement IExternalizable" ); } else { CacheableAdaptingTypeWrapper wrapper = new CacheableAdaptingTypeWrapper(); parseContext.addReference( wrapper ); IAdaptingType returnValue = null; extobj = ((IExternalizable)extobj).readExternal( reader, parseContext ); if( extobj is IAdaptingType ) returnValue = (IAdaptingType) extobj; else returnValue = new ConcreteObject( extobj ); wrapper.setType( returnValue ); return returnValue; } } else { Dictionary<String, IAdaptingType> props = new Dictionary<String, IAdaptingType>(); AnonymousObject anonObj = new AnonymousObject(); IAdaptingType returnValue = anonObj; if( classInfo.className != null && classInfo.className.Length > 0 ) returnValue = new NamedObject( classInfo.className, anonObj ); parseContext.addReference( returnValue ); int propCount = classInfo.getPropertyCount(); for( int i = 0; i < propCount; i++ ) { if( Log.isLogging( LoggingConstants.DEBUG ) ) Log.log( LoggingConstants.DEBUG, "reading object property " + classInfo.getProperty( i ) ); props[ classInfo.getProperty( i ) ] = RequestParser.readData( reader, parseContext ); } if( classInfo.looseProps ) while( true ) { string propName = ReaderUtils.readString( reader, parseContext ); if( propName == null || propName.Length == 0 ) break; props[ propName ] = RequestParser.readData( reader, parseContext ); } anonObj.Properties = props; return returnValue; } }
public IAdaptingType read(FlashorbBinaryReader reader, ParseContext parseContext) { int refId = reader.ReadVarInteger(); if ((refId & 0x1) == 0) { return((IAdaptingType)parseContext.getReference(refId >> 1)); } ClassInfo classInfo = getClassInfo(refId, reader, parseContext); Type mappedType = null; if (!string.IsNullOrEmpty(classInfo.className)) { mappedType = Types.Types.getServerTypeForClientClass(classInfo.className); } if (classInfo.externalizable || typeof(IExternalizable).IsAssignableFrom(mappedType)) { Type type = Types.Types.getServerTypeForClientClass(classInfo.className); object extobj = null; if (type != null) { extobj = ObjectFactories.CreateServiceObject(type); } else { extobj = ObjectFactories.CreateServiceObject(classInfo.className); } if (!(extobj is IExternalizable)) { throw new Exception("object must implement IExternalizable"); } else { CacheableAdaptingTypeWrapper wrapper = new CacheableAdaptingTypeWrapper(); parseContext.addReference(wrapper); IAdaptingType returnValue = null; extobj = ((IExternalizable)extobj).readExternal(reader, parseContext); if (extobj is IAdaptingType) { returnValue = (IAdaptingType)extobj; } else { returnValue = new ConcreteObject(extobj); } wrapper.setType(returnValue); return(returnValue); } } else { Dictionary <String, IAdaptingType> props = new Dictionary <String, IAdaptingType>(); AnonymousObject anonObj = new AnonymousObject(); IAdaptingType returnValue = anonObj; if (classInfo.className != null && classInfo.className.Length > 0) { returnValue = new NamedObject(classInfo.className, anonObj); } parseContext.addReference(returnValue); int propCount = classInfo.getPropertyCount(); for (int i = 0; i < propCount; i++) { if (Log.isLogging(LoggingConstants.DEBUG)) { Log.log(LoggingConstants.DEBUG, "reading object property " + classInfo.getProperty(i)); } props[classInfo.getProperty(i)] = RequestParser.readData(reader, parseContext); } if (classInfo.looseProps) { while (true) { string propName = ReaderUtils.readString(reader, parseContext); if (propName == null || propName.Length == 0) { break; } props[propName] = RequestParser.readData(reader, parseContext); } } anonObj.Properties = props; return(returnValue); } }