Bottles.Services.BottleServiceApplication.DetermineLoaderType C# (CSharp) Метод

DetermineLoaderType() публичный статический Метод

public static DetermineLoaderType ( Type type ) : Type
type System.Type
Результат System.Type
        public static Type DetermineLoaderType(Type type)
        {
            if (type.CanBeCastTo<IApplicationLoader>()) return type;

            if (type.CanBeCastTo<IBootstrapper>())
            {
                return typeof (BootstrapperApplicationLoader<>).MakeGenericType(type);
            }

            var @interface = type.FindInterfaceThatCloses(typeof (IApplicationSource<,>));
            if (@interface == null) throw new ArgumentOutOfRangeException("type must implement either IBootstrapper, IApplicationLoader, or IApplicationSource<TApplication,TRuntime> (FubuMVC's IApplicationSource)");

            var genericArguments = @interface.GetGenericArguments();
            return typeof (ApplicationLoader<,,>)
                .MakeGenericType(type, genericArguments.First(), genericArguments.Last());
        }