Esempio n. 1
0
 // release a property reader back to the pool
 public void ReleasePropertyReader(Amf3Reader reader)
 {
     reader.EndRead();
     // add reader to pool
     reader.NextReader = mReaderPool;
     mReaderPool       = reader;
 }
Esempio n. 2
0
            public void ReadObject(Amf3Reader reader, object obj)
            {
                var amfObj = (Amf3Object)obj;

                reader.ReadObjectHeader(amfObj.ClassDef);

                // read class properties
                for (int i = 0; i < amfObj.Values.Length; i++)
                {
                    reader.Read(ref amfObj.Values[i]);
                }
            }
        public void ReadObject(Amf3Reader reader, object obj)
        {
            var expando = (ExpandoObject)obj;

            reader.ReadObjectHeader();

            // read class properties
            while (!reader.Done)
            {
                string name  = reader.Name;
                object value = reader.ReadAsObject();
                expando[name] = value;
            }
        }
Esempio n. 4
0
        // creates a property reader that can read ordered or named properties from an amf stream
        public Amf3Reader CreatePropertyReader()
        {
            var reader = mReaderPool;

            if (reader == null)
            {
                // create new property reader if pool is empty
                reader = new Amf3Reader(this);
                return(reader);
            }

            // use next property reader from pool
            mReaderPool = mReaderPool.NextReader;
            return(reader);
        }
        public void ReadObject(Amf3Reader reader, object obj)
        {
            // see if object implements IAmf3Readable, if so, use it instead of reflection
            var serializable = obj as IAmf3Readable;

            if (serializable != null)
            {
                // read using custom method (fast)
                serializable.Serialize(reader);
                return;
            }

            // read using reflection (slow)
            // begin read
            reader.ReadObjectHeader(mClassDef);

            // read all fields using reflection
            foreach (var field in mFieldList)
            {
                // read value
                Variant value = reader.ReadAsVariant();
                if (value.IsDefined)
                {
                    field.SetValue(obj, value.AsType(field.FieldType));
                }
            }

            // read all properties using reflection
            foreach (var property in mPropertyList)
            {
                // read value
                Variant value = reader.ReadAsVariant();
                if (value.IsDefined)
                {
                    property.SetValue(obj, value.AsType(property.PropertyType), null);
                }
            }
        }