public bool IsMatch(Type type) { if (!_baseType.IsMatch(type)) { return(false); } return(type.GetGenericArguments().Count(c => c.IsGenericParameter) == _numTypeArgs); }
public bool IsMatch(Type type) { if (_cache.ContainsKey(type)) { return(_cache[type]); } var isMatch = _descriptor.IsMatch(type); _cache.Add(type, isMatch); return(isMatch); }
private bool IsTypeMatch(IValueWrapper o) { var workingSet = new Stack <Type>(); var current = o.Value.GetType(); if (_decriptor.IsMatch(current)) { return(true); } workingSet.Push(current.BaseType); foreach (var iface in current.GetInterfaces()) { workingSet.Push(iface); } // We don't need to de-dupe types here, because the _descriptor does caching while (workingSet.Count > 0) { current = workingSet.Pop(); if (current == null) { continue; } if (_decriptor.IsMatch(current)) { return(true); } workingSet.Push(current.BaseType); foreach (var iface in current.GetInterfaces()) { workingSet.Push(iface); } } return(false); }
public bool IsMatch(Type type) { if (!type.IsArray || !type.HasElementType) { return(false); } if (type.GetArrayRank() != _dimensions) { return(false); } var elementType = type.GetElementType(); return(_elementType.IsMatch(elementType)); }