Inheritance: InternalSystem.Object
Beispiel #1
0
		internal static unsafe object IsInst (InternalSystem.Object obj, TypeInfo type)
		{
			if (obj != null && IsBaseClassOf (obj.VTable.Type, type))
				return obj;
			else
				return null;
		}
Beispiel #2
0
		internal static unsafe object CastClass (InternalSystem.Object obj, TypeInfo type)
		{
			if (obj != null && IsBaseClassOf (obj.VTable.Type, type))
				return obj;
			
			Throw (new InternalSystem.InvalidCastException (), 3);

			// It doesn't come so far
			return null;
		}
Beispiel #3
0
		public static bool IsValueType (TypeInfo type)
		{
			return IsBaseClassOf (type, "System", "ValueType");
		}
Beispiel #4
0
		public static TypeDefRow GetType (TypeInfo type)
		{
			TokenType tokType;
			uint rid;

			MetadataToken.Decode (type.MetadataToken, out tokType, out rid);

			return GetType (type.Assembly, tokType, rid);
		}
Beispiel #5
0
		public static unsafe bool IsBaseClassOf (TypeInfo type, TypeInfo baseType)
		{
			byte *systemObject = Stubs.CString ("System.Object");
			CString8 *str = null;

			// Special case for System.Object

			if (ByteString.Compare (systemObject, baseType.Name) == 0)
				return true;

			// If the type infos are the same, then the result is true

			Debug.COM1.Write ("type: 0x");
			Debug.COM1.Write ((int)type.MetadataToken, true);
			Debug.COM1.Write (" '");
			Debug.COM1.Write (type.Name);
			Debug.COM1.WriteLine ("'");


			Debug.COM1.Write ("basetype: 0x");
			Debug.COM1.Write ((int)baseType.MetadataToken, true);
			Debug.COM1.Write (" '");
			Debug.COM1.Write (baseType.Name);
			Debug.COM1.WriteLine ("'");

			if (type == baseType)
				return true;

			return IsBaseClassOf (type.Assembly, type.MetadataToken, baseType.Assembly, baseType.MetadataToken);
		}
Beispiel #6
0
		public static unsafe bool IsBaseClassOf (TypeInfo type, CString8 *baseNS, CString8 *baseType)
		{
			AssemblyMetadata baseAsm;
			uint token;
			TypeRefRow row;
			TypeDefRow def;

			row = GetTypeRef (baseNS, baseType, out baseAsm, out token);

			if (row != null) {
				return IsBaseClassOf (type.Assembly, type.MetadataToken, baseAsm, token);
			} else {
				def = GetType (baseNS, baseType, out baseAsm, out token);

				Diagnostics.Assert (def != null,
					"Runtime.IsBaseClasOf(): couldn't find TypeRef/Def for named type");

				return IsBaseClassOf (type.Assembly, type.MetadataToken, baseAsm, token);
			}
		}
Beispiel #7
0
		public static unsafe bool IsBaseClassOf (TypeInfo type, string baseNS, string baseType)
		{
			CString8 *cBaseNS = CString8.Copy (baseNS);
			CString8 *cBaseType = CString8.Copy (baseType);

			return IsBaseClassOf (type, cBaseNS, cBaseType);
		}