当前位置: 首页>>代码示例>>C#>>正文


C# ILifetimeScope.TryResolve方法代码示例

本文整理汇总了C#中ILifetimeScope.TryResolve方法的典型用法代码示例。如果您正苦于以下问题:C# ILifetimeScope.TryResolve方法的具体用法?C# ILifetimeScope.TryResolve怎么用?C# ILifetimeScope.TryResolve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ILifetimeScope的用法示例。


在下文中一共展示了ILifetimeScope.TryResolve方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetModule

		protected override INancyModule GetModule(ILifetimeScope container, Type moduleType)
		{
			RequiresNotNull(container);
			RequiresNotNull(moduleType);
			object module;
			return container.TryResolve(moduleType, out module) ? (INancyModule) module : null;
		}
开发者ID:jairov4,项目名称:Yorkfield,代码行数:7,代码来源:NancyBootstrapper.cs

示例2: BaseCustomActionsManager

        /// <summary>
        /// Initialises a new instance of the BaseCustomActionsManager class 
        /// using the specified extra suffix and the assembly of the actual type of this class.
        /// </summary>
        protected BaseCustomActionsManager(ILifetimeScope container, string extraSuffix, IEnumerable<ImplementorAssembly> assemblies)
        {
            if (container == null) { throw new ArgumentNullException("container"); }
            if (assemblies == null) { throw new ArgumentNullException("assemblies"); }

            _container = container;
            // Each assembly only once. Thus assemblies will be registered by modules throug Autofac it cannot be guaranteed that this will happen only once per assembly.
            _assemblies = assemblies.Distinct().ToList();

            ExtraSuffix = extraSuffix;
            ImplementationAssemblyName = this.GetType().Assembly.FullName;

            container.TryResolve<IAssetsManager>(out _assetsMgr);
            cfg = container.Resolve<ZetboxConfig>();
        }
开发者ID:daszat,项目名称:zetbox,代码行数:19,代码来源:BaseCustomActionsManager.cs

示例3: CreateTask

        private ITask CreateTask(ILifetimeScope timerScope)
        {
            ITask task = null;
            if (this.Enabled)
            {
                var type2 = System.Type.GetType(this.Type);
                if (type2 != null)
                {
                    object instance;
                    if (!timerScope.TryResolve(type2, out instance))
                    {
                        instance = ResolveUnregistered(timerScope,type2);
                    }

                    task = instance as ITask;
                }
            }
            return task;
        }
开发者ID:zraja90,项目名称:MyApps,代码行数:19,代码来源:Task.cs


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