public override void WriteObject(AMFObject value)
        {
            WriteMarker(AMF3Marker.Object);
            var idx = ObjectIndex(value);

            if (idx.HasValue)
            {
                WriteUI29((idx.Value << 1) | 0);
                return;
            }
            var klass = value.Class;

            idx = ClassIndex(klass);
            if (idx.HasValue)
            {
                WriteUI29((idx.Value << 2) | 0x01);
            }
            else
            {
                WriteUI29(
                    ((klass.IsDynamic ? 1 : 0) << 3) |
                    (klass.Traits.Count() << 4) |
                    0x03);
                WriteStringValue(klass.Name);
                foreach (var name in klass.Traits)
                {
                    WriteStringValue(name);
                }
            }
            foreach (var name in klass.Traits)
            {
                WriteValue(value[name]);
            }
            if (klass.IsDynamic)
            {
                foreach (var name in value.Data.Keys.Where(name => !klass.Traits.Contains(name)))
                {
                    WriteStringValue(name);
                    WriteValue(value[name]);
                }
                WriteStringValue("");
            }
        }
Beispiel #2
0
        public override void WriteObject(AMFObject value)
        {
            var index = ObjectIndex(value);

            if (index.HasValue)
            {
                WriteReference(index.Value);
                return;
            }
            if (String.IsNullOrEmpty(value.Class.Name))
            {
                WriteMarker(AMF0Marker.Object);
                WriteProperties(value.Data);
            }
            else
            {
                WriteMarker(AMF0Marker.TypedObject);
                WriteStringValue(value.Class.Name);
                WriteProperties(value.Data);
            }
        }
Beispiel #3
0
 public abstract void WriteObject(AMFObject value);
Beispiel #4
0
 public AMFValue(AMFObject value)
 {
     Type  = AMFValueType.Object;
     Value = value;
 }
Beispiel #5
0
 public void Add(string key, AMFObject value)
 {
     this.Add(key, new AMFValue(value));
 }