public void EndDeserialization(AmfTraits traits, object deserializingTo, IDictionary<string, object> staticMembers, IDictionary<string, object> dynamicMembers)
        {
            AmfObject obj = deserializingTo as AmfObject;

            foreach (KeyValuePair<string, object> pair in staticMembers)
            {
                obj.Properties[pair.Key] = pair.Value;
            }

            if (dynamicMembers != null)
            {
                foreach (KeyValuePair<string, object> pair in dynamicMembers)
                {
                    obj.Properties[pair.Key] = pair.Value;
                }
            }
        }
Example #2
0
        AmfTraits ReadObjectTraits(int argument)
        {
            bool isNonReferenceTrait = (argument & 1) == 1;

            int remainingArgument = argument >> 1;

            if (isNonReferenceTrait)
            {
                string className = ReadString();

                bool isExternalizable = (remainingArgument & 1) == 1;

                int traitArgument = remainingArgument >> 1;

                AmfTraits traits;

                if (isExternalizable)
                {
                    traits = new AmfTraits(className, AmfTraitsKind.Externalizable, new string[] { });
                }
                else
                {
                    bool isDynamic = (traitArgument & 1) == 1;
                    int memberCount = traitArgument >> 1;

                    string[] memberNames = new string[memberCount];

                    for (int i = 0; i < memberCount; i++)
                    {
                        memberNames[i] = ReadString();
                    }

                    traits = new AmfTraits(className, isDynamic ? AmfTraitsKind.Dynamic : AmfTraitsKind.Static, memberNames);
                }

                _traitsTable.Add(traits);

                return traits;
            }
            else
            {
                return _traitsTable[remainingArgument];
            }
        }
        public void SerializeObject(object value, out AmfTraits traits, out IDictionary<string, object> staticMembers, out IDictionary<string, object> dynamicMembers)
        {
            AmfObject obj = value as AmfObject;

            traits = _serializationTraits;
            staticMembers = null;
            dynamicMembers = obj.Properties;
        }
 public object BeginDeserialization(AmfTraits traits)
 {
     return new AmfObject();
 }
 internal AmfAnonymousClassDescriptor()
 {
     _serializationTraits = new AmfTraits("", AmfTraitsKind.Dynamic, new string[] { });
 }
Example #6
0
        void WriteObjectTraits(AmfTraits traits)
        {
            bool firstTime;

            long uniqueValue = _idGenerator.GetId(traits, out firstTime);

            if (!firstTime)
            {
                int argument = (_traitsTable[uniqueValue] << 2) | 0x01;
                WritePackedInteger(argument);
            }
            else
            {
                _traitsTable[uniqueValue] = _traitsTable.Count;

                if (traits.Kind == AmfTraitsKind.Externalizable) throw new NotImplementedException();

                int argument = (traits.MemberNames.Length << 4) | 0x03;

                if (traits.Kind == AmfTraitsKind.Dynamic) argument |= 0x08;

                WritePackedInteger(argument);
                WriteBareString(traits.ClassName);

                foreach (string memberName in traits.MemberNames)
                {
                    WriteBareString(memberName);
                }
            }
        }