Owin.Loader.DefaultLoader.MakeDelegate C# (CSharp) Method

MakeDelegate() private method

private MakeDelegate ( Type type, MethodInfo methodInfo ) : Action
type System.Type
methodInfo System.Reflection.MethodInfo
return Action
        private Action<IAppBuilder> MakeDelegate(Type type, MethodInfo methodInfo)
        {
            if (methodInfo == null)
            {
                return null;
            }

            if (Matches(methodInfo, typeof(void), typeof(IAppBuilder)))
            {
                var instance = methodInfo.IsStatic ? null : _activator(type);
                return builder => methodInfo.Invoke(instance, new[] { builder });
            }

            if (Matches(methodInfo, null, typeof(IDictionary<string, object>)))
            {
                var instance = methodInfo.IsStatic ? null : _activator(type);
                return builder => builder.Use(new Func<object, object>(_ => methodInfo.Invoke(instance, new object[] { builder.Properties })));
            }

            if (Matches(methodInfo, null))
            {
                var instance = methodInfo.IsStatic ? null : _activator(type);
                return builder => builder.Use(new Func<object, object>(_ => methodInfo.Invoke(instance, new object[] { builder.Properties })));
            }

            return null;
        }