コード例 #1
0
        public void DoMethodThings()
        {
            Type[] targetTypes = new[] { typeof(int), typeof(System.IO.File), typeof(System.Diagnostics.Activity) };

            // raw
            foreach (Type type in targetTypes)
            {
                var result = type.GetMethods(BindingFlags.Public | BindingFlags.Instance);
            }
            // cached
            foreach (Type type in targetTypes)
            {
                var result = TypeInfoHolderHelper.GetMethods(type, (m) => m.IsPublic && m.IsStatic == false);
            }
        }
コード例 #2
0
        public void Caching()
        {
            IReadOnlyList <MethodInfo> result       = null;
            Action <MethodInfo>        action       = Foo;
            Func <MethodInfo, bool>    methodFilter = m => m.IsPublic || m.IsPrivate;

            for (int i = 0; i < N; ++i)
            {
                foreach (Type type in TargetTypes())
                {
                    TypeInfoHolderHelper.GetMethods(type, methodFilter);
                    if (result != null)
                    {
                        foreach (MethodInfo methodInfo in result)
                        {
                            action(methodInfo);
                        }
                    }
                }
            }
        }