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


C# IServiceLocator.RegisterInstance方法代码示例

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


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

示例1: Initialize

        /// <summary>
        /// Initializes the specified service locator.
        /// </summary>
        /// <param name="serviceLocator">The service locator.</param>
        public void Initialize(IServiceLocator serviceLocator)
        {
            Argument.IsNotNull("serviceLocator", serviceLocator);

            serviceLocator.RegisterType<ILanguageService, LanguageService>();
            serviceLocator.RegisterInstance<IExceptionService>(ExceptionService.Default);
            serviceLocator.RegisterInstance<IMessageMediator>(MessageMediator.Default);

            serviceLocator.RegisterType<IValidatorProvider, AttributeValidatorProvider>();
            serviceLocator.RegisterType<IRegistrationConventionHandler, RegistrationConventionHandler>();

#if NET
            serviceLocator.RegisterType<IBinarySerializer, BinarySerializer>();
            serviceLocator.RegisterTypeWithTag<ISerializationContextInfoFactory, BinarySerializationContextInfoFactory>(typeof(BinarySerializer));
#endif
            serviceLocator.RegisterType<IDataContractSerializerFactory, DataContractSerializerFactory>();
            serviceLocator.RegisterType<IXmlSerializer, XmlSerializer>();
            serviceLocator.RegisterType<IXmlNamespaceManager, XmlNamespaceManager>();
            serviceLocator.RegisterType<ISerializationManager, SerializationManager>();
            serviceLocator.RegisterType<IObjectAdapter, ObjectAdapter>();

            serviceLocator.RegisterType<ISerializer, XmlSerializer>();
            serviceLocator.RegisterTypeWithTag<ISerializationContextInfoFactory, XmlSerializationContextInfoFactory>(typeof(XmlSerializer));

            serviceLocator.RegisterType<IModelEqualityComparer, ModelEqualityComparer>();
            serviceLocator.RegisterType<IConfigurationService, ConfigurationService>();
            serviceLocator.RegisterType<IObjectConverterService, ObjectConverterService>();
            serviceLocator.RegisterType<IRollingInMemoryLogService, RollingInMemoryLogService>();
        }
开发者ID:Catel,项目名称:Catel,代码行数:33,代码来源:CoreModule.cs

示例2: Configure

        /// <summary>
        /// Configures the specified IoC container with the type resolutions from this library.
        /// </summary>
        public void Configure(IServiceLocator container)
        {
            var cardComparer = new CardComparer();
            container.RegisterInstance<IComparer<Card>>(cardComparer);

            var highCardComparer = new HighCardComparer(cardComparer);
            var handComparer = new HandComparer(
                highCardComparer,
                new PairComparer(highCardComparer),
                new TwoPairComparer(),
                new ThreeOfAKindComparer(highCardComparer),
                new StraightComparer(),
                new FlushComparer(highCardComparer),
                new FullHouseComparer(highCardComparer),
                new FourOfAKindComparer(highCardComparer),
                new StraightFlushComparer());
            container.RegisterInstance<IHandComparer>(handComparer);

            container.RegisterInstance<Func<List<Card>, IHand>>(
                cards => new Hand(
                    cards,
                    cardComparer,
                    handComparer));

            container.RegisterInstance<Func<ICollection<IPlayer>, IGame>>(
                players => new Game(
                    container.ResolveType<IDeckFactory>().CreateStandardDeck(),
                    players,
                    container.ResolveType<IComparer<IPlayer>>(),
                    container.ResolveType<Func<List<Card>, IHand>>()));
        }
开发者ID:Trezamere,项目名称:Poker,代码行数:34,代码来源:Bootstrapper.cs

示例3: Configure

        /// <summary>
        /// Configures the specified IoC container with the type resolutions from this library.
        /// </summary>
        public void Configure(IServiceLocator container)
        {
            container.RegisterInstance<Func<IPlayerConfigurationViewModel>>(() => new PlayerConfigurationViewModel(container.ResolveType<IPlayerConfiguration>()));
            container.RegisterInstance<Func<IRoundResult, IRoundResultViewModel>>(result => new RoundResultViewModel(result));
            container.RegisterInstance<Func<IEnumerable<IPlayer>, IEnumerable<IPlayer>, IRoundResult>>((winners, losers) => new RoundResult(winners, losers));

            var viewModelLocator = container.ResolveType<IViewModelLocator>();
            viewModelLocator.Register(typeof (MainWindow), typeof (MainWindowViewModel));

            var uiVisualizerService = container.ResolveType<IUIVisualizerService>();
            uiVisualizerService.Register(typeof(PlayerConfigurationViewModel), typeof(PlayerConfigurationView));
            uiVisualizerService.Register(typeof(RoundResultViewModel), typeof(RoundResultView));
        }
开发者ID:Trezamere,项目名称:Poker,代码行数:16,代码来源:Bootstrapper.cs

示例4: RegisterServices

        /// <summary>
        /// Registers the services in the specified <see cref="IServiceLocator" />.
        /// </summary>
        /// <param name="serviceLocator">The service locator.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="serviceLocator"/> is <c>null</c>.</exception>
        public static void RegisterServices(IServiceLocator serviceLocator)
        {
            Argument.IsNotNull(() => serviceLocator);

            if (!serviceLocator.IsTypeRegistered<IMementoService>())
            {
                serviceLocator.RegisterInstance(MementoService.Default);
            }
        }
开发者ID:paytonli2013,项目名称:Catel,代码行数:14,代码来源:ExtensionsMementoModule.cs

示例5: Initialize

        /// <summary>
        /// Initializes the specified service locator.
        /// </summary>
        /// <param name="serviceLocator">The service locator.</param>
        public void Initialize(IServiceLocator serviceLocator)
        {
            Argument.IsNotNull("serviceLocator", serviceLocator);

            if (!serviceLocator.IsTypeRegistered<IMementoService>())
            {
                serviceLocator.RegisterInstance(MementoService.Default);
            }
        }
开发者ID:Catel,项目名称:Catel,代码行数:13,代码来源:ExtensionsMementoModule.cs

示例6: RegisterServices

        /// <summary>
        /// Registers the services in the specified <see cref="IServiceLocator" />.
        /// </summary>
        /// <param name="serviceLocator">The service locator.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="serviceLocator"/> is <c>null</c>.</exception>
        public static void RegisterServices(IServiceLocator serviceLocator)
        {
            Argument.IsNotNull(() => serviceLocator);

            serviceLocator.RegisterInstance<IExceptionService>(ExceptionService.Default);
            serviceLocator.RegisterInstance<IMessageMediator>(MessageMediator.Default);

            serviceLocator.RegisterTypeIfNotYetRegistered<IValidatorProvider, AttributeValidatorProvider>();

#if NET
            serviceLocator.RegisterType<IBinarySerializer, BinarySerializer>();
#endif

            serviceLocator.RegisterType<IDataContractSerializerFactory, DataContractSerializerFactory>();
            serviceLocator.RegisterType<IXmlSerializer, XmlSerializer>();
            serviceLocator.RegisterType<IXmlNamespaceManager, XmlNamespaceManager>();
            serviceLocator.RegisterType<ISerializationManager, SerializationManager>();

            serviceLocator.RegisterType<IModelEqualityComparer, ModelEqualityComparer>();
        }
开发者ID:paytonli2013,项目名称:Catel,代码行数:25,代码来源:CoreModule.cs

示例7: Initialize

        /// <summary>
        /// Initializes the specified service locator.
        /// </summary>
        /// <param name="serviceLocator">The service locator.</param>
        public void Initialize(IServiceLocator serviceLocator)
        {
            Argument.IsNotNull(() => serviceLocator);

            serviceLocator.RegisterType<ILanguageService, LanguageService>();
            serviceLocator.RegisterInstance<IExceptionService>(ExceptionService.Default);
            serviceLocator.RegisterInstance<IMessageMediator>(MessageMediator.Default);

            serviceLocator.RegisterType<IValidatorProvider, AttributeValidatorProvider>();
            serviceLocator.RegisterType<IRegistrationConventionHandler, RegistrationConventionHandler>();

#if NET
            serviceLocator.RegisterType<IBinarySerializer, BinarySerializer>();
#endif

            serviceLocator.RegisterType<IDataContractSerializerFactory, DataContractSerializerFactory>();
            serviceLocator.RegisterType<IXmlSerializer, XmlSerializer>();
            serviceLocator.RegisterType<IXmlNamespaceManager, XmlNamespaceManager>();
            serviceLocator.RegisterType<ISerializationManager, SerializationManager>();

            serviceLocator.RegisterType<IModelEqualityComparer, ModelEqualityComparer>();
            serviceLocator.RegisterType<IConfigurationService, ConfigurationService>();
        }
开发者ID:JaysonJG,项目名称:Catel,代码行数:27,代码来源:CoreModule.cs

示例8: OnStartup

        //private static readonly ILog log = LogManager.GetLogger(typeof (Program)) ;
        


        /// <summary>
        /// Raises the <see cref="E:System.Windows.Application.Startup"/> event.
        /// </summary>
        /// <param name="e">A <see cref="T:System.Windows.StartupEventArgs"/> that contains the event data.</param>
        protected override void OnStartup(StartupEventArgs e)
        {
            _versionNumber = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
            _log.InfoFormat("Starting Safe and Sound 2015 version {0}", _versionNumber);


            base.OnStartup(e);
#if DEBUG
            Catel.Logging.LogManager.RegisterDebugListener();
           
#endif

            StyleHelper.CreateStyleForwardersForDefaultStyles();

            // TODO: Using a custom IoC container like Unity? Register it here:
            //Catel.IoC.ServiceLocator.Instance.RegisterExternalContainer(MyUnityContainer);

            _serviceLocator = ServiceLocator.Default;
            _serviceLocator.RegisterType<IBackupSetService, BackupSetService>();
            _serviceLocator.RegisterType<IMessageBoxService, MessageBoxService>();
            _serviceLocator.RegisterInstance<ILog>(_log);
            var test = _serviceLocator.GetService(typeof(ILog));
            //test.l

            var uiVisualizerService = _serviceLocator.ResolveType<IUIVisualizerService>();
            uiVisualizerService.Register(typeof(BackupSetViewModel), typeof(BackupSetDialog));
            uiVisualizerService.Register(typeof(ExcludedDirectoriesViewModel), typeof(ExcludedDirectoriesWindow));
            uiVisualizerService.Register(typeof(DriveSelectionViewModel), typeof(DriveSelectionWindow));
            uiVisualizerService.Register(typeof(AboutViewModel), typeof(AboutDialog));

            

            

            var typeFactory = this.GetTypeFactory();
            var shellWindowViewModel = typeFactory.CreateInstanceWithParametersAndAutoCompletion<MainWindowViewModel>();
            shellWindowViewModel.OnThemeChanged += shellWindowViewModel_OnThemeChanged;

            new SKnoxConsulting.SafeAndSound.Gui.Views.MainWindow(shellWindowViewModel).ShowDialog();

           // Bootstrapper bootstrapper = new Bootstrapper();
           // bootstrapper.Run();



            
        }
开发者ID:simon-knox,项目名称:SafeAndSound2014,代码行数:55,代码来源:App.xaml.cs

示例9: GetTypeCatalog

 public static ITypeCatalog GetTypeCatalog(IServiceLocator serviceLocator)
 {
     var typeCatalog = serviceLocator.Resolve<ITypeCatalog>();
     if (typeCatalog != null)
     {
         return typeCatalog;
     }
     var assemblies = serviceLocator.Resolve<List<Assembly>>();
     if (assemblies == null || assemblies.Count < 1)
     {
         assemblies = AppDomain.CurrentDomain.GetAssemblies().ToList();
     }
     serviceLocator.RegisterInstance(assemblies);
     typeCatalog = new AppDomainTypeCatalog(assemblies);
     serviceLocator.Register(() => typeCatalog);
     return typeCatalog;
 }
开发者ID:Hallmanac,项目名称:ServiceLocator,代码行数:17,代码来源:StartupConfiguration.cs

示例10: SetUp

            public void SetUp()
            {
                _regionManagerMock = new Mock<IRegionManager>();
                _activeViewCollection = new Mock<IViewsCollection>();
                _viewCollection = new Mock<IViewsCollection>();
                _regionCollectionMock = new Mock<IRegionCollection>();
                _mainRegionMock = new Mock<IRegion>();

                var dispatcherServiceMock = new Mock<IDispatcherService>();
                dispatcherServiceMock.Setup(service => service.Invoke(It.IsAny<Action>())).Callback((Action action) => action.Invoke());

                _serviceLocator = ServiceLocator.Default;
                _serviceLocator.RegisterInstance<IDispatcherService>(dispatcherServiceMock.Object);

                _serviceLocator.RegisterType<IViewLocator, ViewLocator>();
                _serviceLocator.RegisterType<IViewModelLocator, ViewModelLocator>();
                _serviceLocator.RegisterType<IUIVisualizerService, UIVisualizerService>();
                _serviceLocator.RegisterType<IUICompositionService, UICompositionService>();
            }
开发者ID:yshbchenlie,项目名称:Catel,代码行数:19,代码来源:UIVisualizerServiceExtensionsTests.cs

示例11: SetupDefaultRegionManager

            /// <summary>
            /// The setup region manager behavior related with main region.
            /// </summary>
            private void SetupDefaultRegionManager(IServiceLocator serviceLocator = null)
            {
                if (serviceLocator == null)
                {
                    serviceLocator = _serviceLocator;
                }

                _activeViewCollection.Setup(collection => collection.Contains(It.IsAny<FooViewModelView>())).Returns(false);
                _viewCollection.Setup(collection => collection.Contains(It.IsAny<FooViewModelView>())).Returns(false);
                _mainRegionMock.SetupGet(region => region.ActiveViews).Returns(_activeViewCollection.Object);
                _mainRegionMock.SetupGet(region => region.Views).Returns(_viewCollection.Object);
                _regionCollectionMock.Setup(collection => collection.ContainsRegionWithName(MainRegionName)).Returns(true);
                _regionCollectionMock.SetupGet(collection => collection[MainRegionName]).Returns(_mainRegionMock.Object);
                _regionManagerMock.SetupGet(manager => manager.Regions).Returns(_regionCollectionMock.Object);

                serviceLocator.RegisterInstance<IRegionManager>(_regionManagerMock.Object);
            }
开发者ID:yshbchenlie,项目名称:Catel,代码行数:20,代码来源:UIVisualizerServiceExtensionsTests.cs

示例12: RegisterDefaultViewModelServices

        /// <summary>
        /// Registers the default view model services.
        /// </summary>
        /// <param name="serviceLocator">The service locator to add the services to.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="serviceLocator"/> is <c>null</c>.</exception>
        public static void RegisterDefaultViewModelServices(IServiceLocator serviceLocator)
        {
            Argument.IsNotNull("serviceLocator", serviceLocator);

            try
            {
                Log.Debug("Registering default service implementations for IoC container");

                if (!serviceLocator.IsTypeRegistered<IMessageMediator>())
                {
                    serviceLocator.RegisterInstance(MessageMediator.Default);
                }

                if (!serviceLocator.IsTypeRegistered<ExceptionHandling.IExceptionService>())
                {
                    serviceLocator.RegisterInstance(ExceptionHandling.ExceptionService.Default);
                }

                serviceLocator.RegisterTypeIfNotYetRegistered<IViewPropertySelector, FastViewPropertySelector>();
                serviceLocator.RegisterTypeIfNotYetRegistered<IStateService, StateService>();
                serviceLocator.RegisterTypeIfNotYetRegistered<IDispatcherService, DispatcherService>();
                serviceLocator.RegisterTypeIfNotYetRegistered<IMessageService, MessageService>();
                serviceLocator.RegisterTypeIfNotYetRegistered<IUrlLocator, UrlLocator>();
                serviceLocator.RegisterTypeIfNotYetRegistered<IViewLocator, ViewLocator>();
                serviceLocator.RegisterTypeIfNotYetRegistered<IViewModelLocator, ViewModelLocator>();
                serviceLocator.RegisterTypeIfNotYetRegistered<IViewModelFactory, ViewModelFactory>();
                serviceLocator.RegisterTypeIfNotYetRegistered<INavigationService, NavigationService>();

                serviceLocator.RegisterTypeIfNotYetRegistered<IPleaseWaitService, PleaseWaitService>();
                serviceLocator.RegisterTypeIfNotYetRegistered<IAccelerometerService, AccelerometerService>();
                serviceLocator.RegisterTypeIfNotYetRegistered<ILocationService, LocationService>();
                serviceLocator.RegisterTypeIfNotYetRegistered<IVibrateService, VibrateService>();

#if !NET && !SL5
                serviceLocator.RegisterTypeIfNotYetRegistered<ICameraService, CameraService>();
#endif

#if !XAMARIN
                // TODO: Add support in xamarin
                serviceLocator.RegisterTypeIfNotYetRegistered<ISchedulerService, SchedulerService>();
#endif

#if NET
                serviceLocator.RegisterTypeIfNotYetRegistered<IProcessService, ProcessService>();
                serviceLocator.RegisterTypeIfNotYetRegistered<ISelectDirectoryService, SelectDirectoryService>();
#endif

#if NET || SL5
                serviceLocator.RegisterTypeIfNotYetRegistered<IOpenFileService, OpenFileService>();
                serviceLocator.RegisterTypeIfNotYetRegistered<ISaveFileService, SaveFileService>();
                serviceLocator.RegisterTypeIfNotYetRegistered<IUIVisualizerService, UIVisualizerService>();
                serviceLocator.RegisterTypeIfNotYetRegistered<IViewExportService, ViewExportService>();
                serviceLocator.RegisterTypeIfNotYetRegistered<IStartUpInfoProvider, StartUpInfoProvider>();
                serviceLocator.RegisterTypeIfNotYetRegistered<ISplashScreenService, SplashScreenService>(RegistrationType.Transient);
#endif

#if (WINDOWS_PHONE && SILVERLIGHT) || XAMARIN
                serviceLocator.RegisterTypeIfNotYetRegistered<IPhoneService, PhoneService>();
#endif

                Log.Debug("Registered default service implementations for IoC container");
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Failed to configure IoC container");

                throw new Exception(Catel.ResourceHelper.GetString("FailedToConfigureIoCContainer"), ex);
            }            
        }
开发者ID:matthijskoopman,项目名称:Catel,代码行数:74,代码来源:ViewModelServiceHelper.cs

示例13: RegisterDefaultViewModelServices

        /// <summary>
        /// Registers the default view model services.
        /// </summary>
        /// <param name="serviceLocator">The service locator to add the services to.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="serviceLocator"/> is <c>null</c>.</exception>
        public static void RegisterDefaultViewModelServices(IServiceLocator serviceLocator)
        {
            Argument.IsNotNull("serviceLocator", serviceLocator);

            try
            {
                Log.Debug("Registering default service implementations for IoC container");

#if NETFX_CORE
                if (!serviceLocator.IsTypeRegistered<IMessageMediator>())
                {
                    serviceLocator.RegisterInstance(MessageMediator.Default);
                }

                if (!serviceLocator.IsTypeRegistered<ExceptionHandling.IExceptionService>())
                {
                    serviceLocator.RegisterInstance(ExceptionHandling.ExceptionService.Default);
                }

                // NOTE: Must be in this specific order
                serviceLocator.RegisterTypeIfNotYetRegistered<IDependencyPropertySelector, DependencyPropertySelector>();
                serviceLocator.RegisterTypeIfNotYetRegistered<IDispatcherService, DispatcherService>();
                serviceLocator.RegisterTypeIfNotYetRegistered<IMessageService, MessageService>();
                serviceLocator.RegisterTypeIfNotYetRegistered<IMessageService, MessageService>();
                serviceLocator.RegisterTypeIfNotYetRegistered<INavigationService, NavigationService>();
                serviceLocator.RegisterTypeIfNotYetRegistered<IPleaseWaitService, PleaseWaitService>();
                serviceLocator.RegisterTypeIfNotYetRegistered<IProcessService, ProcessService>();
                serviceLocator.RegisterTypeIfNotYetRegistered<ISchedulerService, SchedulerService>();
                serviceLocator.RegisterTypeIfNotYetRegistered<IUrlLocator, UrlLocator>();
                serviceLocator.RegisterTypeIfNotYetRegistered<IViewLocator, ViewLocator>();
                serviceLocator.RegisterTypeIfNotYetRegistered<IViewModelLocator, ViewModelLocator>();
                serviceLocator.RegisterTypeIfNotYetRegistered<IViewModelFactory, ViewModelFactory>();
#elif WINDOWS_PHONE
                if (!serviceLocator.IsTypeRegistered<IMessageMediator>())
                {
                    serviceLocator.RegisterInstance(MessageMediator.Default);
                }

                if (!serviceLocator.IsTypeRegistered<ExceptionHandling.IExceptionService>())
                {
                    serviceLocator.RegisterInstance(ExceptionHandling.ExceptionService.Default);
                }

                // NOTE: Must be in this specific order
                serviceLocator.RegisterTypeIfNotYetRegistered<IDependencyPropertySelector, DependencyPropertySelector>();
                serviceLocator.RegisterTypeIfNotYetRegistered<IDispatcherService, DispatcherService>();
                serviceLocator.RegisterTypeIfNotYetRegistered<IMessageService, MessageService>();
                serviceLocator.RegisterTypeIfNotYetRegistered<ILocationService, LocationService>();
                serviceLocator.RegisterTypeIfNotYetRegistered<IMessageService, MessageService>();
                serviceLocator.RegisterTypeIfNotYetRegistered<INavigationService, NavigationService>();
                serviceLocator.RegisterTypeIfNotYetRegistered<IPleaseWaitService, PleaseWaitService>();
                serviceLocator.RegisterTypeIfNotYetRegistered<ISchedulerService, SchedulerService>();
                serviceLocator.RegisterTypeIfNotYetRegistered<IVibrateService, VibrateService>();
                serviceLocator.RegisterTypeIfNotYetRegistered<IUrlLocator, UrlLocator>();
                serviceLocator.RegisterTypeIfNotYetRegistered<IViewLocator, ViewLocator>();
                serviceLocator.RegisterTypeIfNotYetRegistered<IViewModelLocator, ViewModelLocator>();
                serviceLocator.RegisterTypeIfNotYetRegistered<IViewModelFactory, ViewModelFactory>();

                serviceLocator.RegisterTypeIfNotYetRegistered<IAccelerometerService, AccelerometerService>();
                serviceLocator.RegisterTypeIfNotYetRegistered<ICameraService, CameraService>();

#elif SILVERLIGHT
                if (!serviceLocator.IsTypeRegistered<IMessageMediator>())
                {
                    serviceLocator.RegisterInstance(MessageMediator.Default);
                }

                if (!serviceLocator.IsTypeRegistered<ExceptionHandling.IExceptionService>())
                {
                    serviceLocator.RegisterInstance(ExceptionHandling.ExceptionService.Default);
                }

                // NOTE: Must be in this specific order
                serviceLocator.RegisterTypeIfNotYetRegistered<IDependencyPropertySelector, DependencyPropertySelector>();
                serviceLocator.RegisterTypeIfNotYetRegistered<IDispatcherService, DispatcherService>();
                serviceLocator.RegisterTypeIfNotYetRegistered<IMessageService, MessageService>();
                serviceLocator.RegisterTypeIfNotYetRegistered<INavigationService, NavigationService>();
                serviceLocator.RegisterTypeIfNotYetRegistered<IOpenFileService, OpenFileService>();
                serviceLocator.RegisterTypeIfNotYetRegistered<IPleaseWaitService, PleaseWaitService>();
                serviceLocator.RegisterTypeIfNotYetRegistered<ISaveFileService, SaveFileService>();
                serviceLocator.RegisterTypeIfNotYetRegistered<ISchedulerService, SchedulerService>();
                serviceLocator.RegisterTypeIfNotYetRegistered<IUIVisualizerService, UIVisualizerService>();
                serviceLocator.RegisterTypeIfNotYetRegistered<IUrlLocator, UrlLocator>();
                serviceLocator.RegisterTypeIfNotYetRegistered<IViewLocator, ViewLocator>();
                serviceLocator.RegisterTypeIfNotYetRegistered<IViewExportService, ViewExportService>();
                serviceLocator.RegisterTypeIfNotYetRegistered<IViewModelLocator, ViewModelLocator>();
                serviceLocator.RegisterTypeIfNotYetRegistered<IViewModelFactory, ViewModelFactory>();
                serviceLocator.RegisterTypeIfNotYetRegistered<IViewExportService, ViewExportService>();
#else // WPF
                if (!serviceLocator.IsTypeRegistered<IMessageMediator>())
                {
                    serviceLocator.RegisterInstance(MessageMediator.Default);
                }

                if (!serviceLocator.IsTypeRegistered<ExceptionHandling.IExceptionService>())
//.........这里部分代码省略.........
开发者ID:pars87,项目名称:Catel,代码行数:101,代码来源:ViewModelServiceHelper.cs

示例14: SetupMockTransportWhichReturnsBytes

        private static void SetupMockTransportWhichReturnsBytes(IServiceLocator serviceLocator, byte[] expectedResponseMessageBytes)
        {
            var inConnector = new Subject<byte[]>();
            var mockTransport = new Mock<IClientTransport>();
            mockTransport.Setup(transport => transport.Subscribe(It.IsAny<IObserver<byte[]>>())).Callback<IObserver<byte[]>>(observer => inConnector.Subscribe(observer));
            mockTransport.Setup(transport => transport.SendAsync(It.IsAny<byte[]>(), It.IsAny<CancellationToken>()))
                .Callback(() => inConnector.OnNext(expectedResponseMessageBytes))
                .Returns(() => TaskConstants.Completed);

            serviceLocator.RegisterInstance(CreateMockTransportFactory(mockTransport.Object));
        }
开发者ID:moradifx,项目名称:SharpMTProto,代码行数:11,代码来源:MTProtoConnectionFacts.cs


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