Exemple #1
0
        public static void Main(string[] args)
        {
            AbcaFileCodec codec = new AbcaFileCodec
            {
                Header = new EsfHeader
                {
                    ID = 0xABCA
                }
            };
            RecordNode root = new RecordNode(codec)
            {
                Name = "root"
            };
            RecordNode child = new RecordNode(codec)
            {
                Name = "copySource"
            };
            EsfValueNode <string> utf16String = (EsfValueNode <string>)codec.CreateValueNode(EsfType.UTF16);

            utf16String.Value = "utf16";
            child.Value.Add(utf16String);
            root.Value.Add(child);
            child = new RecordNode(codec)
            {
                Name = "copyTarget"
            };
            EsfValueNode <string> copyString = (EsfValueNode <string>)utf16String.CreateCopy();

            // copyString.Value = "copy";
            copyString.FromString("copy");
            child.Value.Add(copyString);
            root.Value.Add(child);

            // this is needed for the file to create the record nodes properly
            SortedList <int, string> nodeNames = new SortedList <int, string>();

            nodeNames.Add(0, "root");
            nodeNames.Add(1, "copySource");
            nodeNames.Add(2, "copyTarget");
            // this property needs to be added to the EsfFileCodec, getting and setting EsfFileCodec#nodeNames
            codec.NodeNames = nodeNames;

            EsfFile file = new EsfFile(root, codec);

            EsfCodecUtil.WriteEsfFile("string_container.esf", file);
        }
Exemple #2
0
        public void TestEquals()
        {
            EsfNode valueNode = new IntNode {
                Value = 1
            };
            EsfNode valueNode2 = new IntNode {
                Value = 1
            };

            assertEqual(valueNode, valueNode2);

            List <EsfNode> nodeList1 = new List <EsfNode>();

            nodeList1.Add(valueNode);
            List <EsfNode> nodeList2 = new List <EsfNode>();

            nodeList2.Add(valueNode);
            RecordNode node = new RecordNode(null)
            {
                Name = "name", Value = nodeList1
            };
            EsfNode node2 = new RecordNode(null)
            {
                Name = "nodename", Value = nodeList2
            };

            assertNotEqual(node, node2);
            node = new RecordNode(null)
            {
                Name = "nodename", Value = nodeList1
            };
            assertEqual(node, node2);

            AbcaFileCodec codec  = new AbcaFileCodec();
            EsfFile       file   = new EsfFile(node, codec);
            AbceCodec     codec2 = new AbceCodec();
            EsfFile       file2  = new EsfFile(node2, codec2);

            assertNotEqual(file, file2);
            file2.Codec = codec;
            assertEqual(file, file2);
        }