상속: ConstructorInfo
		internal RuntimeConstructorInfo GetSerializationCtor()
		{
			if (m_serializationCtor == null) {
				var s_SICtorParamTypes = new Type[] { typeof(SerializationInfo), typeof(StreamingContext) };

				m_serializationCtor = GetConstructor(
					BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic,
					null,
					CallingConventions.Any,
					s_SICtorParamTypes,
					null) as RuntimeConstructorInfo;
			}

			return m_serializationCtor;
		}
예제 #2
0
 internal static object[] GetCustomAttributes(RuntimeConstructorInfo ctor, RuntimeType caType)
 {
     int count = 0;
     Attribute[] sourceArray = PseudoCustomAttribute.GetCustomAttributes(ctor, caType, true, out count);
     object[] destinationArray = GetCustomAttributes(ctor.Module, ctor.MetadataToken, count, caType);
     if (count > 0)
     {
         Array.Copy(sourceArray, 0, destinationArray, destinationArray.Length - count, count);
     }
     return destinationArray;
 }
예제 #3
0
        internal static unsafe object[] GetCustomAttributes(Module decoratedModule, int decoratedMetadataToken, int pcaCount, RuntimeType attributeFilterType, bool mustBeInheritable, IList derivedAttributes)
        {
            if (decoratedModule.Assembly.ReflectionOnly)
            {
                throw new InvalidOperationException(Environment.GetResourceString("Arg_ReflectionOnlyCA"));
            }
            MetadataImport metadataImport = decoratedModule.MetadataImport;

            CustomAttributeRecord[] customAttributeRecords = CustomAttributeData.GetCustomAttributeRecords(decoratedModule, decoratedMetadataToken);
            Type elementType = (((attributeFilterType == null) || attributeFilterType.IsValueType) || attributeFilterType.ContainsGenericParameters) ? typeof(object) : attributeFilterType;

            if ((attributeFilterType == null) && (customAttributeRecords.Length == 0))
            {
                return(Array.CreateInstance(elementType, 0) as object[]);
            }
            object[]             attributes = Array.CreateInstance(elementType, customAttributeRecords.Length) as object[];
            int                  length     = 0;
            SecurityContextFrame frame      = new SecurityContextFrame();

            frame.Push(decoratedModule.Assembly.InternalAssembly);
            Assembly lastAptcaOkAssembly = null;

            for (int i = 0; i < customAttributeRecords.Length; i++)
            {
                bool   flag2;
                bool   flag3;
                object obj2 = null;
                CustomAttributeRecord caRecord      = customAttributeRecords[i];
                RuntimeMethodHandle   ctor          = new RuntimeMethodHandle();
                RuntimeType           attributeType = null;
                int    namedArgs = 0;
                IntPtr signature = caRecord.blob.Signature;
                IntPtr blobEnd   = (IntPtr)(((void *)signature) + caRecord.blob.Length);
                if (FilterCustomAttributeRecord(caRecord, metadataImport, ref lastAptcaOkAssembly, decoratedModule, decoratedMetadataToken, attributeFilterType, mustBeInheritable, attributes, derivedAttributes, out attributeType, out ctor, out flag2, out flag3))
                {
                    if (!ctor.IsNullHandle())
                    {
                        ctor.CheckLinktimeDemands(decoratedModule, decoratedMetadataToken);
                    }
                    RuntimeConstructorInfo.CheckCanCreateInstance(attributeType, flag3);
                    if (flag2)
                    {
                        obj2 = CreateCaObject(decoratedModule, ctor, ref signature, blobEnd, out namedArgs);
                    }
                    else
                    {
                        obj2 = attributeType.TypeHandle.CreateCaInstance(ctor);
                        if (Marshal.ReadInt16(signature) != 1)
                        {
                            throw new CustomAttributeFormatException();
                        }
                        signature = (IntPtr)(((void *)signature) + 2);
                        namedArgs = Marshal.ReadInt16(signature);
                        signature = (IntPtr)(((void *)signature) + 2);
                    }
                    for (int j = 0; j < namedArgs; j++)
                    {
                        string str;
                        bool   flag4;
                        Type   type3;
                        object obj3;
                        IntPtr ptr1 = caRecord.blob.Signature;
                        GetPropertyOrFieldData(decoratedModule, ref signature, blobEnd, out str, out flag4, out type3, out obj3);
                        try
                        {
                            if (flag4)
                            {
                                if ((type3 == null) && (obj3 != null))
                                {
                                    type3 = (obj3.GetType() == typeof(RuntimeType)) ? typeof(Type) : obj3.GetType();
                                }
                                RuntimePropertyInfo property = null;
                                if (type3 == null)
                                {
                                    property = attributeType.GetProperty(str) as RuntimePropertyInfo;
                                }
                                else
                                {
                                    property = attributeType.GetProperty(str, type3, Type.EmptyTypes) as RuntimePropertyInfo;
                                }
                                RuntimeMethodInfo setMethod = property.GetSetMethod(true) as RuntimeMethodInfo;
                                if (setMethod.IsPublic)
                                {
                                    setMethod.MethodHandle.CheckLinktimeDemands(decoratedModule, decoratedMetadataToken);
                                    setMethod.Invoke(obj2, BindingFlags.Default, null, new object[] { obj3 }, null, true);
                                }
                            }
                            else
                            {
                                (attributeType.GetField(str) as RtFieldInfo).InternalSetValue(obj2, obj3, BindingFlags.Default, Type.DefaultBinder, null, false);
                            }
                        }
                        catch (Exception exception)
                        {
                            throw new CustomAttributeFormatException(string.Format(CultureInfo.CurrentUICulture, Environment.GetResourceString(flag4 ? "RFLCT.InvalidPropFail" : "RFLCT.InvalidFieldFail"), new object[] { str }), exception);
                        }
                    }
                    if (!signature.Equals(blobEnd))
                    {
                        throw new CustomAttributeFormatException();
                    }
                    attributes[length++] = obj2;
                }
            }
            frame.Pop();
            if ((length == customAttributeRecords.Length) && (pcaCount == 0))
            {
                return(attributes);
            }
            if (length == 0)
            {
                Array.CreateInstance(elementType, 0);
            }
            object[] destinationArray = Array.CreateInstance(elementType, (int)(length + pcaCount)) as object[];
            Array.Copy(attributes, 0, destinationArray, 0, length);
            return(destinationArray);
        }
예제 #4
0
		RuntimeConstructorInfo[] GetConstructors_internal (BindingFlags bindingAttr, RuntimeType reflectedType)
		{
			var refh = new RuntimeTypeHandle (reflectedType);
			using (var h = new Mono.SafeGPtrArrayHandle (GetConstructors_native (bindingAttr))) {
				var n = h.Length;
				var a = new RuntimeConstructorInfo [n];
				for (int i = 0; i < n; i++) {
					var mh = new RuntimeMethodHandle (h[i]);
					a[i] = (RuntimeConstructorInfo) MethodBase.GetMethodFromHandleNoGenericCheck (mh, refh);
				}
				return a;
			}
		}
예제 #5
0
 internal static bool TryGetConstructor(RuntimeType t, out RuntimeConstructorInfo ctorInfo) { 
     return TryGetConstructor(t, SIConstructorTypes, out ctorInfo); 
 }
 internal static IList<CustomAttributeData> GetCustomAttributesInternal(RuntimeConstructorInfo target)
 {
     return GetCustomAttributes(target.GetRuntimeModule(), target.MetadataToken);
 }
예제 #7
0
        [System.Security.SecurityCritical]  // auto-generated
        internal static Attribute[] GetCustomAttributes(RuntimeConstructorInfo ctor, RuntimeType caType, bool includeSecCa, out int count)
        {
            count = 0;

            bool all = caType == (RuntimeType)typeof(object) || caType == (RuntimeType)typeof(Attribute);

            if (!all && s_pca.GetValueOrDefault(caType) == null && !IsSecurityAttribute(caType))
                return new Attribute[0];

            List<Attribute> pcas = new List<Attribute>();

            if (includeSecCa && (all || IsSecurityAttribute(caType)))
            {
                object[] securityAttributes;

                GetSecurityAttributes(ctor.Module.ModuleHandle.GetRuntimeModule(), ctor.MetadataToken, false, out securityAttributes);
                if (securityAttributes != null)
                    foreach (object a in securityAttributes)
                        if (caType == a.GetType() || a.GetType().IsSubclassOf(caType))
                            pcas.Add((Attribute)a);
            }

            count = pcas.Count;
            return pcas.ToArray();
        }
예제 #8
0
        [System.Security.SecurityCritical]  // auto-generated
        internal static bool IsDefined(RuntimeConstructorInfo ctor, RuntimeType caType)
        {
            Contract.Requires(ctor != null);
            Contract.Requires(caType != null);

            if (PseudoCustomAttribute.IsDefined(ctor, caType))
                return true;

            return IsCustomAttributeDefined(ctor.GetRuntimeModule(), ctor.MetadataToken, caType);
        }
예제 #9
0
 private void LoadConstructorInfo()
 {
     if (_constructors != null)
     {
         return;
     }
     _constructors = new RuntimeConstructorInfo[_class.Constructors.Length];
     for (int i = 0; i < _class.Constructors.Length; i++)
     {
         Constructor constructor = _class.Constructors[i];
         _constructors[i] = new RuntimeConstructorInfo(constructor, this);
         _constructorToRuntimeConstructorInfoMap[constructor] = _constructors[i];
     }
 }
예제 #10
0
 internal static IList <CustomAttributeData> GetCustomAttributesInternal(RuntimeConstructorInfo target)
 {
     return(GetCustomAttributes(target.GetRuntimeModule(), target.MetadataToken));
 }
예제 #11
0
 internal static extern int get_metadata_token(RuntimeConstructorInfo method);
 internal static bool IsDefined(RuntimeConstructorInfo ctor, RuntimeType caType)
 {
     int num;
     bool flag = (caType == ((RuntimeType) typeof(object))) || (caType == ((RuntimeType) typeof(Attribute)));
     if (!flag && (s_pca.GetValueOrDefault(caType) == null))
     {
         return false;
     }
     return ((flag || IsSecurityAttribute(caType)) && (GetCustomAttributes(ctor, caType, true, out num).Length != 0));
 }
 internal static Attribute[] GetCustomAttributes(RuntimeConstructorInfo ctor, RuntimeType caType, bool includeSecCa, out int count)
 {
     count = 0;
     bool flag = (caType == ((RuntimeType) typeof(object))) || (caType == ((RuntimeType) typeof(Attribute)));
     if ((!flag && (s_pca.GetValueOrDefault(caType) == null)) && !IsSecurityAttribute(caType))
     {
         return new Attribute[0];
     }
     List<Attribute> list = new List<Attribute>();
     if (includeSecCa && (flag || IsSecurityAttribute(caType)))
     {
         object[] objArray;
         GetSecurityAttributes(ctor.Module.ModuleHandle.GetRuntimeModule(), ctor.MetadataToken, false, out objArray);
         if (objArray != null)
         {
             foreach (object obj2 in objArray)
             {
                 if ((caType == obj2.GetType()) || obj2.GetType().IsSubclassOf(caType))
                 {
                     list.Add((Attribute) obj2);
                 }
             }
         }
     }
     count = list.Count;
     return list.ToArray();
 }
예제 #14
0
 internal static bool IsDefined(RuntimeConstructorInfo ctor, RuntimeType caType)
 {
     return(PseudoCustomAttribute.IsDefined(ctor, caType) || IsCustomAttributeDefined(ctor.Module, ctor.MetadataToken, caType));
 }
예제 #15
0
 internal static bool IsDefined(RuntimeConstructorInfo ctor, RuntimeType caType)
 {
     return (PseudoCustomAttribute.IsDefined(ctor, caType) || IsCustomAttributeDefined(ctor.Module, ctor.MetadataToken, caType));
 }
예제 #16
0
        private int GetTokenFor(RuntimeConstructorInfo rtMeth, RuntimeType rtType)
        {
#if FEATURE_APPX
            if (ProfileAPICheck)
            {
                if ((rtMeth.InvocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NON_W8P_FX_API) != 0)
                    throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_APIInvalidForCurrentContext", rtMeth.FullName));

                if ((rtType.InvocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NON_W8P_FX_API) != 0)
                    throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_APIInvalidForCurrentContext", rtType.FullName));
            }
#endif

            return m_scope.GetTokenFor(rtMeth.MethodHandle, rtType.TypeHandle);
        }
 internal RemotingCachedData(RuntimeConstructorInfo ri)
 {
     this.RI = ri;
 }
예제 #18
0
        [System.Security.SecuritySafeCritical]  // auto-generated
        internal static Object[] GetCustomAttributes(RuntimeConstructorInfo ctor, RuntimeType caType)
        {
            Contract.Requires(ctor != null);
            Contract.Requires(caType != null);

            int pcaCount = 0;
            Attribute[] pca = PseudoCustomAttribute.GetCustomAttributes(ctor, caType, true, out pcaCount);
            object[] attributes = GetCustomAttributes(ctor.GetRuntimeModule(), ctor.MetadataToken, pcaCount, caType, !AllowCriticalCustomAttributes(ctor));
            if (pcaCount > 0) Array.Copy(pca, 0, attributes, attributes.Length - pcaCount, pcaCount);
            return attributes;
        }
        internal static bool IsDefined(RuntimeConstructorInfo ctor, RuntimeType caType)
        {
            ASSERT.PRECONDITION(ctor != null);

            if (PseudoCustomAttribute.IsDefined(ctor, caType))
                return true;

            return IsCustomAttributeDefined(ctor.Module, ctor.MetadataToken, caType);
        }
예제 #20
0
        [System.Security.SecurityCritical]  // auto-generated
        internal static bool IsDefined(RuntimeConstructorInfo ctor, RuntimeType caType)
        {
            bool all = caType == (RuntimeType)typeof(object) || caType == (RuntimeType)typeof(Attribute);

            if (!all && s_pca.GetValueOrDefault(caType) == null)
                return false;

            if (all || IsSecurityAttribute(caType))
            {
                int count;

                if (GetCustomAttributes(ctor, caType, true, out count).Length != 0)
                    return true;
            }

            return false;
        }
 internal static Object[] GetCustomAttributes(RuntimeConstructorInfo ctor, RuntimeType caType)
 {
     int pcaCount = 0;
     Attribute[] pca = PseudoCustomAttribute.GetCustomAttributes(ctor, caType, true, out pcaCount);
     object[] attributes = GetCustomAttributes(ctor.Module, ctor.MetadataToken, pcaCount, caType);
     if (pcaCount > 0) Array.Copy(pca, 0, attributes, attributes.Length - pcaCount, pcaCount);
     return attributes;
 }
 internal RemotingMethodCachedData(RuntimeConstructorInfo ri) : base(ri)
 {
 }
        [System.Security.SecurityCritical]  // auto-generated
        internal static bool IsDefined(RuntimeConstructorInfo ctor, RuntimeType caType)
        {
            Contract.Requires(ctor != null);
            Contract.Requires(caType != null);

#if !FEATURE_CORECLR
            if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.DynamicTypeUsage) && caType != null)
            {
                FrameworkEventSource.Log.QueryAttributeIsDefined(caType.GetFullNameForEtw());
            }
#endif

            if (PseudoCustomAttribute.IsDefined(ctor, caType))
                return true;

            return IsCustomAttributeDefined(ctor.GetRuntimeModule(), ctor.MetadataToken, caType);
        }
예제 #24
0
        internal static bool TryGetConstructor(RuntimeType t, RuntimeType[] ctorParams, out RuntimeConstructorInfo ctorInfo) {
            Contract.Assert(t != null, "[GetConstructor]t!=null");
            Contract.Assert(t is RuntimeType, "[GetConstructor]t is RuntimeType"); 

            ctorInfo = t.RemotingCache[CacheObjType.ConstructorInfo] as RuntimeConstructorInfo; 
            if (ctorInfo != null) { 
                return true;
            } 

            ctorInfo = t.GetConstructor(
                    BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic,
                    null, CallingConventions.Any, ctorParams, null) as RuntimeConstructorInfo; 
            if (ctorInfo != null) {
                t.RemotingCache[CacheObjType.ConstructorInfo] = ctorInfo; 
                return true; 
            }
 
            return false;
        }
 internal RemotingMethodCachedData(RuntimeConstructorInfo ri)
 {
     RI = ri;
 }
예제 #26
0
        [System.Security.SecurityCritical]  // auto-generated
        private int GetMemberRefOfMethodInfo(int tr, RuntimeConstructorInfo method)
        {
            Contract.Assert(method != null);

#if FEATURE_APPX
            if (ContainingAssemblyBuilder.ProfileAPICheck)
            {
                if ((method.InvocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NON_W8P_FX_API) != 0)
                    throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_APIInvalidForCurrentContext", method.FullName));
            }
#endif

            return GetMemberRefOfMethodInfo(GetNativeHandle(), tr, method);
        }
예제 #27
0
 internal static IList <CustomAttributeData> GetCustomAttributesInternal(RuntimeConstructorInfo target)
 {
     return(CustomAttribute.GetCustomAttributesData(target));
 }