CurrentPlatformEnlightenmentProvider
(Infrastructure) Provider for platform-specific framework enlightenments.
using System.ComponentModel;
using System.Diagnostics;
using System.Reactive.Concurrency;
using System.Reactive.Linq;
using System.Runtime.CompilerServices;
namespace System.Reactive.PlatformServices
{
[EditorBrowsable(EditorBrowsableState.Never)]
public class CurrentPlatformEnlightenmentProvider : IPlatformEnlightenmentProvider
{
[System.Runtime.CompilerServices.NullableContext(1)]
[return: System.Runtime.CompilerServices.Nullable(2)]
public virtual T GetService<T>(object[] args) where T : class
{
Type typeFromHandle = typeof(T);
if (typeFromHandle == typeof(IExceptionServices))
return (T)(object)new ExceptionServicesImpl();
if (typeFromHandle == typeof(IConcurrencyAbstractionLayer))
return (T)(object)new ConcurrencyAbstractionLayerImpl();
if (typeFromHandle == typeof(IScheduler) && args != null) {
switch ((string)args[0]) {
case "ThreadPool":
return (T)(object)ThreadPoolScheduler.Instance;
case "TaskPool":
return (T)(object)TaskPoolScheduler.Default;
case "NewThread":
return (T)(object)NewThreadScheduler.Default;
}
}
if (typeFromHandle == typeof(IQueryServices) && Debugger.IsAttached)
return (T)(object)new QueryDebugger();
return null;
}
}
}