-
Notifications
You must be signed in to change notification settings - Fork 0
/
Host.cs
26 lines (24 loc) · 1000 Bytes
/
Host.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
using ricaun.DI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BimIshou
{
public static class Host
{
public static IContainer Container { get; } = ContainerUtils.CreateContainer();
public static IContainerResolver ContainerResolver => Container;
public static T Resolve<T>() where T : class => ContainerResolver.Resolve<T>();
public static T ResolveOrNull<T>() where T : class => ContainerResolver.ResolveOrNull<T>();
}
public interface IHost { }
public static class HostExtension
{
public static IContainer GetContainer(this IHost _) => Host.Container;
public static IContainerResolver GetContainerResolver(this IHost _) => Host.ContainerResolver;
public static T Resolve<T>(this IHost _) where T : class => Host.Resolve<T>();
public static T ResolveOrNull<T>(this IHost _) where T : class => Host.ResolveOrNull<T>();
}
}