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); } }
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; }
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); }
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]); }
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; }
public abstract IEnumerable<IMatcher> GetMatchers (MatcherKind kind, IWarningLogger log);
public abstract IEnumerable <IMatcher> GetMatchers(MatcherKind kind, IWarningLogger log);
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; } }
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]; }
public MatcherAttribute (MatcherKind kind) { this.kind = kind; }
public MatcherAttribute(MatcherKind kind) { this.kind = kind; }