예제 #1
0
 public bool IsMatch(Type type)
 {
     if (!_baseType.IsMatch(type))
     {
         return(false);
     }
     return(type.GetGenericArguments().Count(c => c.IsGenericParameter) == _numTypeArgs);
 }
예제 #2
0
        public bool IsMatch(Type type)
        {
            if (_cache.ContainsKey(type))
            {
                return(_cache[type]);
            }
            var isMatch = _descriptor.IsMatch(type);

            _cache.Add(type, isMatch);
            return(isMatch);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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));
        }