Beispiel #1
0
        void Test_ReaderWriter()
        {
            var output = new BerMemoryOutput();
             var writer = new EmberWriter(output);

             writer.WriteSequenceBegin(new BerTag(DefaultClass, 1));

             for(uint index = 0; index <= 20; index++)
            writer.Write(new BerTag(DefaultClass, index + 111122), index);

             var oid = new int[100];
             for(int index = 0; index < oid.Length; index++)
            oid[index] = 1000 + index;

             writer.WriteRelativeOid(new BerTag(DefaultClass, 500000), oid);

             writer.WriteContainerEnd();

             Console.WriteLine("\r\n------------------------ Reader, Writer");

             var asyncReader = new AsyncDomReader(null);
             asyncReader.ReadBytes(output.Memory);

             var root = asyncReader.DetachRoot();
             Console.WriteLine(GetXml(root));
        }
Beispiel #2
0
        void GlowReader_RootReady(object sender, AsyncDomReader.RootReadyArgs e)
        {
            var root = e.Root as GlowContainer;

             if(root != null)
             {
            var buffer = new StringBuilder();
            var settings = new XmlWriterSettings
            {
               OmitXmlDeclaration = true,
               Indent = true,
               IndentChars = "  ",
            };

            using(var writer = XmlWriter.Create(Console.Out, settings))
               XmlExport.Export(root, writer);

            Registry.ReadGlow(root, this);
             }
             else
             {
            Console.WriteLine("Unexpected Ember Root: {0} ({1})", e.Root, e.Root.GetType());
             }
        }
Beispiel #3
0
        void Test_ReaderWriter()
        {
            var output = new BerMemoryOutput();
             var writer = new EmberWriter(output);

             writer.WriteFrameBegin();

             writer.WriteSequenceBegin(new BerTag(DefaultClass, 1));

             for(uint index = 0; index <= 100; index++)
            writer.Write(new BerTag(DefaultClass, index + 111122), index);

             writer.WriteContainerEnd();

             writer.WriteContainerEnd();

             Console.WriteLine("\r\n------------------------ Reader, Writer");

             var asyncReader = new AsyncDomReader(null);
             asyncReader.ReadBytes(output.Memory);
             DumpXml(asyncReader.DetachRoot());

             //var input = new BerMemoryInput(output.Memory);
             //var reader = new EmberReader(input);

             //var xmlBuffer = new StringBuilder();
             //var xmlSettings = new XmlWriterSettings
             //{
             //   OmitXmlDeclaration = true,
             //};

             //using(var xmlWriter = XmlWriter.Create(xmlBuffer, xmlSettings))
             //   EmberToXml(reader, xmlWriter);
             //Console.WriteLine(xmlBuffer.ToString());
        }