Ejemplo n.º 1
0
            //  FilterHelper code copied from: https://github.com/dotnet/coreclr/blob/bc146608854d1db9cdbcc0b08029a87754e12b49/src/mscorlib/src/System/RtType.cs#L87
            // Calculate prefixLookup, ignoreCase, and listType for use by GetXXXCandidates
            private static void FilterHelper(
                BindingFlags bindingFlags, ref string name, bool allowPrefixLookup, out bool prefixLookup,
                out bool ignoreCase, out MemberListType listType)
            {
                prefixLookup = false;
                ignoreCase   = false;

                if (name != null)
                {
                    if ((bindingFlags & BindingFlags.IgnoreCase) != 0)
                    {
                        name       = name.ToLowerInvariant();
                        ignoreCase = true;
                        listType   = MemberListType.CaseInsensitive;
                    }
                    else
                    {
                        listType = MemberListType.CaseSensitive;
                    }

                    if (allowPrefixLookup && name.EndsWith("*", StringComparison.Ordinal))
                    {
                        // We set prefixLookup to true if name ends with a "*".
                        // We will also set listType to All so that all members are included in
                        // the candidates which are later filtered by FilterApplyPrefixLookup.
                        name         = name.Substring(0, name.Length - 1);
                        prefixLookup = true;
                        listType     = MemberListType.All;
                    }
                }
                else
                {
                    listType = MemberListType.All;
                }
            }
Ejemplo n.º 2
0
        RuntimeFieldInfo[] GetFields_internal(string name, BindingFlags bindingAttr, MemberListType listType, RuntimeType reflectedType)
        {
            var refh = new RuntimeTypeHandle(reflectedType);

            using (var namePtr = new Mono.SafeStringMarshal(name))
                using (var h = new Mono.SafeGPtrArrayHandle(GetFields_native(namePtr.Value, bindingAttr, listType))) {
                    int n = h.Length;
                    var a = new RuntimeFieldInfo[n];
                    for (int i = 0; i < n; i++)
                    {
                        var fh = new RuntimeFieldHandle(h[i]);
                        a[i] = (RuntimeFieldInfo)FieldInfo.GetFieldFromHandle(fh, refh);
                    }
                    return(a);
                }
        }
Ejemplo n.º 3
0
        RuntimeEventInfo[] GetEvents_internal(string name, BindingFlags bindingAttr, MemberListType listType, RuntimeType reflectedType)
        {
            var refh = new RuntimeTypeHandle(reflectedType);

            using (var namePtr = new Mono.SafeStringMarshal(name))
                using (var h = new Mono.SafeGPtrArrayHandle(GetEvents_native(namePtr.Value, listType))) {
                    int n = h.Length;
                    var a = new RuntimeEventInfo[n];
                    for (int i = 0; i < n; i++)
                    {
                        var eh = new Mono.RuntimeEventHandle(h[i]);
#if NETCORE
                        a[i] = (RuntimeEventInfo)RuntimeEventInfo.GetEventFromHandle(eh, refh);
#else
                        a[i] = (RuntimeEventInfo)EventInfo.GetEventFromHandle(eh, refh);
#endif
                    }
                    return(a);
                }
        }
Ejemplo n.º 4
0
        RuntimeType[] GetNestedTypes_internal(string displayName, BindingFlags bindingAttr, MemberListType listType)
        {
            string internalName = null;

#if NETCORE
            if (displayName != null)
            {
                internalName = displayName;
            }
#else
            if (displayName != null)
            {
                internalName = TypeIdentifiers.FromDisplay(displayName).InternalName;
            }
#endif
            using (var namePtr = new Mono.SafeStringMarshal(internalName))
                using (var h = new Mono.SafeGPtrArrayHandle(GetNestedTypes_native(namePtr.Value, bindingAttr, listType))) {
                    int n = h.Length;
                    var a = new RuntimeType [n];
                    for (int i = 0; i < n; i++)
                    {
                        var th = new RuntimeTypeHandle(h[i]);
                        a[i] = (RuntimeType)Type.GetTypeFromHandle(th);
                    }
                    return(a);
                }
        }
Ejemplo n.º 5
0
 extern IntPtr GetNestedTypes_native(IntPtr name, BindingFlags bindingAttr, MemberListType listType);
Ejemplo n.º 6
0
 extern IntPtr GetFields_native(IntPtr name, BindingFlags bindingAttr, MemberListType listType);
Ejemplo n.º 7
0
 extern IntPtr GetEvents_native(IntPtr name, MemberListType listType);
Ejemplo n.º 8
0
        RuntimePropertyInfo[] GetPropertiesByName(string name, BindingFlags bindingAttr, MemberListType listType, RuntimeType reflectedType)
        {
            var refh = new RuntimeTypeHandle(reflectedType);

            using (var namePtr = new Mono.SafeStringMarshal(name))
                using (var h = new Mono.SafeGPtrArrayHandle(GetPropertiesByName_native(namePtr.Value, bindingAttr, listType))) {
                    var n = h.Length;
                    var a = new RuntimePropertyInfo [n];
                    for (int i = 0; i < n; i++)
                    {
                        var ph = new Mono.RuntimePropertyHandle(h[i]);
                        a[i] = (RuntimePropertyInfo)RuntimePropertyInfo.GetPropertyFromHandle(ph, refh);
                    }
                    return(a);
                }
        }
Ejemplo n.º 9
0
 extern IntPtr GetPropertiesByName_native(IntPtr name, BindingFlags bindingAttr, MemberListType listType);
Ejemplo n.º 10
0
        internal RuntimeMethodInfo[] GetMethodsByName(string name, BindingFlags bindingAttr, MemberListType listType, RuntimeType reflectedType)
        {
            var refh = new RuntimeTypeHandle(reflectedType);

            using (var namePtr = new Mono.SafeStringMarshal(name))
                using (var h = new Mono.SafeGPtrArrayHandle(GetMethodsByName_native(namePtr.Value, bindingAttr, listType))) {
                    var n = h.Length;
                    var a = new RuntimeMethodInfo [n];
                    for (int i = 0; i < n; i++)
                    {
                        var mh = new RuntimeMethodHandle(h[i]);
                        a[i] = (RuntimeMethodInfo)RuntimeMethodInfo.GetMethodFromHandleNoGenericCheck(mh, refh);
                    }
                    return(a);
                }
        }
Ejemplo n.º 11
0
 internal extern IntPtr GetMethodsByName_native(IntPtr namePtr, BindingFlags bindingAttr, MemberListType listType);