Beispiel #1
0
        public override bool Evaluate(ExtensionContext ctx)
        {
            if (!base.Evaluate(ctx))
            {
                return(false);
            }

            if (!string.IsNullOrEmpty(addin))
            {
                // Make sure the add-in that implements the condition is loaded
                addinEngine.LoadAddin(null, addin, true);
                addin = null;                 // Don't try again
            }

            ConditionType type = ctx.GetCondition(typeId);

            if (type == null)
            {
                var parts = string.Join(", ", Array.ConvertAll(node.Attributes, attr => attr.Name + "=" + attr.Value));
                addinEngine.ReportError("Condition '" + typeId + "' not found in current extension context. [" + parts + "]", node.ParentAddinDescription.AddinId, null, false);
                return(false);
            }

            try {
                return(type.Evaluate(node));
            }
            catch (Exception ex) {
                addinEngine.ReportError("Error while evaluating condition '" + typeId + "'", node.ParentAddinDescription.AddinId, ex, false);
                return(false);
            }
        }