Beispiel #1
0
            //
            // Returns the cached result of a name-specific query on the Type's members, as if you'd passed in
            //
            //  BindingFlags == Public | NonPublic | Instance | Static | FlattenHierarchy
            //
            public QueriedMemberList <M> GetQueriedMembers <M>(string name, bool ignoreCase) where M : MemberInfo
            {
                int    index = MemberPolicies <M> .MemberTypeIndex;
                object obj   = ignoreCase ? _perNameQueryCaches_CaseInsensitive[index] : _perNameQueryCaches_CaseSensitive[index];

                Debug.Assert(obj is PerNameQueryCache <M>);
                PerNameQueryCache <M> unifier = Unsafe.As <PerNameQueryCache <M> >(obj);
                QueriedMemberList <M> result  = unifier.GetOrAdd(name);

                return(result);
            }
Beispiel #2
0
            //
            // Returns the cached result of a name-agnostic query on the Type's members, as if you'd passed in
            //
            //  BindingFlags == Public | NonPublic | Instance | Static | FlattenHierarchy
            //
            public QueriedMemberList <M> GetQueriedMembers <M>() where M : MemberInfo
            {
                int    index  = MemberPolicies <M> .MemberTypeIndex;
                object result = Volatile.Read(ref _nameAgnosticQueryCaches[index]);

                if (result == null)
                {
                    QueriedMemberList <M> newResult = QueriedMemberList <M> .Create(_type, optionalNameFilter : null, ignoreCase : false);

                    newResult.Compact();
                    result = newResult;
                    Volatile.Write(ref _nameAgnosticQueryCaches[index], result);
                }

                Debug.Assert(result is QueriedMemberList <M>);
                return(Unsafe.As <QueriedMemberList <M> >(result));
            }