src/Microsoft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/LanguageServices/VsContainedLanguageComponentsFactory.cs
/// <summary>
///     Gets an object that represents a host-specific IVsContainedLanguageFactory implementation and
///     IVsHierarchy and itemId specific to currently active target framework.
/// </summary>
/// <param name="filePath">Path to a file</param>
/// <param name="hierarchy">Project hierarchy containing given file for current language service</param>
/// <param name="itemid">item id of the given file</param>
/// <param name="containedLanguageFactory">an instance of IVsContainedLanguageFactory specific for current language service</param>
/// <returns></returns>
Gets an object that represents a host-specific IVsContainedLanguageFactory implementation and
IVsHierarchy and itemId specific to currently active target framework.
Gets an object that represents a host - specific IVsContainedLanguageFactory implementation and IVsHierarchy and itemId specific to currently active target framework .
public int GetContainedLanguageFactoryForFile(string filePath, 
                                                      out IVsHierarchy hierarchy, 
                                                      out uint itemid, 
                                                      out IVsContainedLanguageFactory containedLanguageFactory)
        {
            uint myItemId = 0;
            IVsHierarchy myHierarchy = null;
            IVsContainedLanguageFactory myContainedLanguageFactory = null;
            _projectVsServices.ThreadingService.JoinableTaskFactory.Run(async () =>
            {
                await InitializeAsync().ConfigureAwait(false);
                Guid? languageServiceId = await GetLanguageServiceId().ConfigureAwait(false);
                if (languageServiceId == null)
                    return;
                await _projectVsServices.ThreadingService.JoinableTaskFactory.SwitchToMainThreadAsync();
                var priority = new VSDOCUMENTPRIORITY[1];
                HResult result = _projectVsServices.VsProject.IsDocumentInProject(filePath, 
                                                                               out int isFound, 
                                                                               priority, 
                                                                               out myItemId);
                if (result.Failed || isFound == 0)
                {
                    return;
                }
                myHierarchy = (IVsHierarchy)_projectHostProvider.UnconfiguredProjectHostObject.ActiveIntellisenseProjectHostObject;
                var oleServiceProvider = _serviceProvider.GetService(typeof(IOLEServiceProvider)) as IOLEServiceProvider;
                if (oleServiceProvider == null)
                {
                    return;
                }
                myContainedLanguageFactory = (IVsContainedLanguageFactory)PackageUtilities.QueryService(
                                                oleServiceProvider,
                                                languageServiceId.Value);
            });
            hierarchy = myHierarchy;
            itemid = myItemId;
            containedLanguageFactory = myContainedLanguageFactory;
            return (myHierarchy == null || containedLanguageFactory == null) 
                ? VSConstants.E_FAIL 
                : VSConstants.S_OK;
        }
public int GetContainedLanguageFactoryForFile ( string filePath , out IVsHierarchy hierarchy , out uint itemid , out IVsContainedLanguageFactory containedLanguageFactory ) { uint myItemId = 0 ; IVsHierarchy myHierarchy = null ; IVsContainedLanguageFactory myContainedLanguageFactory = null ; _projectVsServices . ThreadingService . JoinableTaskFactory . Run ( async ( ) => { await InitializeAsync ( ) . ConfigureAwait ( false ) ; Guid ? languageServiceId = await GetLanguageServiceId ( ) . ConfigureAwait ( false ) ; if ( languageServiceId == null ) return ; await _projectVsServices . ThreadingService . JoinableTaskFactory . SwitchToMainThreadAsync ( ) ; var priority = new VSDOCUMENTPRIORITY [ 1 ] ; HResult result = _projectVsServices . VsProject . IsDocumentInProject ( filePath , out int isFound , priority , out myItemId ) ; if ( result . Failed || isFound == 0 ) { return ; } myHierarchy = ( IVsHierarchy ) _projectHostProvider . UnconfiguredProjectHostObject . ActiveIntellisenseProjectHostObject ; var oleServiceProvider = _serviceProvider . GetService ( typeof ( IOLEServiceProvider ) ) as IOLEServiceProvider ; if ( oleServiceProvider == null ) { return ; } myContainedLanguageFactory = ( IVsContainedLanguageFactory ) PackageUtilities . QueryService ( oleServiceProvider , languageServiceId . Value ) ; } ) ; hierarchy = myHierarchy ; itemid = myItemId ; containedLanguageFactory = myContainedLanguageFactory ; return ( myHierarchy == null || containedLanguageFactory == null ) ? VSConstants . E_FAIL : VSConstants . S_OK ; }
Gets an object that represents a host-specific IVsContainedLanguageFactory implementation and
IVsHierarchy and itemId specific to currently active target framework.
Gets an object that represents a host - specific IVsContainedLanguageFactory implementation and IVsHierarchy and itemId specific to currently active target framework .
None
filePath
string
Path to a file
Path to a file
IVsHierarchy
out
uint
out
IVsContainedLanguageFactory
out
hierarchy
Project hierarchy containing given file for current language service
Project hierarchy containing given file for current language service
itemid
item id of the given file
item id of the given file
containedLanguageFactory
an instance of IVsContainedLanguageFactory specific for current language service
an instance of IVsContainedLanguageFactory specific for current language service