コード例 #1
0
        private static VsContainedLanguageComponentsFactory CreateInstance(IVsContainedLanguageFactory containedLanguageFactory = null, IVsHierarchy hierarchy = null, IVsProject4 project = null, ProjectProperties properties = null, IActiveWorkspaceProjectContextHost projectContextHost = null)
        {
            var serviceProvider = IOleAsyncServiceProviderFactory.ImplementQueryServiceAsync(containedLanguageFactory, new Guid(LanguageServiceId));

            var projectVsServices = new IUnconfiguredProjectVsServicesMock();

            projectVsServices.ImplementVsHierarchy(hierarchy);
            projectVsServices.ImplementVsProject(project);
            projectVsServices.ImplementThreadingService(IProjectThreadingServiceFactory.Create());
            projectVsServices.ImplementActiveConfiguredProjectProperties(properties);

            return(CreateInstance(serviceProvider, projectVsServices.Object, projectContextHost));
        }
        private static VsContainedLanguageComponentsFactory CreateInstance(IVsContainedLanguageFactory containedLanguageFactory = null, IVsProject4 project = null, ProjectProperties properties = null, IConfiguredProjectHostObject hostObject = null, ILanguageServiceHost languageServiceHost = null)
        {
            var hostProvider    = IProjectHostProviderFactory.ImplementActiveIntellisenseProjectHostObject(hostObject);
            var serviceProvider = IOleAsyncServiceProviderFactory.ImplementQueryServiceAsync(containedLanguageFactory, new Guid(LanguageServiceId));

            var projectVsServices = new IUnconfiguredProjectVsServicesMock();

            projectVsServices.ImplementVsProject(project);
            projectVsServices.ImplementThreadingService(IProjectThreadingServiceFactory.Create());
            projectVsServices.ImplementActiveConfiguredProjectProperties(properties);

            return(CreateInstance(serviceProvider, projectVsServices.Object, hostProvider, languageServiceHost));
        }