public static Type[] GetInterfacesCloseOf(this Type @this, Type closeType) { if (@this.IsInterface) { MiniException.UnExpectedOperated(typeof(TypeExtensions), $"{@this.FullName} isn't close of {closeType.FullName}"); } return(@this.GetInterfaces() .Where(t => t.IsGenericTypeDefinedBy(closeType)) .ToArray()); }
public IRegistrationBuilder <TLimit> As(Type service) { if (!service.IsAssignableFrom(DefaultType)) { MiniException.UnExpectedOperated(typeof(RegistrationBuilder <>), $"register type must assign from {DefaultType.FullName}"); } RegistrationData.AddServices(new TypedService(service)); return(this); }
public MiniContainer Build() { if (_isBuild) { MiniException.UnExpectedOperatedArgument(typeof(MiniContainerBuilder), nameof(_isBuild), _isBuild.ToString(), "false"); } var container = CreateContainer(); Configure(container.ComponentRegistry); _isBuild = true; return(container); }
internal MiniContainer() { ComponentRegistry = new ComponentRegistry(); ComponentRegistry.Register(new ComponentRegistration( LifetimeScope.SelfScopeId, new DelegateActivator(typeof(LifetimeScope), c => throw MiniException.UnExpectedOperated( typeof(MiniContainer), $"root can't resolve {typeof(ILifetimeScope).FullName}, {typeof(IComponentContext)}")), new CurrentLifetimeScope(), InstanceSharing.Shared, new TypedService(typeof(ILifetimeScope)), new TypedService(typeof(IComponentContext) ))); RootLifetimeScope = new LifetimeScope(ComponentRegistry); }
public ISharingLifetimeScope FindScope(ISharingLifetimeScope scope) => scope ?? throw MiniException.ArgumentNull(typeof(ISharingLifetimeScope));