Esempio n. 1
0
        public void ReadGlow(GlowContainer glow, Client client)
        {
            var rootItem = new Item(null, _rootKey.Name, false, _rootKey);

             var walker = new Walker(this, client, rootItem);
             walker.Walk(glow);
        }
Esempio n. 2
0
        public void Write(GlowContainer glow)
        {
            var output = CreateOutput();

            glow.Encode(output);

            output.Finish();
        }
Esempio n. 3
0
        public void ReadGlow(GlowContainer glow, Client client)
        {
            var rootItem = new Item(null, _rootKey.Name, false, _rootKey);

            var walker = new Walker(this, client, rootItem);

            walker.Walk(glow);
        }
        /// <summary>
        /// Converts the glow tree with the root <paramref name="glow"/> to XML,
        /// writing the XML to <paramref name="writer"/>.
        /// </summary>
        /// <param name="glow">The root of the Glow tree to convert.</param>
        /// <param name="writer">The XmlWriter instance to write XML to.</param>
        public static void Export(GlowContainer glow, XmlWriter writer)
        {
            var instance = new GlowXmlExport();

            glow.Accept(instance, writer);

            writer.WriteWhitespace(Environment.NewLine);
        }
Esempio n. 5
0
        void Run(string path)
        {
            using (var stream = File.OpenRead(path))
            {
                var reader = new EmberReader(new BerStreamInput(stream));
                var app    = new GlowApplicationInterface();

                _glow = (GlowContainer)EmberNode.Decode(reader, app);
            }

            //var settings = new XmlWriterSettings
            //{
            //   Indent = true,
            //   IndentChars = "  ",
            //   OmitXmlDeclaration = true,
            //};
            //using(var writer = XmlWriter.Create(Console.Out, settings))
            //   XmlExport.Export(_glow, writer);

            //var children = _glow[GlowTags.CollectionItem][GlowTags.Node.Children];
            //for(int index = 0; index < 2000; index++)
            //{
            //   var node = new GlowNode(5 + index)
            //   {
            //      Identifier = "abc" + index,
            //      Description = "Hallo ich bin Node " + index,
            //   };
            //   children.Insert(node);
            //}

            //using(var output = new BerStreamOutput(File.Create("big.ember")))
            //   _glow.Encode(output);

            var listener = new TcpListener(IPAddress.Any, 9097);

            listener.Start();
            listener.BeginAcceptSocket(AcceptCallback, listener);

            Console.WriteLine("Press Enter to quit...");
            Console.ReadLine();

            lock (_sync)
            {
                foreach (var client in _clients)
                {
                    client.Close();
                }
            }

            listener.Stop();
        }
        void DecodeGlow(GlowContainer glow)
        {
            var buffer   = new StringBuilder();
            var settings = new XmlWriterSettings
            {
                OmitXmlDeclaration = true,
                Indent             = true,
                IndentChars        = "  ",
            };

            using (var writer = XmlWriter.Create(buffer, settings))
                GlowXmlExport.Export(glow, writer);

            XmlText = buffer.ToString();
        }
Esempio n. 7
0
        void Run(string path)
        {
            using(var stream = File.OpenRead(path))
             {
            var reader = new EmberReader(new BerStreamInput(stream));
            var app = new GlowApplicationInterface();

            _glow = (GlowContainer)EmberNode.Decode(reader, app);
             }

             //var settings = new XmlWriterSettings
             //{
             //   Indent = true,
             //   IndentChars = "  ",
             //   OmitXmlDeclaration = true,
             //};
             //using(var writer = XmlWriter.Create(Console.Out, settings))
             //   XmlExport.Export(_glow, writer);

             //var children = _glow[GlowTags.CollectionItem][GlowTags.Node.Children];
             //for(int index = 0; index < 2000; index++)
             //{
             //   var node = new GlowNode(5 + index)
             //   {
             //      Identifier = "abc" + index,
             //      Description = "Hallo ich bin Node " + index,
             //   };
             //   children.Insert(node);
             //}

             //using(var output = new BerStreamOutput(File.Create("big.ember")))
             //   _glow.Encode(output);

             var listener = new TcpListener(IPAddress.Any, 9097);
             listener.Start();
             listener.BeginAcceptSocket(AcceptCallback, listener);

             Console.WriteLine("Press Enter to quit...");
             Console.ReadLine();

             lock(_sync)
             {
            foreach(var client in _clients)
               client.Close();
             }

             listener.Stop();
        }
Esempio n. 8
0
        void AssertGlowXmlSanity(GlowContainer glow)
        {
            var originalXml = GetXml(glow);
             var glowXml = GetGlowXml(glow);

             GlowContainer decoded;

             using(var reader = new StringReader(glowXml))
             using(var xmlReader = XmlReader.Create(reader))
            decoded = GlowXmlImport.Import(xmlReader);

             var decodedXml = GetXml(decoded);

             if(originalXml != decodedXml)
            throw new Exception("Codec error!");
        }
Esempio n. 9
0
        public void DispatchGlow(GlowContainer glow, Provider.Client source)
        {
            var visitor = new ConsumerToProviderTranslator(_endPoints);
            var newGlow = glow.Accept(visitor, null).FirstOrDefault();

            if (newGlow != null)
            {
                if (visitor.EndPointNumber != null)
                {
                    // message to provider
                    var endPoint = (from ep in _endPoints
                                    where ep.LocalNumber == visitor.EndPointNumber.Value
                                    select ep)
                                   .FirstOrDefault();

                    if (endPoint.State == Consumer.GlowEndPointState.Connected ||
                        endPoint.State == Consumer.GlowEndPointState.ProtocolProbing)
                    {
                        endPoint.Write(newGlow);
                    }
                    else
                    {
                        // if endpoint is offline, and a dir command has been issued
                        // on the endpoint node (top-level node) -> send empty top-level node
                        if (newGlow is GlowRootElementCollection)
                        {
                            var command = newGlow.FirstOrDefault() as GlowCommand;

                            if (command != null &&
                                command.Number == GlowCommandType.GetDirectory)
                            {
                                var root = GlowRootElementCollection.CreateRoot();
                                root.Insert(new GlowNode(endPoint.LocalNumber));
                                source.Write(root);
                            }
                        }
                    }
                }
                else
                {
                    // message to proxy - usually command at root level
                    source.Write(newGlow);
                }
            }
        }
Esempio n. 10
0
        void AssertGlowXmlSanity(GlowContainer glow)
        {
            var originalXml = GetXml(glow);
            var glowXml     = GetGlowXml(glow);

            GlowContainer decoded;

            using (var reader = new StringReader(glowXml))
                using (var xmlReader = XmlReader.Create(reader))
                    decoded = GlowXmlImport.Import(xmlReader);

            var decodedXml = GetXml(decoded);

            if (originalXml != decodedXml)
            {
                throw new Exception("Codec error!");
            }
        }
 public GlowRootReadyArgs(GlowContainer root, Client sourceClient)
 {
     Root         = root;
     SourceClient = sourceClient;
 }
Esempio n. 12
0
 public GlowFromProviderReadyArgs(GlowContainer root)
 {
     Root = root;
 }
Esempio n. 13
0
        public void Write(GlowContainer glow)
        {
            var output = CreateOutput();

             glow.Encode(output);

             output.Finish();
        }
Esempio n. 14
0
 string GetGlowXml(GlowContainer glow)
 {
     return(GetXmlBody(writer => GlowXmlExport.Export(glow, writer)));
 }
Esempio n. 15
0
        void DecodeGlow(GlowContainer glow)
        {
            var buffer = new StringBuilder();
             var settings = new XmlWriterSettings
             {
            OmitXmlDeclaration = true,
            Indent = true,
            IndentChars = "  ",
             };

             using(var writer = XmlWriter.Create(buffer, settings))
            GlowXmlExport.Export(glow, writer);

             XmlText = buffer.ToString();
        }
Esempio n. 16
0
 string GetGlowXml(GlowContainer glow)
 {
     return GetXmlBody(writer => GlowXmlExport.Export(glow, writer));
 }