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);
        }
示例#3
0
        bool IGlowVisitor <object, bool> .Visit(GlowFunction glow, object state)
        {
            if (_onFunction != null)
            {
                _onFunction(glow);
                return(true);
            }

            return(false);
        }
示例#4
0
文件: Model.cs 项目: scy/ember-plus
 bool IGlowVisitor <object, bool> .Visit(GlowFunction glow, object state)
 {
     return(false);
 }
示例#5
0
 public IEnumerable <GlowContainer> Visit(GlowFunction glow, object state)
 {
     throw new NotImplementedException();
 }
示例#6
0
 public GlowContainer Visit(GlowFunction glow, object state)
 {
     return(WrapWithEndPointNode(glow));
 }
示例#7
0
 GlowContainer ConvertFunction(XElement xml)
 {
     var glow = new GlowFunction(XmlConvert.ToInt32(xml.Attribute("number").Value));
      FillFunction(glow, xml);
      return glow;
 }
示例#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);
        }
示例#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);
        }