Exemplo n.º 1
0
        public TestClass()
        {
            SBC    = new Engine.Files.SerialBinary.SerialBinaryCompound(this);
            stream = new System.IO.MemoryStream();

            b1   = true;
            i1   = 10;
            fa1  = new float[] { 5.5f, 7.7f, 9.9f };
            ls1  = new List <short>(new short[] { 15, 20 });
            str1 = "Hello!";
            ls2  = new List <string>(new string[] { "World", "in", "danger" });

            SBC.addElement(() => b1);
            SBC.addElement(() => i1);
            SBC.addElement(() => fa1);
            SBC.addElement(() => ls1);
            SBC.addElement(() => str1);
            SBC.addElement(() => ls2);

            SBC.writeCompound(new System.IO.BinaryWriter(stream));

            b1   = false;
            i1   = 7;
            fa1  = new float[] { 3.0f };
            ls1  = new List <short>(new short[] { 56, 90 });
            str1 = "Byeeeeee!";
            ls2  = new List <string>(new string[] { "Nope so", "well", "in pocket" });
        }
Exemplo n.º 2
0
        public static SerialBinaryCompound createSBCompound(this IBinarySerializable bs)
        {
            if (!compounds.ContainsKey(bs.GetType()))
            {
                SerialBinaryCompound c = new SerialBinaryCompound(bs);
                compounds.Add(bs.GetType(), c);
                return(c);
            }

            throw new Exception("Compound already created!");
        }