public override bool IsMatch(Type type, OpenTypeMatchContext context) { if (type == null) { throw new ArgumentNullException(nameof(type)); } if (type.IsByRef) { return(false); } if (type.IsArray) { return(false); } if (type.IsPrimitive) { return(false); } if (type.FullName == "System.Object") { return(false); } if (type.GetInterface("System.IEnumerable`1") != null) { return(false); } if (type.GetInterface("System.IDisposable") != null) { return(false); } return(true); }
public override bool IsMatch(Type type, OpenTypeMatchContext context) { if (type == null) { throw new ArgumentNullException(nameof(type)); } if (type.IsByRef) { var elementType = type.GetElementType(); return(_inner.IsMatch(elementType, context)); } return(false); }
public override bool IsMatch(Type type, OpenTypeMatchContext context) { if (type == _type) { return(true); } if (_type.GetType() != type.GetType()) { // Doing a comparison across type-universes. Likely that: // 'this._type' is a real reflection type defined by the extension // parameter 'type' is a non-reflection implemeentation defined by the tooling. // To compare equivalence across universes, compare by name. if (TypeEquals(type, _type)) { return(true); } } return(false); }
public override bool IsMatch(Type type, OpenTypeMatchContext context) { if (type == null) { throw new ArgumentNullException(nameof(type)); } if (context == null) { throw new ArgumentNullException(nameof(context)); } if (type.IsGenericType && ExactMatch.TypeEquals(type.GetGenericTypeDefinition(), _outerType)) { var args = type.GetGenericArguments(); return(_inner.IsMatch(args[0], context)); } return(false); }
public override bool IsMatch(Type type, OpenTypeMatchContext context) { if (type == null) { throw new ArgumentNullException(nameof(type)); } if (ExactMatch.TypeToString(type) == ExactMatch.TypeToString(_targetType)) { return(true); } // What if types are in different type universes? // Type is a concrete type. if (_targetType.IsInterface) { var iface = type.GetInterface(_targetType.FullName); return(iface != null); } // Fake types? return(false); }
/// <summary> /// Return true if and only if given type matches. /// This is constrained by the current matching context. /// If the OpenType represents an exact type, then this is just Type.Equals. /// </summary> /// <param name="type">Type to check</param> /// <returns></returns> public abstract bool IsMatch(Type type, OpenTypeMatchContext context);
/// <summary> /// Return true if and only if given type matches. /// If the OpenType represents an exact type, then this is just Type.Equals. /// </summary> /// <param name="type">Type to check</param> /// <returns></returns> public bool IsMatch(Type type) { var context = new OpenTypeMatchContext(); return(this.IsMatch(type, context)); }
public override bool IsMatch(Type type, OpenTypeMatchContext context) { return(context.CheckArg(type)); }