コード例 #1
0
ファイル: RegistryProvider.cs プロジェクト: Lawo/ember-plus
        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);
        }
コード例 #2
0
        public void Write(GlowContainer glow)
        {
            var output = CreateOutput();

            glow.Encode(output);

            output.Finish();
        }
コード例 #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);
        }
コード例 #4
0
        /// <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);
        }
コード例 #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();
        }
コード例 #6
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();
        }
コード例 #7
0
ファイル: Program.cs プロジェクト: jv42/ember-plus
        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();
        }
コード例 #8
0
ファイル: Program.cs プロジェクト: jv42/ember-plus
        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!");
        }
コード例 #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);
                }
            }
        }
コード例 #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!");
            }
        }
コード例 #11
0
 public GlowRootReadyArgs(GlowContainer root, Client sourceClient)
 {
     Root         = root;
     SourceClient = sourceClient;
 }
コード例 #12
0
 public GlowFromProviderReadyArgs(GlowContainer root)
 {
     Root = root;
 }
コード例 #13
0
ファイル: Client.cs プロジェクト: jv42/ember-plus
        public void Write(GlowContainer glow)
        {
            var output = CreateOutput();

             glow.Encode(output);

             output.Finish();
        }
コード例 #14
0
 string GetGlowXml(GlowContainer glow)
 {
     return(GetXmlBody(writer => GlowXmlExport.Export(glow, writer)));
 }
コード例 #15
0
ファイル: MainPage.xaml.cs プロジェクト: jv42/ember-plus
        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();
        }
コード例 #16
0
ファイル: Program.cs プロジェクト: jv42/ember-plus
 string GetGlowXml(GlowContainer glow)
 {
     return GetXmlBody(writer => GlowXmlExport.Export(glow, writer));
 }