public override T GetService <T>(Type type = null) { // First try internal services var service = base.GetService <T>(type); return(service ?? _exportProvider.GetExportedValueOrDefault <T>()); }
private object DecorateRazorVersionDetector() { var detector = _inner.GetExportedValueOrDefault <IRazorVersionDetector>(); detector = new RazorVersionDetector(detector); return(detector); }
internal static T TryGetExportedValueOrDefault <T>(ExportProvider provider, ILog log) where T : class { T result = null; try { result = provider.GetExportedValueOrDefault <T>(); } catch (ReflectionTypeLoadException rtle) { var sb = new StringBuilder(); var type = typeof(T); sb.AppendFormat(CultureInfo.InvariantCulture, "Unable to load plugin of type '{0}':", type); sb.AppendLine(); foreach (var loaderException in rtle.LoaderExceptions) { sb.AppendLine(loaderException.ToString()); } log.Error(sb.ToString()); } return(result); }
public object GetInstance(string contract) { return(_container.GetExportedValueOrDefault <object>(contract)); }