本文整理汇总了C#中IServiceLocator.GetService方法的典型用法代码示例。如果您正苦于以下问题:C# IServiceLocator.GetService方法的具体用法?C# IServiceLocator.GetService怎么用?C# IServiceLocator.GetService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IServiceLocator
的用法示例。
在下文中一共展示了IServiceLocator.GetService方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AbstractTestRunner
public AbstractTestRunner(IServiceLocator services, TestPackage package)
{
Services = services;
TestPackage = package;
TestRunnerFactory = Services.GetService<ITestRunnerFactory>();
ProjectService = Services.GetService<IProjectService>();
}
示例2: RootRoute
public RootRoute(bool blogAggregationEnabled, IRouteHandler normalRouteHandler, IRouteHandler aggRouteHandler,
IServiceLocator serviceLocator)
{
BlogAggregationEnabled = blogAggregationEnabled;
NormalRouteHandler = normalRouteHandler ??
new PageRouteHandler("~/aspx/Dtp.aspx", serviceLocator.GetService<ISubtextPageBuilder>(), serviceLocator);
AggregateRouteHandler = aggRouteHandler ??
new PageRouteHandler("~/aspx/AggDefault.aspx", serviceLocator.GetService<ISubtextPageBuilder>(), serviceLocator);
}
示例3: MasterTestRunner
public MasterTestRunner(IServiceLocator services, TestPackage package)
{
_services = services;
TestPackage = package;
_testRunnerFactory = _services.GetService<ITestRunnerFactory>();
_projectService = _services.GetService<IProjectService>();
_runtimeService = _services.GetService<IRuntimeFrameworkService>();
_extensionService = _services.GetService<ExtensionService>();
_engineRunner = _testRunnerFactory.MakeTestRunner(package);
}
示例4: 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();
}
示例5: OnAfterRegisterServices
protected override void OnAfterRegisterServices(IServiceLocator serviceLocator)
{
base.OnAfterRegisterServices(serviceLocator);
// Populate users
var userService = serviceLocator.GetService<IUserService>();
userService.CreateUser(userService.CreateSignUpInfo("Tom", "TomsPassword", "[email protected]"));
userService.CreateUser(userService.CreateSignUpInfo("Aleksas", "AleksasPassword", "[email protected]"));
userService.CreateUser(userService.CreateSignUpInfo("Mike", "MikesPassword", "[email protected]"));
// Populate categories
throw new NotImplementedException();
//var categoryService = (CategoryService)serviceLocator.GetService<ICategoryService>();
//using (var categoryReader = new WikipediaCategoryCursor())
// categoryService.AddCategories(categoryReader);
// Populate messages
var messageService = serviceLocator.GetService<IMessageService>();
}
示例6: SystemDirectoryRoute
public SystemDirectoryRoute(string directoryName, IServiceLocator serviceLocator)
: base(directoryName + "/{*pathInfo}", new DirectoryRouteHandler(serviceLocator.GetService<ISubtextPageBuilder>(), serviceLocator))
{
DirectoryName = directoryName;
}
示例7: CachingUnitTest
public CachingUnitTest()
{
iServiceLocate = ServiceLocatorFactory.GetServiceLocator();
iTestService = iServiceLocate.GetService<ITestService>();
}
示例8: AuditTrailUnitTest
public AuditTrailUnitTest()
{
//iAuditTrailManagementService = ServiceLocatorFactory.GetServiceLocator().GetService<IAuditTrailManagementService>();
iServiceLocate = ServiceLocatorFactory.GetServiceLocator();
iTestService = iServiceLocate.GetService<ITestService>();
}
示例9: Initialize
/// <summary>
/// Initializes REST Foundation configuration with the default IoC container.
/// </summary>
/// <param name="serviceLocator">A service locator instance.</param>
/// <returns>The configuration options object.</returns>
public RestOptions Initialize(IServiceLocator serviceLocator)
{
if (serviceLocator == null)
{
throw new ArgumentNullException("serviceLocator");
}
if (ServiceLocator != null)
{
throw new InvalidOperationException(Resources.Global.AlreadyConfigured);
}
RouteCollection routes = RouteTable.Routes;
routes.Add(new Route(String.Empty, serviceLocator.GetService<RootRouteHandler>()));
ServiceLocator = serviceLocator;
m_options = new RestOptions();
return m_options;
}
示例10: Configure
protected override async Task Configure(IServiceLocator locator, ConfigurationData configuration)
{
var logger = await locator.GetService<ILogger>();
logger.Trace("Configured test 'module one'");
}
示例11: OnAfterRegisterServices
protected override void OnAfterRegisterServices(IServiceLocator serviceLocator)
{
base.OnAfterRegisterServices(serviceLocator);
// Populate users
var userService = serviceLocator.GetService<IUserService>();
userService.CreateUser(userService.CreateSignUpInfo("Tom", "TomsPassword", "[email protected]"));
userService.CreateUser(userService.CreateSignUpInfo("Aleksas", "AleksasPassword", "[email protected]"));
userService.CreateUser(userService.CreateSignUpInfo("Mike", "MikesPassword", "[email protected]"));
// Populate categories
var categoryService = serviceLocator.GetService<ICategoryService>();
categoryService.CreateCategory(GetCategoryInfo());
// Populate messages
var messageService = serviceLocator.GetService<IMessageService>();
}
示例12: PageRoute
public PageRoute(string url, string virtualPath, IEnumerable<string> controls, IServiceLocator serviceLocator)
: this(url, virtualPath, controls, serviceLocator.GetService<ISubtextPageBuilder>(), serviceLocator)
{
}