public void EmitFunction() { var fso1 = new FinalStateObject() { Name = "J1", BaseDefinition = null }; var fso2 = new FinalStateObject() { Name = "J2", BaseDefinition = null }; var fpv = new FunctionPhysicalQuantity() { ArgumentList = "J1.pT > 20, ET > 0, J2", Name = "NTrack", RefersToObjects = new FinalStateObject[] { fso1, fso2 } }; var ms = new StringWriter(); fpv.Emit(ms); var text = ms.ToString().Trim(); Assert.AreEqual("atlas:functionQuantity0 rdf:type dfs:PhysicalQuantity ;\r\n dfs:refersToObject atlas:J1 , atlas:J2 ;\r\n dfs:hasQuantity \"NTrack(J1.pT > 20, ET > 0, J2)\" .", text); }
/// <summary> /// Dump out a function reference /// </summary> /// <param name="fv"></param> /// <param name="wr"></param> /// <returns></returns> public static string Emit(this FunctionPhysicalQuantity fv, TextWriter wr) { var name = MakeName("functionQuantity"); wr.WriteLine($"{OWLNamespace}:{name} rdf:type dfs:PhysicalQuantity ;"); wr.Write(" dfs:refersToObject "); bool first = true; foreach (var q in fv.RefersToObjects) { if (!first) { wr.Write(" , "); } first = false; wr.Write($"{OWLNamespace}:{q.Name}"); } wr.WriteLine(" ;"); wr.WriteLine($" dfs:hasQuantity \"{fv.Name}({fv.ArgumentList})\" ."); return(name); }
/// <summary> /// Return a function's referenced items. /// </summary> /// <param name="functionPhysicalQuantity"></param> /// <returns></returns> private IEnumerable <FinalStateObject> ExtractFSOReferences(FunctionPhysicalQuantity functionPhysicalQuantity) { return(functionPhysicalQuantity.RefersToObjects); }