public EvaluationResult evaluateExpression(XmlElement expressionDoc, IContext context) { // first deserialize expression into a RequiresParticipants instance RequiresParticipants expression = null; try { XmlNodeReader reader = new XmlNodeReader(expressionDoc); expression = (RequiresParticipants)serializer.Deserialize(reader); } catch (Exception e) { throw new PolicyManagerException("Could not deserialize RequiresParticipants node", e); } // go through and check if all participants listed in the policy are in the meeting foreach (string participant in expression.Participant) { if (context.Participants[participant] == null) { // return "false" as the evaluation result return(new EvaluationResult(TAG, false, "Participant " + participant + " not in context")); } } // if we got here, it means all participants were found return(new EvaluationResult(TAG, true, "All participants found in context")); }
public static void Main(String[] args) { RequiresTopic rt = new RequiresTopic(); rt.Topic = "foobar"; RequiresParticipants rp = new RequiresParticipants(); rp.Participant = new String[] { "joe", "bob" }; All all = new All(); all.Any = new XmlElement[] { Util.getXmlElement(rt), Util.getXmlElement(rp) }; Policy policy = new Policy(); policy.Any = Util.getXmlElement(all); StreamWriter writer = new StreamWriter("testpolicy2.xml"); Util.serialize(policy, writer); writer.Close(); Console.Out.WriteLine("done"); }