GlowContainer ConvertQualifiedFunction(XElement xml) { var glow = new GlowQualifiedFunction(ConvertPath(xml.Attribute("path").Value)); FillFunction(glow, xml); return(glow); }
object IGlowVisitor <XmlWriter, object> .Visit(GlowQualifiedFunction glow, XmlWriter state) { state.WriteStartElement("QualifiedFunction"); state.WriteAttributeString("path", ConvertPath(glow.Path)); ConvertFunction(glow, state); state.WriteEndElement(); return(null); }
bool IGlowVisitor <object, bool> .Visit(GlowQualifiedFunction glow, object state) { if (_onFunction != null) { _onFunction(glow); return(true); } return(false); }
GlowContainer IElementVisitor <ElementToGlowOptions, GlowContainer> .Visit(Function element, ElementToGlowOptions state) { var glow = new GlowQualifiedFunction(element.Path); var dirFieldMask = state.DirFieldMask; if (dirFieldMask.HasBits(GlowFieldFlags.Identifier)) { glow.Identifier = element.Identifier; } if (dirFieldMask.HasBits(GlowFieldFlags.Description) && String.IsNullOrEmpty(element.Description) == false) { glow.Description = element.Description; } if (dirFieldMask == GlowFieldFlags.All) { if (element.Arguments != null) { var tupleItemDescs = from tuple in element.Arguments select new GlowTupleItemDescription(tuple.Item2) { Name = tuple.Item1 }; var arguments = glow.EnsureArguments(); foreach (var tupleItemDesc in tupleItemDescs) { arguments.Insert(tupleItemDesc); } } if (element.Result != null) { var tupleItemDescs = from tuple in element.Result select new GlowTupleItemDescription(tuple.Item2) { Name = tuple.Item1 }; var result = glow.EnsureResult(); foreach (var tupleItemDesc in tupleItemDescs) { result.Insert(tupleItemDesc); } } } return(glow); }
public GlowContainer Visit(GlowQualifiedFunction glow, object state) { var newPath = PrependPathWithEndPointNumber(glow.Path); var newQualified = new GlowQualifiedFunction(newPath); foreach (var ember in glow) { if (ember.Tag != GlowTags.QualifiedMatrix.Path) { newQualified.Insert(ember); } } return(newQualified); }
public IEnumerable <GlowContainer> Visit(GlowQualifiedFunction glow, object state) { EndPointNumber = glow.Path[0]; var newPath = glow.Path.Skip(1).ToArray(); var newQualified = new GlowQualifiedFunction(newPath); foreach (var ember in glow) { if (ember.Tag != GlowTags.QualifiedFunction.Path) { newQualified.Insert(ember); } } yield return(newQualified); }
bool IGlowVisitor <object, bool> .Visit(GlowQualifiedFunction glow, object state) { return(false); }
GlowContainer ConvertQualifiedFunction(XElement xml) { var glow = new GlowQualifiedFunction(ConvertPath(xml.Attribute("path").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); }