public IndexerMethodGroupExpr (Indexers indexers, Location loc)
				: base (null, loc)
			{
				Methods = (MethodBase []) indexers.Methods.ToArray (typeof (MethodBase));
			}
			public static Indexers GetIndexersForType (Type caller_type, Type lookup_type) 
			{
				Indexers ix = new Indexers ();

				if (TypeManager.IsGenericParameter (lookup_type)) {
					GenericConstraints gc = TypeManager.GetTypeParameterConstraints (lookup_type);
					if (gc == null)
						return ix;

					if (gc.HasClassConstraint) {
						Type class_contraint = gc.ClassConstraint;
						while (class_contraint != TypeManager.object_type && class_contraint != null) {
							ix.Append (caller_type, GetIndexersForTypeOrInterface (caller_type, class_contraint));
							class_contraint = class_contraint.BaseType;
						}
					}

					Type[] ifaces = gc.InterfaceConstraints;
					foreach (Type itype in ifaces)
						ix.Append (caller_type, GetIndexersForTypeOrInterface (caller_type, itype));

					return ix;
				}

				Type copy = lookup_type;
				while (copy != TypeManager.object_type && copy != null){
					ix.Append (caller_type, GetIndexersForTypeOrInterface (caller_type, copy));
					copy = copy.BaseType;
				}

				if (lookup_type.IsInterface) {
					Type [] ifaces = TypeManager.GetInterfaces (lookup_type);
					if (ifaces != null) {
						foreach (Type itype in ifaces)
							ix.Append (caller_type, GetIndexersForTypeOrInterface (caller_type, itype));
					}
				}

				return ix;
			}
Example #3
0
		static public Indexers GetIndexersForType (Type caller_type, Type lookup_type, Location loc) 
		{
			Indexers ix = (Indexers) map [lookup_type];
			
			if (ix != null)
				return ix;

			Type copy = lookup_type;
			while (copy != TypeManager.object_type && copy != null){
				MemberInfo [] mi = GetIndexersForTypeOrInterface (caller_type, copy);

				if (mi != null){
					if (ix == null)
						ix = new Indexers ();

					ix.Append (mi);
				}
					
				copy = copy.BaseType;
			}

			Type [] ifaces = TypeManager.GetInterfaces (lookup_type);
			if (ifaces != null) {
				foreach (Type itype in ifaces) {
					MemberInfo [] mi = GetIndexersForTypeOrInterface (caller_type, itype);
					if (mi != null){
						if (ix == null)
							ix = new Indexers ();
					
						ix.Append (mi);
					}
				}
			}

			return ix;
		}