Пример #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)
            {
                addinEngine.ReportError("Condition '" + typeId + "' not found in current extension context.", null, null, false);
                return(false);
            }

            try {
                return(type.Evaluate(node));
            }
            catch (Exception ex) {
                addinEngine.ReportError("Error while evaluating condition '" + typeId + "'", null, ex, false);
                return(false);
            }
        }
Пример #2
0
        internal ConditionType GetCondition(string id)
        {
            ConditionType ct;
            ConditionInfo info = (ConditionInfo)conditionTypes [id];

            if (info != null)
            {
                if (info.CondType is Type)
                {
                    // The condition was registered as a type, create an instance now
                    ct            = (ConditionType)Activator.CreateInstance((Type)info.CondType);
                    ct.Id         = id;
                    ct.Changed   += new EventHandler(OnConditionChanged);
                    info.CondType = ct;
                }
                else
                {
                    ct = info.CondType as ConditionType;
                }

                if (ct != null)
                {
                    return(ct);
                }
            }

            if (parentContext != null)
            {
                return(parentContext.GetCondition(id));
            }
            else
            {
                return(null);
            }
        }
Пример #3
0
        public override bool Evaluate(ExtensionContext ctx)
        {
            if (!base.Evaluate(ctx))
            {
                return(false);
            }

            ConditionType type = ctx.GetCondition(typeId);

            if (type == null)
            {
                addinEngine.ReportError("Condition '" + typeId + "' not found in current extension context.", null, null, false);
                return(false);
            }

            try
            {
                return(type.Evaluate(node));
            }
            catch (Exception ex)
            {
                addinEngine.ReportError("Error while evaluating condition '" + typeId + "'", null, ex, false);
                return(false);
            }
        }
Пример #4
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);
            }
        }
Пример #5
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) {
				addinEngine.ReportError ("Condition '" + typeId + "' not found in current extension context.", null, null, false);
				return false;
			}
			
			try {
				return type.Evaluate (node);
			}
			catch (Exception ex) {
				addinEngine.ReportError ("Error while evaluating condition '" + typeId + "'", null, ex, false);
				return false;
			}
		}
		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;
			}
		}