GlowContainer ConvertFunction(XElement xml)
        {
            var glow = new GlowFunction(XmlConvert.ToInt32(xml.Attribute("number").Value));

            FillFunction(glow, xml);
            return(glow);
        }
        object IGlowVisitor <XmlWriter, object> .Visit(GlowFunction glow, XmlWriter state)
        {
            state.WriteStartElement("Function");
            state.WriteAttributeString("number", XmlConvert.ToString(glow.Number));

            ConvertFunction(glow, state);

            state.WriteEndElement();
            return(null);
        }
Exemplo n.º 3
0
        bool IGlowVisitor <object, bool> .Visit(GlowFunction glow, object state)
        {
            if (_onFunction != null)
            {
                _onFunction(glow);
                return(true);
            }

            return(false);
        }
Exemplo n.º 4
0
 bool IGlowVisitor <object, bool> .Visit(GlowFunction glow, object state)
 {
     return(false);
 }
Exemplo n.º 5
0
 public IEnumerable <GlowContainer> Visit(GlowFunction glow, object state)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 6
0
 public GlowContainer Visit(GlowFunction glow, object state)
 {
     return(WrapWithEndPointNode(glow));
 }
Exemplo n.º 7
0
 GlowContainer ConvertFunction(XElement xml)
 {
     var glow = new GlowFunction(XmlConvert.ToInt32(xml.Attribute("number").Value));
      FillFunction(glow, xml);
      return glow;
 }
Exemplo n.º 8
0
        void Test_Functions()
        {
            Action <EmberSequence, string> fillTupleDescription =
                (sequence, namePrefix) =>
            {
                sequence.Insert(new GlowTupleItemDescription(GlowParameterType.Integer)
                {
                    Name = namePrefix + "1:integer"
                });
                sequence.Insert(new GlowTupleItemDescription(GlowParameterType.Boolean)
                {
                    Name = namePrefix + "2:boolean"
                });
                sequence.Insert(new GlowTupleItemDescription(GlowParameterType.Octets)
                {
                    Name = namePrefix + "3:octets"
                });
                sequence.Insert(new GlowTupleItemDescription(GlowParameterType.Real)
                {
                    Name = namePrefix + "4:real"
                });
                sequence.Insert(new GlowTupleItemDescription(GlowParameterType.String)
                {
                    Name = namePrefix + "5:string"
                });
            };

            // --------------- Invocation Command
            var glowCommand = new GlowCommand(GlowCommandType.Invoke)
            {
                Invocation = new GlowInvocation(GlowTags.Command.Invocation)
                {
                    InvocationId = 123,
                },
            };

            var argsTuple = glowCommand.Invocation.EnsureArguments();

            argsTuple.Insert(new IntegerEmberLeaf(GlowTags.CollectionItem, 456));
            argsTuple.Insert(new BooleanEmberLeaf(GlowTags.CollectionItem, true));
            argsTuple.Insert(new OctetStringEmberLeaf(GlowTags.CollectionItem, new byte[] { 250, 251, 253 }));
            argsTuple.Insert(new RealEmberLeaf(GlowTags.CollectionItem, 123.321));
            argsTuple.Insert(new StringEmberLeaf(GlowTags.CollectionItem, "hallo"));

            AssertCodecSanity(glowCommand);
            Console.WriteLine(GetGlowXml(glowCommand));

            // --------------- Function
            var glowFunction = new GlowFunction(100)
            {
                Identifier  = "testFunction",
                Description = "Test Function",
            };

            fillTupleDescription(glowFunction.EnsureArguments(), "arg");
            fillTupleDescription(glowFunction.EnsureResult(), "res");
            glowFunction.EnsureChildren().Insert(glowCommand);

            AssertCodecSanity(glowFunction);
            Console.WriteLine(GetXml(glowFunction));

            // --------------- QualifiedFunction
            var glowQualifiedFunction = new GlowQualifiedFunction(new[] { 1, 2, 3 })
            {
                Identifier  = "testFunction",
                Description = "Test Function",
            };

            fillTupleDescription(glowQualifiedFunction.EnsureArguments(), "arg");
            fillTupleDescription(glowQualifiedFunction.EnsureResult(), "res");
            glowQualifiedFunction.EnsureChildren().Insert(glowCommand);

            AssertCodecSanity(glowQualifiedFunction);
            Console.WriteLine(GetXml(glowQualifiedFunction));

            var glowRoot = GlowRootElementCollection.CreateRoot();

            glowRoot.Insert(glowQualifiedFunction);
            AssertGlowXmlSanity(glowRoot);

            // --------------- InvocationResult
            var glowInvocationResult = GlowInvocationResult.CreateRoot(glowCommand.Invocation.InvocationId.Value);
            var resTuple             = glowInvocationResult.EnsureResult();

            resTuple.Insert(new IntegerEmberLeaf(GlowTags.CollectionItem, 456));
            resTuple.Insert(new BooleanEmberLeaf(GlowTags.CollectionItem, true));
            resTuple.Insert(new OctetStringEmberLeaf(GlowTags.CollectionItem, new byte[] { 250, 251, 253 }));
            resTuple.Insert(new RealEmberLeaf(GlowTags.CollectionItem, 123.321));
            resTuple.Insert(new StringEmberLeaf(GlowTags.CollectionItem, "hallo"));

            AssertCodecSanity(glowInvocationResult);
            Console.WriteLine(GetXml(glowInvocationResult));

            AssertGlowXmlSanity(glowInvocationResult);
        }
Exemplo n.º 9
0
        void Test_Functions()
        {
            Action<EmberSequence, string> fillTupleDescription =
            (sequence, namePrefix) =>
            {
               sequence.Insert(new GlowTupleItemDescription(GlowParameterType.Integer) { Name = namePrefix + "1:integer" });
               sequence.Insert(new GlowTupleItemDescription(GlowParameterType.Boolean) { Name = namePrefix + "2:boolean" });
               sequence.Insert(new GlowTupleItemDescription(GlowParameterType.Octets) { Name = namePrefix + "3:octets" });
               sequence.Insert(new GlowTupleItemDescription(GlowParameterType.Real) { Name = namePrefix + "4:real" });
               sequence.Insert(new GlowTupleItemDescription(GlowParameterType.String) { Name = namePrefix + "5:string" });
            };

             // --------------- Invocation Command
             var glowCommand = new GlowCommand(GlowCommandType.Invoke)
             {
            Invocation = new GlowInvocation(GlowTags.Command.Invocation)
            {
               InvocationId = 123,
            },
             };

             var argsTuple = glowCommand.Invocation.EnsureArguments();
             argsTuple.Insert(new IntegerEmberLeaf(GlowTags.CollectionItem, 456));
             argsTuple.Insert(new BooleanEmberLeaf(GlowTags.CollectionItem, true));
             argsTuple.Insert(new OctetStringEmberLeaf(GlowTags.CollectionItem, new byte[] { 250, 251, 253 }));
             argsTuple.Insert(new RealEmberLeaf(GlowTags.CollectionItem, 123.321));
             argsTuple.Insert(new StringEmberLeaf(GlowTags.CollectionItem, "hallo"));

             AssertCodecSanity(glowCommand);
             Console.WriteLine(GetGlowXml(glowCommand));

             // --------------- Function
             var glowFunction = new GlowFunction(100)
             {
            Identifier = "testFunction",
            Description = "Test Function",
             };

             fillTupleDescription(glowFunction.EnsureArguments(), "arg");
             fillTupleDescription(glowFunction.EnsureResult(), "res");
             glowFunction.EnsureChildren().Insert(glowCommand);

             AssertCodecSanity(glowFunction);
             Console.WriteLine(GetXml(glowFunction));

             // --------------- QualifiedFunction
             var glowQualifiedFunction = new GlowQualifiedFunction(new[] { 1, 2, 3 })
             {
            Identifier = "testFunction",
            Description = "Test Function",
             };

             fillTupleDescription(glowQualifiedFunction.EnsureArguments(), "arg");
             fillTupleDescription(glowQualifiedFunction.EnsureResult(), "res");
             glowQualifiedFunction.EnsureChildren().Insert(glowCommand);

             AssertCodecSanity(glowQualifiedFunction);
             Console.WriteLine(GetXml(glowQualifiedFunction));

             var glowRoot = GlowRootElementCollection.CreateRoot();
             glowRoot.Insert(glowQualifiedFunction);
             AssertGlowXmlSanity(glowRoot);

             // --------------- InvocationResult
             var glowInvocationResult = GlowInvocationResult.CreateRoot(glowCommand.Invocation.InvocationId.Value);
             var resTuple = glowInvocationResult.EnsureResult();
             resTuple.Insert(new IntegerEmberLeaf(GlowTags.CollectionItem, 456));
             resTuple.Insert(new BooleanEmberLeaf(GlowTags.CollectionItem, true));
             resTuple.Insert(new OctetStringEmberLeaf(GlowTags.CollectionItem, new byte[] { 250, 251, 253 }));
             resTuple.Insert(new RealEmberLeaf(GlowTags.CollectionItem, 123.321));
             resTuple.Insert(new StringEmberLeaf(GlowTags.CollectionItem, "hallo"));

             AssertCodecSanity(glowInvocationResult);
             Console.WriteLine(GetXml(glowInvocationResult));

             AssertGlowXmlSanity(glowInvocationResult);
        }