• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IResolutionRoot类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IResolutionRoot的典型用法代码示例。如果您正苦于以下问题:C# IResolutionRoot类的具体用法?C# IResolutionRoot怎么用?C# IResolutionRoot使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IResolutionRoot类属于命名空间,在下文中一共展示了IResolutionRoot类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Resolve

        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());
        }
开发者ID:BrunoJuchli,项目名称:ninject.extensions.staticproxy,代码行数:28,代码来源:InstanceResolver.cs


示例2: NinjectDependencyScope

        public NinjectDependencyScope(IResolutionRoot resolver)
        {
            if (resolver == null)
                throw new ArgumentNullException("resolver");

            this.resolver = resolver;
        }
开发者ID:pieterderycke,项目名称:BeerStockExchange,代码行数:7,代码来源:NinjectDependencyScope.cs


示例3: ChildKernel

 /// <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>();
 }
开发者ID:tgeens,项目名称:ninject.extensions.childkernel,代码行数:12,代码来源:ChildKernel.cs


示例4: NinjectServiceScope

 public NinjectServiceScope(
     IResolutionRoot resolver,
     IEnumerable<IParameter> inheritedParameters)
 {
     _scope = new ScopeParameter();
     inheritedParameters = inheritedParameters.AddOrReplaceScopeParameter(_scope);
     _serviceProvider = new NinjectServiceProvider(resolver, inheritedParameters.ToArray());
 }
开发者ID:stevenliujw,项目名称:DependencyInjection,代码行数:8,代码来源:NinjectServiceScopeFactory.cs


示例5: CreateAuthKernel

 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;
 }
开发者ID:shoftee,项目名称:OpenStory,代码行数:8,代码来源:SimpleBootstrapper.cs


示例6: WcfBootstrapper

        /// <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;
        }
开发者ID:shoftee,项目名称:OpenStory,代码行数:11,代码来源:WcfBootstrapper.cs


示例7: GetAllAsArray

 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 });
 }
开发者ID:BrunoJuchli,项目名称:ninject.extensions.staticproxy,代码行数:9,代码来源:InstanceResolver.cs


示例8: ChildKernel

        /// <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>();
        }
开发者ID:mikkelfish,项目名称:ninject.extensions.childkernel,代码行数:15,代码来源:ChildKernel.cs


示例9: NinjectServiceScopeFactory

        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;
            }
        }
开发者ID:pranavkm,项目名称:DependencyInjection,代码行数:11,代码来源:NinjectServiceScopeFactory.cs


示例10: GetStore

        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;
        }
开发者ID:endjin,项目名称:openrasta-stable,代码行数:12,代码来源:PerRequestProvider.cs


示例11: SimpleBootstrapper

        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>());
        }
开发者ID:shoftee,项目名称:OpenStory,代码行数:13,代码来源:SimpleBootstrapper.cs


示例12: NinjectServiceScope

            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);
                }
            }
开发者ID:Life1ess,项目名称:Ninject.Web.Mvc6,代码行数:15,代码来源:NinjectServiceScopeFactory.cs


示例13: GetAllAsList

        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;
        }
开发者ID:BrunoJuchli,项目名称:ninject.extensions.staticproxy,代码行数:15,代码来源:InstanceResolver.cs


示例14: Dispose

 public void Dispose()
 {
     //IDisposable disposable = resolver as IDisposable;
     //if (disposable != null)
     //    disposable.Dispose();
     resolver = null;
 }
开发者ID:305088020,项目名称:ChART,代码行数:7,代码来源:NinjectDependencyScope.cs


示例15: Dispose

 public void Dispose()
 {
     var disposable = _resolver as IDisposable;
     if (disposable != null)
         disposable.Dispose();
     _resolver = null;
 }
开发者ID:jmptrader,项目名称:spa-template,代码行数:7,代码来源:DependencyScope.cs


示例16: NinjectDependencyResolver

        public NinjectDependencyResolver()
        {
            IKernel kernel = new StandardKernel();
            resolutionRoot = kernel;

            DoBindings(kernel);
        }
开发者ID:Nordis,项目名称:Mvc4WebApiRavenDb,代码行数:7,代码来源:NinjectDependencyResolver.cs


示例17: Dispose

 public void Dispose()
 {
     IDisposable disposable = resolver as IDisposable;
     if (disposable != null)
         disposable.Dispose();
     resolver = null;
 }
开发者ID:zicjin,项目名称:SpiderMan,代码行数:7,代码来源:NinjectDependencyScope.cs


示例18: Dispose

 public void Dispose()
 {
     var disposable = _resolutionRoot as IDisposable;
     if(disposable!=null)
         disposable.Dispose();
     _resolutionRoot = null;
 }
开发者ID:tugberkugurlu,项目名称:ProWebAPI.Samples,代码行数:7,代码来源:NInjectDependencyScope.cs


示例19: Dispose

        public void Dispose()
        {
            var disposable = resolver as IDisposable;

            disposable?.Dispose();

            resolver = null;
        }
开发者ID:COTB,项目名称:k94warriors,代码行数:8,代码来源:NinjectDependencyScope.cs


示例20: Dispose

        public void Dispose()
        {
            var root = this.resolutionRoot as IDisposable;
            if (root != null)
                root.Dispose();

            resolutionRoot = null;
        }
开发者ID:julplee,项目名称:NinjectWithMvcAndWebApi,代码行数:8,代码来源:NinjectDependencyScope.cs



注:本文中的IResolutionRoot类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IResolver类代码示例发布时间:2022-05-24
下一篇:
C# IRequestOptions类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap