static Adapters() { // Initialize the default adapter service for the smart cast extension method. // NOTE: this adapter via global extension method will only include adapters // from Clide itself. AdaptersInitializer.SetService(ServiceLocator.GlobalLocator.GetInstance <IAdapterService>()); }
/// <summary> /// Registers the package components such as commands, filter, options, etc. /// with the development environment. This call should always be made from /// the package Initialize method, which is guaranteed to run on the UI /// thread. /// </summary> /// <param name="hostingPackage">The package owning this deploy /// of Clide.</param> public static IDevEnv Initialize(IServiceProvider hostingPackage) { try { // This call should always be made from a package Initialize method, // which is guaranteed to be called from the UI thread. UIThread.Initialize(Dispatcher.CurrentDispatcher); var devEnv = DevEnv.Get(hostingPackage); using (tracer.StartActivity("Initializing package")) { // TODO // Brings in imports that the package itself might need. //devEnv.ServiceLocator.SatisfyImportsOnce(hostingPackage); // Initialize the host package components. var host = devEnv.ServiceLocator.GetInstance <HostImpl>(); host.Initialize(); // This call causes the static initialization on Adapters to run, which // is then overriden on the next line. Debug.Assert(Adapters.ServiceInstance != null); // Re-initialize the adapter service so that extended adapter implementations // are available. AdaptersInitializer.SetService(devEnv.ServiceLocator.GetInstance <IAdapterService>()); // Force initialization of the global service locator so that the component model // is requested from the UI thread. // This call also forces initialization of the global service locator singleton. Debug.Assert(ServiceLocator.GlobalLocator != null); tracer.Info("Package initialization finished successfully"); return(devEnv); } } catch (Exception ex) { tracer.Error(ex, Strings.Host.FailedToInitialize); throw; } }