public void Dispose() { //IDisposable disposable = resolver as IDisposable; //if (disposable != null) // disposable.Dispose(); resolver = null; }
public object Resolve(IResolutionRoot resolutionRoot, IResolutionParameters resolutionParameters) { Type type = resolutionParameters.TypeToResolve; TypeInfo typeInfo = type.GetTypeInfo(); if (typeInfo.IsGenericType) { var genericType = type.GetGenericTypeDefinition(); if (genericType == typeof(IEnumerable<>) || genericType == typeof(ICollection<>) || genericType == typeof(IList<>) || genericType == typeof(List<>)) { return this.GetAllAsList(resolutionRoot, typeInfo.GenericTypeArguments[0], resolutionParameters); } } if (typeInfo.IsArray) { var argumentType = type.GetElementType(); return this.GetAllAsArray(resolutionRoot, argumentType, resolutionParameters); } return resolutionRoot.Get( type, resolutionParameters.Constraint, resolutionParameters.Parameters.ToArray()); }
public NinjectDependencyResolver() { IKernel kernel = new StandardKernel(); resolutionRoot = kernel; DoBindings(kernel); }
public NinjectDependencyScope(IResolutionRoot resolver) { if (resolver == null) throw new ArgumentNullException("resolver"); this.resolver = resolver; }
public void Dispose() { var disposable = _resolver as IDisposable; if (disposable != null) disposable.Dispose(); _resolver = null; }
public void Dispose() { var disposable = _resolutionRoot as IDisposable; if(disposable!=null) disposable.Dispose(); _resolutionRoot = null; }
public void Dispose() { IDisposable disposable = resolver as IDisposable; if (disposable != null) disposable.Dispose(); resolver = null; }
/// <summary> /// Initializes a new instance of the <see cref="ChildKernel"/> class. /// </summary> /// <param name="parent">The parent.</param> /// <param name="modules">The modules.</param> public ChildKernel(IResolutionRoot parent, params INinjectModule[] modules) : base(modules) { this.parent = parent; this.Components.RemoveAll<IActivationCache>(); this.Components.Add<IActivationCache, ChildActivationCache>(); }
public void Dispose() { var disposable = resolver as IDisposable; disposable?.Dispose(); resolver = null; }
public void Dispose() { var root = this.resolutionRoot as IDisposable; if (root != null) root.Dispose(); resolutionRoot = null; }
public void Dispose() { IDisposable disposable = resolutionRoot as IDisposable; if (disposable != null) disposable.Dispose(); resolutionRoot = null; }
private static ChildKernel CreateAuthKernel(IResolutionRoot parent) { var kernel = new ChildKernel(parent, new ServerModule(), new AuthServerModule()); kernel.Rebind<IPacketCodeTable>().To<AuthPacketCodeTableV75>().InSingletonScope(); kernel.Rebind<IAuthenticator>().To<StubAuthenticator>().InSingletonScope(); kernel.Rebind<IAccountProvider>().To<StubAccountProvider>().InSingletonScope(); return kernel; }
public NinjectServiceScope( IResolutionRoot resolver, IEnumerable<IParameter> inheritedParameters) { _scope = new ScopeParameter(); inheritedParameters = inheritedParameters.AddOrReplaceScopeParameter(_scope); _serviceProvider = new NinjectServiceProvider(resolver, inheritedParameters.ToArray()); }
/// <summary> /// Initializes it all. /// </summary> public WcfBootstrapper(IEnumerable<OsWcfConfiguration> configurations, IResolutionRoot resolutionRoot, ILogger logger) : base(resolutionRoot, logger) { this.configurations = configurations.ToList(); this.hosts = new List<ServiceHost>(this.configurations.Count); this.isDisposed = false; }
public void Dispose() { var disposable = (IDisposable)resolutionRoot; if (disposable != null) { disposable.Dispose(); } resolutionRoot = null; }
public void Dispose() { var disposable = (IDisposable)ResolutionRoot; disposable?.Dispose(); ResolutionRoot = null; }
public object GetAllAsArray(IResolutionRoot resolutionRoot, Type type, IResolutionParameters resolutionParameters) { var list = this.GetAllAsList(resolutionRoot, type, resolutionParameters); return typeof(Enumerable) .GetTypeInfo() .GetDeclaredMethod("ToArray") .MakeGenericMethod(type) .Invoke(null, new[] { list }); }
public void Dispose() { var disposable = this.resolver as IDisposable; if (disposable != null) { disposable.Dispose(); } this.resolver = null; }
// The bulk of the clean-up code is implemented in Dispose(bool) protected virtual void Dispose(bool disposing) { if (disposing) { IDisposable disposable = (IDisposable)ResolutionRoot; if (disposable != null) disposable.Dispose(); ResolutionRoot = null; GC.SuppressFinalize(this); } }
/// <summary> /// The dispose. /// </summary> public void Dispose() { var disposable = this.resolutionRoot as IDisposable; if (disposable == null) { return; } disposable.Dispose(); this.resolutionRoot = null; }
protected virtual void Dispose(bool disposing) { var disposable = _resolver as IDisposable; if (disposable != null) { disposable.Dispose(); } _resolver = null; }
/// <summary> /// Initializes a new instance of the <see cref="ChildKernel"/> class. /// </summary> /// <param name="parent">The parent.</param> /// <param name="modules">The modules.</param> public ChildKernel(IResolutionRoot parent, params INinjectModule[] modules) : base(modules) { this.parent = parent; this.Components.RemoveAll<IActivationCache>(); this.Components.Add<IActivationCache, ChildActivationCache>(); this.Components.RemoveAll<IConstructorScorer>(); this.Components.Add<IConstructorScorer, StandardConstructorScorerForChildKernel>(); }
public void Dispose() { try { ((IDisposable)(resolver)).Dispose(); } finally { resolver = null; } }
public NinjectServiceScopeFactory(IContext context) { _resolver = context.Kernel.Get<IResolutionRoot>(); _inheritedParameters = context.Parameters.Where(p => p.ShouldInherit); var scopeParameter = _inheritedParameters.GetScopeParameter(); if (scopeParameter != null) { _fallbackProvider = scopeParameter.FallbackProvider; } }
protected virtual void Dispose(bool isDisposing) { if (isDisposing) { IDisposable disposable = resolver as IDisposable; if (disposable != null) { disposable.Dispose(); } resolver = null; } }
public void Dispose() { if (ResolutionRoot is IKernel) return; var disposable = ResolutionRoot as IDisposable; if (disposable != null) { disposable.Dispose(); } ResolutionRoot = null; }
private static IContextStore GetStore(IResolutionRoot kernel) { var store = kernel.TryGet<IContextStore>(); if (store == null) { throw new InvalidOperationException( "There is no IContextStore implementation registered in the container."); } return store; }
public SimpleBootstrapper(IResolutionRoot resolutionRoot, ILogger logger) : base(resolutionRoot, logger) { var nexus = new ChildKernel(this.ResolutionRoot, new NexusServerModule()); this.account = new ChildKernel(nexus, new AccountServerModule()); this.auth = CreateAuthKernel(nexus); this.world = new ChildKernel(nexus, new WorldServerModule()); this.channel = new ChildKernel(this.world, new ServerModule(), new ChannelServerModule()); // HACK :( nexus.Bind<IAccountService>().ToMethod(ctx => this.account.Get<IAccountService>()); }
public NinjectServiceScope( IResolutionRoot resolver, IEnumerable<IParameter> inheritedParameters) { _scope = new ScopeParameter(); inheritedParameters = inheritedParameters.AddOrReplaceScopeParameter(_scope); _serviceProvider = new NinjectServiceProvider(resolver, inheritedParameters.ToArray()); var httpContext = resolver.Get<IHttpContextAccessor>().HttpContext; if (httpContext != null) { httpContext.Items.Add(typeof(ScopeParameter).FullName, _scope); } }
public object GetAllAsList(IResolutionRoot resolutionRoot, Type type, IResolutionParameters resolutionParameters) { var listType = typeof(List<>).MakeGenericType(type).GetTypeInfo(); var list = listType.DeclaredConstructors.Single(x => !x.GetParameters().Any()).Invoke(new object[0]); var addMethod = listType.GetDeclaredMethod("Add"); IEnumerable<object> values = resolutionRoot.GetAll(type, resolutionParameters.Constraint, resolutionParameters.Parameters.ToArray()); foreach (var value in values) { addMethod.Invoke(list, new[] { value }); } return list; }
/// <summary> /// Tries to get an instance of the specified service by using the first binding that matches the specified constraint. /// </summary> /// <typeparam name="T">The service to resolve.</typeparam> /// <param name="root">The resolution root.</param> /// <param name="constraint">The constraint to apply to the binding.</param> /// <param name="parameters">The parameters to pass to the request.</param> /// <returns>An instance of the service, or <see langword="null"/> if no implementation was available.</returns> public static T TryGet <T>(this IResolutionRoot root, Func <IBindingMetadata, bool> constraint, params IParameter[] parameters) { return(TryGet(() => GetResolutionIterator(root, typeof(T), constraint, parameters, true, true).Cast <T>())); }
public RibbonToolControllerFactory(IResolutionRoot resolutionRoot) { this.resolutionRoot = resolutionRoot; }
/// <summary> /// Gets an instance of the specified service by using the first binding with the specified name. /// </summary> /// <param name="root">The resolution root.</param> /// <param name="service">The service to resolve.</param> /// <param name="name">The name of the binding.</param> /// <param name="parameters">The parameters to pass to the request.</param> /// <returns><c>True</c> if the request can be resolved; otherwise, <c>false</c>.</returns> public static bool CanResolve(this IResolutionRoot root, Type service, string name, params IParameter[] parameters) { return(CanResolve(root, service, b => b.Name == name, parameters, false, true)); }
/// <summary> /// Extensibility point - this method is called after the Kernel is configured and before service starts /// processing incoming request. /// </summary> /// <param name="resolutionRoot">Used to retrieve dependencies from Ninject.</param> protected virtual void OnInitilize(IResolutionRoot resolutionRoot) { }
/// <summary> /// Initializes a new instance of the <see cref="ActivationBlock"/> class. /// </summary> /// <param name="parent">The parent resolution root.</param> public ActivationBlock(IResolutionRoot parent) { Ensure.ArgumentNotNull(parent, "parent"); Parent = parent; }
public TaxiDriverManager(IResolutionRoot kernel) { _playerInfoManager = kernel.Get <IPlayerInfoManager>(); _workInfoManager = kernel.Get <IWorkInfoManager>(); }
public PropertiesTabViewModel(IEventAggregator eventAggregator, IResolutionRoot resolutionRoot) { this.eventAggregator = eventAggregator; this.resolutionRoot = resolutionRoot; ViewModels = new Dictionary <string, PropertyEditorModel>(); Title = "Properties"; //CreateNewInstancePropertyModel("CockpitBuilder.Common.PropertyEditors.MonitorPropertyEditorViewModel", true); //CreateNewInstancePropertyModel("CockpitBuilder.Common.PropertyEditors.LayoutPropertyEditorViewModel"); //var typeClass = Type.GetType("CockpitBuilder.Common.PropertyEditors.MonitorPropertyEditorViewModel"); ////Ninject.Parameters.Parameter[] param = { new ConstructorArgument("tag", 0, true) }; //var viewmodel = resolutionRoot.TryGet(typeClass); //var view = ViewLocator.LocateForModel(viewmodel, null, null); //ViewModelBinder.Bind(viewmodel, view, null); //PropertyViewModels.Add((PropertyEditorModel)viewmodel); //typeClass = Type.GetType("CockpitBuilder.Common.PropertyEditors.LayoutPropertyEditorViewModel"); ////Ninject.Parameters.Parameter[] param = { new ConstructorArgument("tag", 0, true) }; //viewmodel = resolutionRoot.TryGet(typeClass); //view = ViewLocator.LocateForModel(viewmodel, null, null); //ViewModelBinder.Bind(viewmodel, view, null); //PropertyViewModels.Add((PropertyEditorModel)viewmodel); //typeClass = Type.GetType("CockpitBuilder.Common.PropertyEditors.PushButtonAppearanceEditorViewModel"); //Ninject.Parameters.Parameter[] param1 = { new ConstructorArgument("tag", 0, true) }; //viewmodel = resolutionRoot.TryGet(typeClass, param1); //view = ViewLocator.LocateForModel(viewmodel, null, null); //ViewModelBinder.Bind(viewmodel, view, null); //PropertyViewModels.Add((PropertyEditorModel)viewmodel); //typeClass = Type.GetType("CockpitBuilder.Common.PropertyEditors.PushButtonBehaviorEditorViewModel"); //Ninject.Parameters.Parameter[] param2 = { new ConstructorArgument("tag", 1, true) }; //viewmodel = resolutionRoot.TryGet(typeClass, param2); //view = ViewLocator.LocateForModel(viewmodel, null, null); //ViewModelBinder.Bind(viewmodel, view, null); //PropertyViewModels.Add((PropertyEditorModel)viewmodel); //typeClass = Type.GetType("CockpitBuilder.Common.PropertyEditors.ThreeWayToggleSwitchAppearanceEditorViewModel"); //Ninject.Parameters.Parameter[] param1 = { new ConstructorArgument("tag", 0, true) }; //viewmodel = resolutionRoot.TryGet(typeClass, param1); //view = ViewLocator.LocateForModel(viewmodel, null, null); //ViewModelBinder.Bind(viewmodel, view, null); //PropertyViewModels.Add((PropertyEditorModel)viewmodel); //typeClass = Type.GetType("CockpitBuilder.Views.Main.DockPanel.Panels.UserViewModel"); //Ninject.Parameters.Parameter[] param1 = { new ConstructorArgument("tag", 0, true) }; //viewmodel = resolutionRoot.TryGet(typeClass, param1); //view = ViewLocator.LocateForModel(viewmodel, null, null); //ViewModelBinder.Bind(viewmodel, view, null); //PropertyViewModels.Add((PropertyEditorModel)viewmodel); //typeClass = Type.GetType("CockpitBuilder.Common.PropertyEditors.ThreeWayToggleSwitchBehaviorEditorViewModel"); //Ninject.Parameters.Parameter[] param2 = { new ConstructorArgument("tag", 1, true) }; //viewmodel = resolutionRoot.TryGet(typeClass, param2); //view = ViewLocator.LocateForModel(viewmodel, null, null); //ViewModelBinder.Bind(viewmodel, view, null); //PropertyViewModels.Add((PropertyEditorModel)viewmodel); //typeClass = Type.GetType("CockpitBuilder.Common.PropertyEditors.MonitorPropertyEditorViewModel"); //Ninject.Parameters.Parameter[] param2 = { new ConstructorArgument("tag", 1, true) }; //viewmodel = resolutionRoot.TryGet(typeClass, param2); //view = ViewLocator.LocateForModel(viewmodel, null, null); //ViewModelBinder.Bind(viewmodel, view, null); //PropertyViewModels.Add((PropertyEditorModel)viewmodel); //PropertyViewModels = new ObservableCollection<AboutViewModel> { "&é", "12", "azert" }; this.eventAggregator.Subscribe(this); }
internal NinjectDependencyScope(IResolutionRoot resolver) { Contract.Assert(resolver != null); this.resolver = resolver; }
public NinjectDependencyResolver(IResolutionRoot kernel) { _resolutionRoot = kernel; }
public NInjectDependencyScope(IResolutionRoot resolutionRoot) { _resolutionRoot = resolutionRoot; }
/// <summary> /// Initializes a new instance of the <see cref="Ninject.Web.WebApi.NinjectDependencyResolver"/> class. /// </summary> /// <param name="resolutionRoot">The resolution root.</param> public NinjectDependencyResolver(IResolutionRoot resolutionRoot) : base(resolutionRoot) { }
public NinjectDependencyScope(IResolutionRoot resolver) { _resolver = resolver; }
/// <summary> /// Tries to get an instance of the specified service by using the first binding with the specified name. /// </summary> /// <typeparam name="T">The service to resolve.</typeparam> /// <param name="root">The resolution root.</param> /// <param name="name">The name of the binding.</param> /// <param name="parameters">The parameters to pass to the request.</param> /// <returns>An instance of the service, or <see langword="null"/> if no implementation was available.</returns> public static T TryGet <T>(this IResolutionRoot root, string name, params IParameter[] parameters) { return(TryGet(() => GetResolutionIterator(root, typeof(T), b => b.Name == name, parameters, true, true).Cast <T>())); }
public NinjectScope(IResolutionRoot kernel) { resolutionRoot = kernel; }
/// <summary> /// Gets an instance of the specified service by using the first binding with the specified name. /// </summary> /// <typeparam name="T">The service to resolve.</typeparam> /// <param name="root">The resolution root.</param> /// <param name="name">The name of the binding.</param> /// <param name="parameters">The parameters to pass to the request.</param> /// <returns>An instance of the service.</returns> public static T Get <T>(this IResolutionRoot root, string name, params IParameter[] parameters) { return(GetResolutionIterator(root, typeof(T), b => b.Name == name, parameters, false, true).Cast <T>().Single()); }
public ConfigEventFactory(IResolutionRoot resolutionRoot) { _resolutionRoot = resolutionRoot; }
private static T DoTryGetAndThrowOnInvalidBinding <T>(IResolutionRoot root, Func <IBindingMetadata, bool> constraint, IEnumerable <IParameter> parameters) { return(GetResolutionIterator(root, typeof(T), constraint, parameters, true, true, true).Cast <T>().SingleOrDefault()); }
public Client(ServerData shd, IResolutionRoot kernel) { _shd = shd; _gameService = kernel.Get <IGameService>(); _userService = kernel.Get <IUserService>(); }
/// <summary> /// Gets an instance of the specified service by using the first binding that matches the specified constraint. /// </summary> /// <param name="root">The resolution root.</param> /// <param name="service">The service to resolve.</param> /// <param name="constraint">The constraint to apply to the binding.</param> /// <param name="parameters">The parameters to pass to the request.</param> /// <returns><c>True</c> if the request can be resolved; otherwise, <c>false</c>.</returns> public static bool CanResolve(this IResolutionRoot root, Type service, Func <IBindingMetadata, bool> constraint, params IParameter[] parameters) { return(CanResolve(root, service, constraint, parameters, false, true)); }
/// <summary> /// Gets all instances of the specified service using bindings registered with the specified name. /// </summary> /// <typeparam name="T">The service to resolve.</typeparam> /// <param name="root">The resolution root.</param> /// <param name="name">The name of the binding.</param> /// <param name="parameters">The parameters to pass to the request.</param> /// <returns>A series of instances of the service.</returns> public static IEnumerable <T> GetAll <T>(this IResolutionRoot root, string name, params IParameter[] parameters) { return(GetResolutionIterator(root, typeof(T), b => b.Name == name, parameters, true, false).Cast <T>()); }
public void Dispose() { resolver = null; }
/// <summary> /// Gets all instances of the specified service by using the bindings that match the specified constraint. /// </summary> /// <typeparam name="T">The service to resolve.</typeparam> /// <param name="root">The resolution root.</param> /// <param name="constraint">The constraint to apply to the bindings.</param> /// <param name="parameters">The parameters to pass to the request.</param> /// <returns>A series of instances of the service.</returns> public static IEnumerable <T> GetAll <T>(this IResolutionRoot root, Func <IBindingMetadata, bool> constraint, params IParameter[] parameters) { return(GetResolutionIterator(root, typeof(T), constraint, parameters, true, false).Cast <T>()); }
public NinjectDependencyResolver(IResolutionRoot container, IKernel kernel) { _container = container; _kernel = kernel; }
/// <summary> /// Gets an instance of the specified service by using the first binding with the specified name. /// </summary> /// <param name="root">The resolution root.</param> /// <param name="service">The service to resolve.</param> /// <param name="name">The name of the binding.</param> /// <param name="parameters">The parameters to pass to the request.</param> /// <returns>An instance of the service.</returns> public static object Get(this IResolutionRoot root, Type service, string name, params IParameter[] parameters) { return(GetResolutionIterator(root, service, b => b.Name == name, parameters, false, true).Single()); }
/// <summary> /// Tries to get an instance of the specified service. /// </summary> /// <typeparam name="T">The service to resolve.</typeparam> /// <param name="root">The resolution root.</param> /// <param name="parameters">The parameters to pass to the request.</param> /// <returns>An instance of the service, or <see langword="null"/> if no implementation was available.</returns> public static T TryGetAndThrowOnInvalidBinding <T>(this IResolutionRoot root, params IParameter[] parameters) { return(DoTryGetAndThrowOnInvalidBinding <T>(root, null, parameters)); }
/// <summary> /// Initializes a new instance of the <see cref="SelfHostNinjectDependencyScope"/> class. /// </summary> /// <param name="resolutionRoot">The resolution root.</param> public SelfHostNinjectDependencyScope(IResolutionRoot resolutionRoot) : base(resolutionRoot) { }
/// <summary> /// Tries to get an instance of the specified service by using the first binding with the specified name. /// </summary> /// <typeparam name="T">The service to resolve.</typeparam> /// <param name="root">The resolution root.</param> /// <param name="name">The name of the binding.</param> /// <param name="parameters">The parameters to pass to the request.</param> /// <returns>An instance of the service, or <see langword="null"/> if no implementation was available.</returns> public static T TryGetAndThrowOnInvalidBinding <T>(this IResolutionRoot root, string name, params IParameter[] parameters) { return(DoTryGetAndThrowOnInvalidBinding <T>(root, b => b.Name == name, parameters)); }
/// <summary> /// Tries to get an instance of the specified service by using the first binding that matches the specified constraint. /// </summary> /// <typeparam name="T">The service to resolve.</typeparam> /// <param name="root">The resolution root.</param> /// <param name="constraint">The constraint to apply to the binding.</param> /// <param name="parameters">The parameters to pass to the request.</param> /// <returns>An instance of the service, or <see langword="null"/> if no implementation was available.</returns> public static T TryGetAndThrowOnInvalidBinding <T>(this IResolutionRoot root, Func <IBindingMetadata, bool> constraint, params IParameter[] parameters) { return(DoTryGetAndThrowOnInvalidBinding <T>(root, constraint, parameters)); }
public CommandEnumerator(IResolutionRoot localRoot) { this.localRoot = localRoot; }
/// <summary> /// The assign. /// </summary> /// <param name="resolutionRoot"> /// The resolution root. /// </param> public void Assign(IResolutionRoot resolutionRoot) { this.m_ResolutionRoot = resolutionRoot; }