本文整理汇总了C#中IServiceLocator.RegisterType方法的典型用法代码示例。如果您正苦于以下问题:C# IServiceLocator.RegisterType方法的具体用法?C# IServiceLocator.RegisterType怎么用?C# IServiceLocator.RegisterType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IServiceLocator
的用法示例。
在下文中一共展示了IServiceLocator.RegisterType方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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.RegisterTypeIfNotYetRegistered<IBootstrapperTaskFactory, BootstrapperTaskFactory>();
serviceLocator.RegisterType<RegionAdapterMappings, RegionAdapterMappings>();
serviceLocator.RegisterType<IUICompositionService, UICompositionService>();
}
示例2: 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();
}
示例3: 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.RegisterTypeIfNotYetRegistered<IBootstrapperTaskFactory, BootstrapperTaskFactory>();
serviceLocator.RegisterType<RegionAdapterMappings, RegionAdapterMappings>();
}
示例4: 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>();
}
示例5: 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>();
}
示例6: 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>();
}
示例7: Configure
/// <summary>
/// Configures an instance of <see cref="IServiceLocator" />.
/// </summary>
/// <param name="serviceLocator">The instance of <see cref="IServiceLocator" /></param>
public void Configure(IServiceLocator serviceLocator)
{
foreach (Registration registrationElement in this)
{
serviceLocator.RegisterType(registrationElement.InterfaceType, registrationElement.ImplementationType, registrationElement.Tag, registrationElement.RegistrationType);
}
}
示例8: 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>();
}
示例9: 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<IJsonSerializer, JsonSerializer>();
}
示例10: 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<IProxyFactory, ProxyFactory>();
}
示例11: RegisterServices
private void RegisterServices(IServiceLocator serviceLocator)
{
serviceLocator.RegisterType<IReflectionService, ReflectionService>();
serviceLocator.RegisterType<IUIServiceHost, UIServiceHost>();
serviceLocator.RegisterType<ITestTargetService, TestTargetService>();
serviceLocator.RegisterType<ISettings, Settings>();
}
示例12: Configure
/// <summary>
/// Configures an instance of <see cref="IServiceLocator" />.
/// </summary>
/// <param name="serviceLocator">The instance of <see cref="IServiceLocator" /></param>
public void Configure(IServiceLocator serviceLocator)
{
serviceLocator.SupportDependencyInjection = SupportDependencyInjection;
foreach (Registration registrationElement in this)
{
serviceLocator.RegisterType(registrationElement.InterfaceType, registrationElement.ImplementationType, registrationElement.Tag, registrationElement.RegistrationType);
}
}
示例13: 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.RegisterType<IProxyFactory, ProxyFactory>();
}