Ejemplo n.º 1
0
        void ResolveProxyableMembers()
        {
            // Note: Type.FindMembers has a suboptimal implementation wherein it allocates
            // arrays for each MemberTypes value, calls the Get(Properties|Fields|etc) methods,
            // to populate the arrays, then allocates a final array to merge all MemberTypes
            // arrays, which we would then use here to populate proxyableMembers...
            // so instead we implement just what we need here to avoid that excess!
            // -abock, 2015-12-22

            foreach (var pi in ResolvedType.GetProperties(memberInfoBindingFlags))
            {
                if (!pi.IsSpecialName && pi.GetIndexParameters()?.Length == 0)
                {
                    proxyableMembers.Add(pi.Name, new RepresentedMemberInfo(this, pi));
                }
            }

            foreach (var fi in ResolvedType.GetFields(memberInfoBindingFlags))
            {
                if (!fi.IsSpecialName)
                {
                    proxyableMembers.Add(fi.Name, new RepresentedMemberInfo(this, fi));
                }
            }
        }