public void RegisterCondition (string id, ConditionType type) { type.Id = id; ConditionInfo info = CreateConditionInfo (id); ConditionType ot = info.CondType as ConditionType; if (ot != null) ot.Changed -= new EventHandler (OnConditionChanged); info.CondType = type; type.Changed += new EventHandler (OnConditionChanged); }
public override bool Evaluate(ExtensionContext ctx) { if (!base.Evaluate(ctx)) { return(false); } ConditionType type = ctx.GetCondition(typeId); if (type == null) { AddinManager.ReportError("Condition '" + typeId + "' not found in current extension context.", null, null, false); return(false); } try { return(type.Evaluate(node)); } catch (Exception ex) { AddinManager.ReportError("Error while evaluating condition '" + typeId + "'", null, ex, false); return(false); } }
void OnConditionChanged(object s, EventArgs a) { ConditionType cond = (ConditionType)s; NotifyConditionChanged(cond); }
internal void NotifyConditionChanged (ConditionType cond) { try { fireEvents = true; ConditionInfo info = (ConditionInfo) conditionTypes [cond.Id]; if (info != null && info.BoundConditions != null) { Hashtable parentsToNotify = new Hashtable (); foreach (BaseCondition c in info.BoundConditions) { ArrayList nodeList = (ArrayList) conditionsToNodes [c]; if (nodeList != null) { foreach (TreeNode node in nodeList) parentsToNotify [node.Parent] = null; } } foreach (TreeNode node in parentsToNotify.Keys) { if (node.NotifyChildrenChanged ()) NotifyExtensionsChanged (new ExtensionEventArgs (node.GetPath ())); } } } finally { fireEvents = false; } // Notify child contexts lock (conditionTypes) { if (childContexts != null) { foreach (WeakReference wref in childContexts) { ExtensionContext ctx = wref.Target as ExtensionContext; if (ctx != null) ctx.NotifyConditionChanged (cond); } } } }