Exemplo n.º 1
0
        public AmfReader(BinaryReader reader, AmfRegistry registry)
        {
            _reader = reader;
            _registry = registry;

            _stringTable = new List<string>();
            _objectTable = new List<object>();
            _traitsTable = new List<AmfTraits>();
        }
Exemplo n.º 2
0
 public static object Read(AmfRegistry registry, byte[] encodedBytes)
 {
     using (MemoryStream stream = new MemoryStream(encodedBytes))
     {
         using (AmfReader reader = new AmfReader(new BinaryReader(stream), registry))
         {
             return reader.Read();
         }
     }
 }
Exemplo n.º 3
0
        public void TestObjectField()
        {
            AmfRegistry registry = new AmfRegistry();
            registry.RegisterClassAlias(typeof(A));
            registry.RegisterClassAlias(typeof(C));

            C c = new C();
            c.OtherClass = new A();

            C result = AmfReader.Read(registry, AmfWriter.Write(registry, c)) as C;

            Assert.IsTrue(result.OtherClass is A);
        }
Exemplo n.º 4
0
        public AmfWriter(BinaryWriter writer, AmfRegistry registry)
        {
            _writer = writer;
            _registry = registry;

            _stringTable = new Dictionary<string, int>();

            _idGenerator = new ObjectIDGenerator();
            _dateTimeTable = new Dictionary<DateTime, int>();
            _objectTable = new Dictionary<long, int>();

            _traitsTable = new Dictionary<long, int>();
        }
Exemplo n.º 5
0
        public void TestNesting()
        {
            AmfRegistry registry = new AmfRegistry();
            registry.RegisterClassAlias(typeof(A));
            registry.RegisterClassAlias(typeof(B));

            A a = new A();
            B b = new B();

            AmfArray array = AmfArray.Dense(a, b);

            object nullResult = AmfReader.Read(registry, AmfWriter.Write(registry, array));

            a.B = b;

            object nestedResult = AmfReader.Read(registry, AmfWriter.Write(registry, array));
        }
Exemplo n.º 6
0
        public static byte[] Write(AmfRegistry registry, object value)
        {
            using (MemoryStream stream = new MemoryStream())
            {
                using (AmfWriter writer = new AmfWriter(new BinaryWriter(stream), registry))
                {
                    writer.Write(value);

                    return stream.ToArray();
                }
            }
        }