public object TryGetService(Type serviceType) { string contract = AttributedModelServices.GetContractName(serviceType); var instance = AddToDisposables(TempContainer.GetExportedValueOrDefault <object>(contract)); if (instance != null) { return(instance); } var sp = initialized ? syncServiceProvider : asyncServiceProvider; instance = sp.GetService(serviceType); if (instance != null) { return(instance); } instance = AddToDisposables(ExportProvider.GetExportedValues <object>(contract).FirstOrDefault(x => contract.StartsWith("github.", StringComparison.OrdinalIgnoreCase) ? x.GetType().Assembly.GetName().Version == currentVersion : true)); if (instance != null) { return(instance); } instance = GitServiceProvider?.GetService(serviceType); if (instance != null) { return(instance); } return(null); }
public object TryGetService(Type serviceType) { Guard.ArgumentNotNull(serviceType, nameof(serviceType)); if (!initializingLogging && log.Factory.Configuration == null) { initializingLogging = true; try { var logging = TryGetService(typeof(ILoggingConfiguration)) as ILoggingConfiguration; logging.Configure(); } catch { #if DEBUG throw; #endif } } string contract = AttributedModelServices.GetContractName(serviceType); var instance = AddToDisposables(TempContainer.GetExportedValueOrDefault <object>(contract)); if (instance != null) { return(instance); } var sp = initialized ? syncServiceProvider : asyncServiceProvider; instance = sp.GetService(serviceType); if (instance != null) { return(instance); } instance = AddToDisposables(ExportProvider.GetExportedValues <object>(contract).FirstOrDefault(x => contract.StartsWith("github.", StringComparison.OrdinalIgnoreCase) ? x.GetType().Assembly.GetName().Version == currentVersion : true)); if (instance != null) { return(instance); } instance = GitServiceProvider?.GetService(serviceType); if (instance != null) { return(instance); } return(null); }