| | |
| | | **
|
| | | ****************************************************************************/
|
| | |
|
| | | using Microsoft.VisualStudio.Shell;
|
| | | using System;
|
| | | using System.Collections.Concurrent;
|
| | | using System.Threading.Tasks;
|
| | |
| | | {
|
| | | public static IVsServiceProvider Instance { get; set; }
|
| | |
|
| | | static ConcurrentDictionary<ServiceType, object> services
|
| | | static readonly ConcurrentDictionary<ServiceType, object> services
|
| | | = new ConcurrentDictionary<ServiceType, object>();
|
| | |
|
| | | public static I GetService<I>()
|
| | |
| | | if (Instance == null)
|
| | | return null;
|
| | |
|
| | | object serviceObj;
|
| | | if (services.TryGetValue(new ServiceType(typeof(T), typeof(I)), out serviceObj))
|
| | | if (services.TryGetValue(new ServiceType(typeof(T), typeof(I)), out object serviceObj))
|
| | | return serviceObj as I;
|
| | |
|
| | | var serviceInterface = Instance.GetService<T, I>();
|
| | |
| | | if (Instance == null)
|
| | | return null;
|
| | |
|
| | | object serviceObj;
|
| | | if (services.TryGetValue(new ServiceType(typeof(T), typeof(I)), out serviceObj))
|
| | | if (services.TryGetValue(new ServiceType(typeof(T), typeof(I)), out object serviceObj))
|
| | | return serviceObj as I;
|
| | |
|
| | | var serviceInterface = await Instance.GetServiceAsync<T, I>();
|