Example #1
0
 public BrowseObjectExtenderProvider(IAsyncServiceProvider2 serviceProvider, ObjectExtenders objectExtenders, string extenderCategory)
 {
     this.serviceProvider  = serviceProvider;
     this.objectExtenders  = objectExtenders;
     this.extenderCategory = extenderCategory;
     this.providerCookie   = this.objectExtenders.RegisterExtenderProvider(extenderCategory, BrowseObjectExtenderProvider.ExtenderName, this);
 }
Example #2
0
        public VisualStudioWorkspaceStatusServiceFactory(
            SVsServiceProvider serviceProvider, IAsynchronousOperationListenerProvider listenerProvider)
        {
            _serviceProvider = (IAsyncServiceProvider2)serviceProvider;

            // for now, we use workspace so existing tests can automatically wait for full solution load event
            // subscription done in test
            _listener = listenerProvider.GetListener(FeatureAttribute.Workspace);
        }
            public Service(IAsyncServiceProvider2 serviceProvider, IAsynchronousOperationListener listener)
            {
                _serviceProvider = serviceProvider;

                // pre-emptively make sure event is subscribed. if APIs are called before it is done, calls will be blocked
                // until event subscription is done
                var asyncToken = listener.BeginAsyncOperation("StatusChanged_EventSubscription");
                Task.Run(() => EnsureInitializationAsync(CancellationToken.None), CancellationToken.None).CompletesAsyncOperation(asyncToken);
            }
Example #4
0
        internal CustomToolParameters(IAsyncServiceProvider2 serviceProvider, IVsHierarchy project, uint projectItemId)
        {
            Debug.Assert(serviceProvider != null, "serviceProvider");
            Debug.Assert(project != null, "project");
            Debug.Assert(projectItemId != 0, "projectItemId");

            this.serviceProvider = serviceProvider;
            this.project         = project;
            this.projectItemId   = projectItemId;
        }
Example #5
0
        internal BrowseObjectExtender(IAsyncServiceProvider2 serviceProvider, IVsBrowseObject browseObject, IExtenderSite site, int cookie)
        {
            Debug.Assert(serviceProvider != null, "serviceProvider");
            Debug.Assert(browseObject != null, "browseObject");
            Debug.Assert(site != null, "site");
            Debug.Assert(cookie != 0, "cookie");

            this.site            = site;
            this.cookie          = cookie;
            this.serviceProvider = serviceProvider;
            ErrorHandler.ThrowOnFailure(browseObject.GetProjectItem(out this.hierarchy, out this.itemId));
            this.propertyStorage      = (IVsBuildPropertyStorage)this.hierarchy;
            this.CustomToolParameters = new CustomToolParameters(this.serviceProvider, this.hierarchy, this.itemId);
            this.templateLocator      = (TemplateLocator)this.serviceProvider.GetServiceAsync(typeof(TemplateLocator)).Result;
        }
Example #6
0
        public LogHubLogger([Import(typeof(SAsyncServiceProvider))] IAsyncServiceProvider2 asyncServiceProvider)
        {
            asyncServiceProvider.GetServiceAsync <SVsBrokeredServiceContainer, IBrokeredServiceContainer>(throwOnFailure: true).ContinueWith(async(t) => {
                var serviceBroker = t.Result.GetFullAccessServiceBroker();
                Assumes.NotNull(serviceBroker);

                // Setup logging using the log hub
                using TraceConfiguration config = await TraceConfiguration.CreateTraceConfigurationInstanceAsync(serviceBroker, false);
                SourceLevels sourceLevels       = SourceLevels.Information | SourceLevels.ActivityTracing;
                LoggerOptions logOptions        = new(
                    requestedLoggingLevel: new LoggingLevelSettings(sourceLevels),
                    privacySetting: PrivacyFlags.MayContainPersonallyIdentifibleInformation | PrivacyFlags.MayContainPrivateInformation);

                this._traceSource = await config.RegisterLogSourceAsync(new LogId("Microsoft.PythonTools", serviceId: null), logOptions, traceSource: null, isBootstrappedService: true, default);
            });
        }
Example #7
0
        public OutputFileManager(
            IAsyncServiceProvider2 serviceProvider,
            DTE dte,
            ITextTemplatingEngineHost textTemplatingEngineHost,
            string inputFile,
            OutputFile[] outputFiles)
        {
            this.serviceProvider = serviceProvider;
            this.dte             = dte;
            this.templatingHost  = textTemplatingEngineHost;
            this.inputFile       = inputFile;
            this.outputFiles     = outputFiles;

            this.inputDirectory = Path.GetDirectoryName(inputFile);
            this.projects       = GetAllProjects(this.dte.Solution);
            this.input          = this.dte.Solution.FindProjectItem(this.inputFile);
        }
            public Service(IAsyncServiceProvider2 serviceProvider, IThreadingContext threadingContext, IAsynchronousOperationListener listener)
            {
                _serviceProvider  = serviceProvider;
                _threadingContext = threadingContext;

                _loadHubClientPackage = _threadingContext.JoinableTaskFactory.RunAsync(async() =>
                {
                    // Use the disposal token, since the caller's cancellation token will apply instead to the
                    // JoinAsync operation in GetProgressStageStatusAsync.
                    await _threadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(alwaysYield: true, _threadingContext.DisposalToken);

                    // Make sure the HubClient package is loaded, since we rely on it for proffered OOP services
                    var shell = await _serviceProvider.GetServiceAsync <SVsShell, IVsShell7>().ConfigureAwait(true);
                    Assumes.Present(shell);

                    await shell.LoadPackageAsync(Guids.GlobalHubClientPackageGuid);
                });

                _progressStageStatus = _threadingContext.JoinableTaskFactory.RunAsync(async() =>
                {
                    // pre-emptively make sure event is subscribed. if APIs are called before it is done, calls will be blocked
                    // until event subscription is done
                    using var asyncToken = listener.BeginAsyncOperation("StatusChanged_EventSubscription");

                    await threadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(alwaysYield: true, _threadingContext.DisposalToken);
                    var service = await serviceProvider.GetServiceAsync <SVsOperationProgress, IVsOperationProgressStatusService>(throwOnFailure: false).ConfigureAwait(true);
                    if (service is null)
                    {
                        return(null);
                    }

                    var status              = service.GetStageStatusForSolutionLoad(CommonOperationProgressStageIds.Intellisense);
                    status.PropertyChanged += (_, _) => StatusChanged?.Invoke(this, EventArgs.Empty);

                    return(status);
                });
            }
Example #9
0
 protected TemplateLocator(IAsyncServiceProvider2 serviceProvider)
 {
     this.ServiceProvider = serviceProvider;
 }
Example #10
0
 private TransformationContextProvider(IAsyncServiceProvider2 serviceProvider)
 {
     this.serviceProvider = serviceProvider;
 }