public static CA.IRule GetProxy(GF.IRule rule)
        {
            if (!boundProxies.ContainsKey(rule))
            {
                throw new ArgumentException(AddinCatalog.GetString("{0} rule has not been cached but it should.", rule), "rule");
            }

            return(boundProxies [rule]);
        }
示例#2
0
		internal GendarmeRule (GF.IRule rule)
		{
			this.rule = rule;
			
			object [] attrs = rule.GetType ().GetCustomAttributes (typeof (GF.ProblemAttribute), false);
			if (attrs == null || attrs.Length == 0)
				return;
			
			GF.ProblemAttribute problem = (GF.ProblemAttribute) attrs [0];
			description = problem.Problem;
		}
示例#3
0
        internal GendarmeRule(GF.IRule rule)
        {
            this.rule = rule;

            object [] attrs = rule.GetType().GetCustomAttributes(typeof(GF.ProblemAttribute), false);
            if (attrs == null || attrs.Length == 0)
            {
                return;
            }

            GF.ProblemAttribute problem = (GF.ProblemAttribute)attrs [0];
            description = problem.Problem;
        }
        public static CA.IRule CreateOrGetProxy(Type ruleType)
        {
            if (!Utilities.IsGendarmeRule(ruleType))
            {
                throw new ArgumentException(AddinCatalog.GetString("{0} is not a rule type because it does not implement IRule interface.",
                                                                   ruleType), "ruleType");
            }

            if (!cachedRules.ContainsKey(ruleType))
            {
                // create `real' rule and cache it
                GF.IRule rule = (GF.IRule)Activator.CreateInstance(ruleType);
                cachedRules.Add(ruleType, rule);
                // create a proxy and cache it
                GendarmeRule proxy = new GendarmeRule(rule);
                boundProxies.Add(rule, proxy);
                return(proxy);
            }
            else
            {
                // return from cache
                return(boundProxies [cachedRules [ruleType]]);
            }
        }