Inheritance: Type, ISerializable
Beispiel #1
0
        RuntimeTypeHandle(SerializationInfo info, StreamingContext context)
        {
            if (info == null)
            {
                throw new ArgumentNullException("info");
            }

            MonoType mt = ((MonoType)info.GetValue("TypeObj", typeof(MonoType)));

            value = mt.TypeHandle.Value;
            if (value == IntPtr.Zero)
            {
                throw new SerializationException(Locale.GetText("Insufficient state."));
            }
        }
Beispiel #2
0
        public static object CreateInstance(Type type, bool nonPublic)
        {
            CheckType(type);
#if NET_2_0
            if (type.ContainsGenericParameters)
            {
                throw new ArgumentException(type + " is an open generic type", "type");
            }
#endif
            CheckAbstractType(type);

            ConstructorInfo ctor;
            MonoType        monoType = type as MonoType;

            if (monoType != null)
            {
                ctor = monoType.GetDefaultConstructor();
                if (!nonPublic && ctor != null && !ctor.IsPublic)
                {
                    ctor = null;
                }
            }
            else
            {
                BindingFlags flags = BindingFlags.Public | BindingFlags.Instance;
                if (nonPublic)
                {
                    flags |= BindingFlags.NonPublic;
                }
                ctor = type.GetConstructor(flags, null, CallingConventions.Any, Type.EmptyTypes, null);
            }

            if (ctor == null)
            {
                if (type.IsValueType)
                {
                    return(CreateInstanceInternal(type));
                }

                throw new MissingMethodException(Locale.GetText("Default constructor not found."),
                                                 ".ctor() of " + type.FullName);
            }

            return(ctor.Invoke(null));
        }
Beispiel #3
0
        public static object CreateInstance(Type type, bool nonPublic)
        {
            CheckType(type);

            if (type.ContainsGenericParameters)
            {
                throw new ArgumentException(type + " is an open generic type", "type");
            }

            MonoType monoType = type.UnderlyingSystemType as MonoType;

            if (monoType == null)
            {
                throw new ArgumentException("Type must be a type provided by the runtime");
            }

            CheckAbstractType(monoType);

            var ctor = monoType.GetDefaultConstructor();

            if (!nonPublic && ctor != null && !ctor.IsPublic)
            {
                ctor = null;
            }

            if (ctor == null)
            {
                if (type.IsValueType)
                {
                    return(CreateInstanceInternal(type));
                }

                throw new MissingMethodException(Locale.GetText("Default constructor not found for type " + type.FullName));
            }

            return(ctor.InternalInvoke(null, null));
        }
Beispiel #4
0
 private static extern void type_from_obj(MonoType type, Object obj);
Beispiel #5
0
		private static extern void type_from_obj (MonoType type, Object obj);
 protected override TypeAttributes GetAttributeFlagsImpl()
 {
     return(MonoType.get_attributes(this));
 }
 internal MonoType(object obj)
 {
     MonoType.type_from_obj(this, obj);
     throw new NotImplementedException();
 }
Beispiel #8
0
 /// <summary>
 /// Get the type expression that is used to type check this expression.
 /// </summary>
 public TypeCheck TypeCheck()
 {
     return TC.DoAfter (GetTypeCheck (),
         (st, exp) =>
         {
             TypeEnvironment = st.Env;
             Subs = st.Subs;
             Type = exp;
         });
 }
Beispiel #9
0
 private static void type_from_obj(MonoType type, Object obj)
 {
     throw new System.NotImplementedException();
 }
		private static void type_from_obj (MonoType type, Object obj)
		{
			throw new System.NotImplementedException();
		}