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); }
bool IGlowVisitor <object, bool> .Visit(GlowFunction glow, object state) { if (_onFunction != null) { _onFunction(glow); return(true); } return(false); }
bool IGlowVisitor <object, bool> .Visit(GlowFunction glow, object state) { return(false); }
public IEnumerable <GlowContainer> Visit(GlowFunction glow, object state) { throw new NotImplementedException(); }
public GlowContainer Visit(GlowFunction glow, object state) { return(WrapWithEndPointNode(glow)); }
GlowContainer ConvertFunction(XElement xml) { var glow = new GlowFunction(XmlConvert.ToInt32(xml.Attribute("number").Value)); FillFunction(glow, xml); return glow; }
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); }
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); }