示例#1
0
        IEnumerable <IMatcher> ListMatchers(MatcherKind kind, IWarningLogger log)
        {
            mlist_had_error = false;

            foreach (Type t in VisibleTypes)
            {
                object[] attrs = t.GetCustomAttributes(typeof(MatcherAttribute), false);

                if (attrs == null || attrs.Length == 0)
                {
                    continue;
                }

                if (((MatcherAttribute)attrs[0]).Kind != kind)
                {
                    continue;
                }

                object o;

                if (InstantiateBoundType(t, out o, log))
                {
                    mlist_had_error = true;
                    yield break;
                }

                yield return((IMatcher)o);
            }
        }
示例#2
0
 private MatcherInfo(MatcherKind kind, Type argType, int argPosition, string argName, string expressionString)
 {
     this.Kind             = kind;
     this.ArgType          = argType;
     this.ArgPosition      = argPosition;
     this.ArgName          = argName;
     this.ExpressionString = expressionString;
 }
示例#3
0
        public bool TryMatch(string name, MatcherKind kind, out TargetTemplate tmpl, IWarningLogger log)
        {
            tmpl = null;
            IMatcher which   = null;
            int      quality = 0;

            IEnumerable <IMatcher> mlist = GetMatchers(kind, log);

            if (mlist == null)
            {
                return(true);
            }

            foreach (IMatcher m in mlist)
            {
                int            q;
                TargetTemplate match = m.TryMatch(name, out q);

                if (match == null)
                {
                    continue;
                }

                if (q < quality)
                {
                    continue;
                }

                if (tmpl != null && q == quality)
                {
                    // FIXME: provide a way to specify which one should take priority!
                    string s = String.Format("Two matches succeed with equal quality: " +
                                             "{0} and {1}; going with the first",
                                             which, m);
                    log.Warning(2026, s, name);
                    break;
                }

                which   = m;
                tmpl    = match;
                quality = q;
            }

            return(false);
        }
示例#4
0
        public override IEnumerable <IMatcher> GetMatchers(MatcherKind kind, IWarningLogger log)
        {
            if (bm == null)
            {
                throw new Exception("Need to set manager before performing type lookup.");
            }

            if (!matchers.ContainsKey(kind))
            {
                mlist_had_error = false;
                matchers[kind]  = new List <IMatcher> (ListMatchers(kind, log));

                if (mlist_had_error)
                {
                    matchers[kind] = null;
                    return(null);
                }
            }

            return(matchers[kind]);
        }
示例#5
0
	public bool TryMatch (string name, MatcherKind kind, out TargetTemplate tmpl, IWarningLogger log) 
	{
	    tmpl = null;
	    IMatcher which = null;
	    int quality = 0;
	    
	    IEnumerable<IMatcher> mlist = GetMatchers (kind, log);

	    if (mlist == null)
		return true;

	    foreach (IMatcher m in mlist) {
		int q;
		TargetTemplate match = m.TryMatch (name, out q);

		if (match == null)
		    continue;
		
		if (q < quality)
		    continue;
		
		if (tmpl != null && q == quality) {
		    // FIXME: provide a way to specify which one should take priority!
		    string s = String.Format ("Two matches succeed with equal quality: " + 
		    			      "{0} and {1}; going with the first",
		    			      which, m);
		    log.Warning (2026, s, name);
		    break;
		}
		
		which = m;
		tmpl = match;
		quality = q;
	    }
	    
	    return false;
	}
示例#6
0
	public abstract IEnumerable<IMatcher> GetMatchers (MatcherKind kind, IWarningLogger log);
示例#7
0
 public abstract IEnumerable <IMatcher> GetMatchers(MatcherKind kind, IWarningLogger log);
示例#8
0
	IEnumerable<IMatcher> ListMatchers (MatcherKind kind, IWarningLogger log)
	{
	    mlist_had_error = false;

	    foreach (Type t in VisibleTypes) {
		object[] attrs = t.GetCustomAttributes (typeof (MatcherAttribute), false);

		if (attrs == null || attrs.Length == 0)
		    continue;

		if (((MatcherAttribute) attrs[0]).Kind != kind)
		    continue;

		object o;

		if (InstantiateBoundType (t, out o, log)) {
		    mlist_had_error = true;
		    yield break;
		}

		yield return (IMatcher) o;
	    }
	}
示例#9
0
	public override IEnumerable<IMatcher> GetMatchers (MatcherKind kind, IWarningLogger log)
	{
	    if (bm == null)
		throw new Exception ("Need to set manager before performing type lookup.");

	    if (!matchers.ContainsKey (kind)) {
		mlist_had_error = false;
		matchers[kind] = new List<IMatcher> (ListMatchers (kind, log));

		if (mlist_had_error) {
		    matchers[kind] = null;
		    return null;
		}
	    }

	    return matchers[kind];
	}
示例#10
0
	public MatcherAttribute (MatcherKind kind)
	{
	    this.kind = kind;
	}
示例#11
0
 public MatcherAttribute(MatcherKind kind)
 {
     this.kind = kind;
 }