/// <summary> /// read inline dynamic object. /// </summary> /// <param name="result">The result.</param> /// <returns> The read inline dynamic object.</returns> /// <remarks> /// If there is a class-def reference there are no property names /// and the number of values is equal to the number of properties /// in the class-def. /// </remarks> private bool ReadInlineDynamicObject(out object result) { string str; string str2; if (!this.ReadString(out str)) { result = null; return(false); } Amf3ClassDefinition item = new Amf3ClassDefinition { ClassName = str, IsDynamic = true }; this.classDefReferences.Add(item); List <string> list = new List <string>(); Hashtable hashtable = new Hashtable(); if (this.ReadString(out str2)) { while (str2 != string.Empty) { object obj2; list.Add(str2); if (this.Read(out obj2)) { hashtable.Add(str2, obj2); if (!this.ReadString(out str2)) { result = null; return(false); } } else { result = null; return(false); } } item.PropertyNames = list.ToArray(); result = hashtable; return(true); } result = null; return(false); }
/// <summary> /// read inline non dynamic object. /// </summary> /// <param name="flags">The flags.</param> /// <param name="result">The result.</param> /// <returns>the non dynamic object</returns> private bool ReadInlineNonDynamicObject(int flags, out object result) { string str; int num = flags >> 4; if (!this.ReadString(out str)) { result = null; return(false); } string[] strArray = new string[num]; for (int i = 0; i < num; i++) { string str2; if (!this.ReadString(out str2)) { result = null; return(false); } strArray[i] = str2; } Hashtable hashtable = new Hashtable(); for (int j = 0; j < num; j++) { object obj2; if (this.Read(out obj2)) { hashtable.Add(strArray[j], obj2); } else { result = null; return(false); } } Amf3ClassDefinition item = new Amf3ClassDefinition { ClassName = str, PropertyNames = strArray }; this.classDefReferences.Add(item); result = hashtable; return(true); }
/// <summary> /// read object properties. /// </summary> /// <param name="classDefinition">The class definition.</param> /// <param name="result">The result.</param> /// <returns>the object properties</returns> private bool ReadObjectProperties(Amf3ClassDefinition classDefinition, out object result) { Hashtable hashtable = new Hashtable(classDefinition.PropertyNames.Length); foreach (string str in classDefinition.PropertyNames) { object obj2; if (this.Read(out obj2)) { hashtable.Add(str, obj2); } else { result = null; return(false); } } result = hashtable; return(true); }
/// <summary> /// Reads an object from the underling stream. /// </summary> /// <param name="result">The result.</param> /// <returns>The read object.</returns> private bool ReadObject(out object result) { int flags = this.ReadInteger(); if ((flags & 1) == 0) { int num2 = flags >> 1; if (num2 < this.objectReferences.Count) { result = this.objectReferences[num2]; return(true); } if (log.IsDebugEnabled) { log.DebugFormat("Object reference index out of range at position {0}", new object[] { this.binaryReader.BaseStream.Position }); } result = null; return(false); } if ((flags & 2) == 0) { int num3 = flags >> 2; if (num3 < this.classDefReferences.Count) { Amf3ClassDefinition classDefinition = this.classDefReferences[num3]; if (classDefinition.IsDynamic) { return(this.ReadDynamicObjectProperties(out result)); } return(this.ReadObjectProperties(classDefinition, out result)); } if (log.IsDebugEnabled) { log.DebugFormat("Class definition index out of range at position {0}", new object[] { this.binaryReader.BaseStream.Position }); } result = null; return(false); } switch (((flags >> 2) & 3)) { case 0: if (this.ReadInlineNonDynamicObject(flags, out result)) { break; } return(false); case 1: if (log.IsDebugEnabled) { log.DebugFormat("Externalizable object is not supported, at position {0}", new object[] { this.binaryReader.BaseStream.Position }); } result = null; return(false); case 2: if (this.ReadInlineDynamicObject(out result)) { break; } return(false); default: if (log.IsDebugEnabled) { log.DebugFormat("Invalid amf3 object format, at position {0}", new object[] { this.binaryReader.BaseStream.Position }); } result = null; return(false); } this.objectReferences.Add(result); return(true); }