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


C# ILifetimeScope.Resolve方法代码示例

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


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

示例1: Resolve

        protected override void Resolve(ILifetimeScope container) {
            _compositionStrategy = container.Resolve<CompositionStrategy>();
            _compositionStrategy.Logger = container.Resolve<ILogger>();

            var alphaExtension = new ExtensionDescriptor {
                Id = "Alpha",
                Name = "Alpha",
                ExtensionType = "Module"
            };

            var alphaFeatureDescriptor = new FeatureDescriptor {
                Id = "Alpha",
                Name = "Alpha",
                Extension = alphaExtension
            };

            var betaFeatureDescriptor = new FeatureDescriptor {
                Id = "Beta",
                Name = "Beta",
                Extension = alphaExtension,
                Dependencies = new List<string> {
                    "Alpha"
                }
            };

            alphaExtension.Features = new List<FeatureDescriptor> {
                alphaFeatureDescriptor,
                betaFeatureDescriptor
            };

            _availableExtensions = new[] {
                alphaExtension
            };

            _installedFeatures = new List<Feature> {
                new Feature {
                    Descriptor = alphaFeatureDescriptor,
                    ExportedTypes = new List<Type> {
                        typeof(AlphaDependency)
                    }
                },
                new Feature {
                    Descriptor = betaFeatureDescriptor,
                    ExportedTypes = new List<Type> {
                        typeof(BetaDependency)
                    }
                }
            };

            _loggerMock.Setup(x => x.IsEnabled(It.IsAny<LogLevel>())).Returns(true);

            _extensionManager.Setup(x => x.AvailableExtensions()).Returns(() => _availableExtensions);

            _extensionManager.Setup(x => x.AvailableFeatures()).Returns(() =>
                _extensionManager.Object.AvailableExtensions()
                .SelectMany(ext => ext.Features)
                .ToReadOnlyCollection());

            _extensionManager.Setup(x => x.LoadFeatures(It.IsAny<IEnumerable<FeatureDescriptor>>())).Returns(() => _installedFeatures);
        }
开发者ID:Higea,项目名称:Orchard,代码行数:60,代码来源:CompositionStrategyTests.cs

示例2: RequestStartup

        protected override void RequestStartup(ILifetimeScope container, IPipelines pipelines, NancyContext context)
        {
            // No registrations should be performed in here, however you may
            // resolve things that are needed during request startup.

            FormsAuthentication.Enable(pipelines, new FormsAuthenticationConfiguration()
            {
                RedirectUrl = "~/account/login",
                UserMapper = container.Resolve<IUserMapper>(),
            });

            pipelines.BeforeRequest.AddItemToEndOfPipeline(c =>
            {
                if (c.CurrentUser.IsAuthenticated())
                {
                    container.Resolve<ITenantContext>().SetTenantId(c.CurrentUser.AsAuthenticatedUser().Id, c.CurrentUser.HasClaim("Admin"));
                    c.ViewBag.UserName = c.CurrentUser.AsAuthenticatedUser().FullName;
                    c.ViewBag.IsAdmin = c.CurrentUser.HasClaim("Admin");
                }
                else
                    container.Resolve<ITenantContext>().SetTenantId(null, false);

                return null;
            });
        }
开发者ID:kcornelis,项目名称:FreelanceManager.NET,代码行数:25,代码来源:NancyTestBootstrapper.cs

示例3: ApplicationStartup

        protected override void ApplicationStartup(ILifetimeScope container, IPipelines pipelines)
        {
            StaticConfiguration.DisableErrorTraces = false;

              // Enable memory sessions, and secure them against session hijacking
              pipelines.EnableInProcSessions();
              pipelines.BeforeRequest.AddItemToStartOfPipeline(ctx => {
            var antiSessionHijackLogic = container.Resolve<IAntiSessionHijackLogic>();
            return antiSessionHijackLogic.InterceptHijackedSession(ctx.Request);
              });
              pipelines.AfterRequest.AddItemToEndOfPipeline(ctx => {
            var antiSessionHijackLogic = container.Resolve<IAntiSessionHijackLogic>();
            antiSessionHijackLogic.ProtectResponseFromSessionHijacking(ctx);
              });

              // Load the user from the AspNet session. If one is found, create a Nancy identity and assign it.
              pipelines.BeforeRequest.AddItemToEndOfPipeline(ctx => {
            var identityAssigner = container.Resolve<INancyIdentityFromContextAssigner>();
            identityAssigner.AssignNancyIdentityFromContext(ctx);
            return null;
              });

              pipelines.OnError = pipelines.OnError
            + ErrorPipelines.HandleModelBindingException()
            + ErrorPipelines.HandleRequestValidationException()
            + ErrorPipelines.HandleSecurityException();

              base.ApplicationStartup(container, pipelines);
        }
开发者ID:DavidLievrouw,项目名称:InvoiceGen,代码行数:29,代码来源:Bootstrapper.cs

示例4: OnStartScope

        public void OnStartScope(ILifetimeScope scope)
        {
            var defaultFactoryMapper = scope.Resolve<IFactoryMapper>() as DefaultFactoryMapper;
            defaultFactoryMapper?.PerformAutomaticMappingByAttribute();

            var storageMap = scope.Resolve<IConfigurationToExtentStorageMapper>() as ManualConfigurationToExtentStorageMapper;
            storageMap?.PerformMappingForConfigurationOfExtentLoaders();
        }
开发者ID:mbrenn,项目名称:datenmeister-new,代码行数:8,代码来源:DotNetIntegrationHooks.cs

示例5: PingHub

        public PingHub(ILifetimeScope lifetimeScope)
        {
            // Create a lifetime scope for this hub instance.
            _hubLifetimeScope = lifetimeScope.BeginLifetimeScope();

            // Resolve the dependencies from the hub lifetime scope (unfortunately, service locator style).
            _bar = _hubLifetimeScope.Resolve<IBar>();
            _foo = _hubLifetimeScope.Resolve<IFoo>();
        }
开发者ID:FukKwang,项目名称:SignalRSamples,代码行数:9,代码来源:PingHub.cs

示例6: ResetState

 public INavigationService ResetState()
 {
     using (var oldScope = currentScope)
     {
         currentScope = rootScope.BeginLifetimeScope();
         mainWindow.DataContext = currentScope.Resolve<IMainWindowViewModel>();
         return currentScope.Resolve<INavigationService>();
     }
 }
开发者ID:kingkino,项目名称:azure-documentdb-datamigrationtool,代码行数:9,代码来源:ApplicationController.cs

示例7: CommonHub

        public CommonHub(ILifetimeScope lifetimeScope)
        {
            // Create a lifetime scope for the hub.
            _hubLifetimeScope = lifetimeScope.BeginLifetimeScope();

            // Resolve dependencies from the hub lifetime scope
            _documentService = _hubLifetimeScope.Resolve<IDocumentsService>(); // singleton
            _tableService = _hubLifetimeScope.Resolve<ITableService>(); // singleton
            _counterService = _hubLifetimeScope.Resolve<IDistributedCounter>(); // singleton
        }
开发者ID:Enttoi,项目名称:enttoi-api,代码行数:10,代码来源:CommonHub.cs

示例8: EnsureProfileProperties

 private void EnsureProfileProperties(ILifetimeScope scope, ITargetingProfileConfig config, SPSite site)
 {
     var logger = scope.Resolve<ILogger>();
     var userProfilePropertyHelper = scope.Resolve<IUserProfilePropertyHelper>();
     foreach (var userProfilePropertyInfo in config.UserProfileProperties)
     {
         logger.Info("Ensuring profile property '{0}'", userProfilePropertyInfo.Name);
         userProfilePropertyHelper.EnsureProfileProperty(site, userProfilePropertyInfo);
     }
 }
开发者ID:GSoft-SharePoint,项目名称:Dynamite-Components,代码行数:10,代码来源:XSP_ProfileTargeting.EventReceiver.cs

示例9: ApplicationStartup

        protected override void ApplicationStartup(ILifetimeScope container, IPipelines pipelines)
        {
            var generator = container.Resolve<IFrankengenerator>();
            var store = container.Resolve<IFrankenstore>();
            var rootPathProvider = container.Resolve<IRootPathProvider>();
            var wikiSourcePathSetting = container.Resolve<WikiSourcePathSetting>();
            var sourcePath = Path.Combine(rootPathProvider.GetRootPath(), wikiSourcePathSetting);

            generator.GenerateFromSource(sourcePath, store);
        }
开发者ID:bendetat,项目名称:frankenwiki,代码行数:10,代码来源:Bootstrapper.cs

示例10: ApplicationStartup

        protected override void ApplicationStartup(ILifetimeScope container, IPipelines pipelines)
        {
            var customPipelines = new PipelinesBuilder()
               .WithErrorHandling(container.Resolve<IResponseNegotiator>(), container.Resolve<INancyErrorMap>())
               .Build();

            pipelines.BeforeRequest += customPipelines.BeforeRequest;
            pipelines.AfterRequest += customPipelines.AfterRequest;
            pipelines.OnError += customPipelines.OnError;

            base.ApplicationStartup(container, pipelines);
        }
开发者ID:onatm,项目名称:futurice.challenge,代码行数:12,代码来源:Bootstrapper.cs

示例11: MainWindow

        public MainWindow()
        {
            InitializeComponent();
     
            this.Loaded += MainWindow_Loaded;
            _container = ContainerHost.Container;
            _deviceService = _container.Resolve<IDeviceService>();
            _userService = _container.Resolve<IUserService>();
            this.Register<LogoutAndShowMainMessage>(_reshowThis);

            XDispatcher.Dispatcher = Dispatcher;

        }
开发者ID:jakkaj,项目名称:DayBar,代码行数:13,代码来源:MainWindow.xaml.cs

示例12: MainMenu

		public MainMenu ()
		{
			InitializeComponent ();

			Master = _master = new MainMenuView ();

			_scope = App.AutoFacContainer.BeginLifetimeScope ();

			var mainNav = new NavigationPage (_scope.Resolve<DashboardPage>());

			//var msg = new NotificationMessage<IDictionary<string, int>>(new Dictionary<string, int>(), _loadingMsgId);
			//msg.Content.Add("Mode", 0);

			//Messenger.Default.Send<NotificationMessage<IDictionary<string, int>>> (msg, _loadingMsgId);

			Detail = mainNav;

			this.Icon = "slideout.png";

			_master.PageSelectionChanged = (measurementTypeDefId) => {

				IDictionary<string, int> msgSelectionChanged = new Dictionary<string, int>();
				msgSelectionChanged.Add("DefinitionId", measurementTypeDefId);
				msgSelectionChanged.Add("Mode", 0);
				var page = App.NavigationService.MasterNavigateTo (MeasurementPage.PageName, msgSelectionChanged);
				Detail = new NavigationPage(page);
				Detail.Title = page.Title;
				IsPresented = false;
			};
		}
开发者ID:jscote,项目名称:Meezure,代码行数:30,代码来源:MainMenu.xaml.cs

示例13: GetValidator

        /// <summary>
        /// Получить экземпляр типа <see cref="SqlDateTimeValidator"/>.
        /// </summary>
        /// <returns>Экземпляр валидатора.</returns>
        public override IValidator GetValidator(ILifetimeScope scope)
        {
            var validator = scope.Resolve<SqlDateTimeValidator>();
            validator.Message = ErrorMessage;

            return validator;
        }
开发者ID:ChessOK,项目名称:ModelFramework,代码行数:11,代码来源:SqlDateTimeAttribute.cs

示例14: MessageFeedbackProcessor

        public MessageFeedbackProcessor(
            ILifetimeScope scope,
            IDeviceLogic deviceLogic)
        {
            IConfigurationProvider configProvider;

            if (scope == null)
            {
                throw new ArgumentNullException("scope");
            }

            if (deviceLogic == null)
            {
                throw new ArgumentNullException("deviceLogic");
            }

            configProvider = scope.Resolve<IConfigurationProvider>();
            _iotHubConnectionString = 
                configProvider.GetConfigurationSettingValue(
                    "iotHub.ConnectionString");

            if (string.IsNullOrEmpty(_iotHubConnectionString))
            {
                throw new InvalidOperationException(
                    "Cannot find configuration setting: \"iotHub.ConnectionString\".");
            }

            _deviceLogic = deviceLogic;
        }
开发者ID:smartpcr,项目名称:azure-iot-remote-monitoring,代码行数:29,代码来源:MessageFeedbackProcessor.cs

示例15: Application_Startup

        private void Application_Startup(object sender, StartupEventArgs e)
        {
            _scope = Container.BeginLifetimeScope();
              _scope.Resolve<ApplicationWindow>().Show();

              Messenger.Default.Send(new ApplicationMessage(NotificationKind.Initialized));
        }
开发者ID:arghlolrofl,项目名称:visualstudiosnippeteditor,代码行数:7,代码来源:App.xaml.cs


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