다음을 통해 공유


IVsExtensionManager.GetEnabledExtensionContentLocations 메서드 (String, IDictionary<String, String>)

컬렉션의 모든 콘텐츠가 활성화 된 확장에 포함 되어 있으며 다음 콘텐츠 노드에 XML 특성에 지정 된 특성을 비교 하 여 결과 필터링 특정 유형의 경로를 쿼리 합니다.

네임스페이스:  Microsoft.VisualStudio.ExtensionManager
어셈블리:  Microsoft.VisualStudio.ExtensionManager(Microsoft.VisualStudio.ExtensionManager.dll)

구문

‘선언
Function GetEnabledExtensionContentLocations ( _
    contentTypeName As String, _
    attributes As IDictionary(Of String, String) _
) As IEnumerable(Of String)
IEnumerable<string> GetEnabledExtensionContentLocations(
    string contentTypeName,
    IDictionary<string, string> attributes
)
IEnumerable<String^>^ GetEnabledExtensionContentLocations(
    String^ contentTypeName, 
    IDictionary<String^, String^>^ attributes
)
abstract GetEnabledExtensionContentLocations : 
        contentTypeName:string * 
        attributes:IDictionary<string, string> -> IEnumerable<string> 
function GetEnabledExtensionContentLocations(
    contentTypeName : String, 
    attributes : IDictionary<String, String>
) : IEnumerable<String>

매개 변수

  • contentTypeName
    형식: String

    하 여 검색을 필터링 하려면 콘텐츠 형식입니다.

  • attributes
    형식: IDictionary<String, String>

    특성 일치 하는 콘텐츠입니다.

반환 값

형식: IEnumerable<String>
경로 확장의 컬렉션을 어디 contentTypeName 의 자식에 해당는 콘텐츠 VSIX 매니페스트는 확장에 대 한 요소 및 attributes 해당 자식 요소의 XML 특성에 일치 합니다.

설명

이 API를 지원 하기는 하지만 확장 관리자 인프라를 좋습니다 변경 될 수 있으므로 사용 하지 않는 것입니다.

예제

다음 예제를 사용 하 여 GetEnabledExtensionContentLocations 의 특정 사용자 정의 형식의 모든 확장 위치를 얻을 수 있습니다. 다음 사용 하 여 CreateExtension 모든 확장을 찾을 수 및 해당 이름에 대 한 기타 메타 데이터에 액세스할 수 있습니다. 이름 및 경로 정보를 저장 하 고 나면 각 확장명에 대 한 메뉴 명령이 만들어집니다.

// This is the CommandID of the placeholder menu item,  
// as defined in the .vsct file. 
int CmdIdBase = 0x103;

// These lists will store name and path information. 
private ArrayList SkinNames = new ArrayList();
private ArrayList SkinPaths = new ArrayList();

// Call this from Initialize(). 
private void InitSkinList()
{
    var mcs = GetService(typeof(IMenuCommandService)) 
        as OleMenuCommandService;
    int counter = CmdIdBase;

    // Get the Extension Manager service. 
    var ExtMgrSvc = GetService(typeof(SVsExtensionManager)) 
        as IVsExtensionManager;

    // Iterate through installed extensions. 
    var attributes = new Dictionary<string, string>();
    attributes.Add("Type", "Skin");
    foreach (string SkinPath
        in ExtMgrSvc.GetEnabledExtensionContentLocations(
        "CustomExtension", attributes))
    {
        // Store the name and path information.
        SkinPaths.Add(SkinPath);
        SkinNames.Add(ExtMgrSvc.CreateExtension(SkinPath).Header.Name);

        // Create a CommandID for the new menu item. 
        var cmdID = new CommandID(
            GuidList.guidVSSkinHostCmdSet, counter);

        // Create the menu item and add its event handlers. 
        var mc = new OleMenuCommand(
            new EventHandler(OnSkinExec), cmdID);
        mc.BeforeQueryStatus += new EventHandler(OnSkinQueryStatus);
        mcs.AddCommand(mc);

        counter ++;
    }
}

private void OnSkinQueryStatus(object sender, EventArgs e)
{
    var menuCommand = sender as OleMenuCommand;
    if (null != menuCommand)
    {
        // Determine which menu item was queried. 
        int skinIndex = menuCommand.CommandID.ID - this.CmdIdBase;
        if (skinIndex >= 0 && skinIndex < this.SkinNames.Count)
        {
            // Set the text.
            menuCommand.Text = this.SkinNames[skinIndex] as string;
        }
    }
}

private void OnSkinExec(object sender, EventArgs e)
{
    var menuCommand = sender as OleMenuCommand;
    if (null != menuCommand)
    {
        // Get the name of the skin from the menu item. 
        string skinName = menuCommand.Text;

        // Locate the name in the list of skins.  
        int i = this.SkinNames.IndexOf(skinName);

        // Get the corrsponding path. 
        var skinPath = SkinPaths[i] as string;

        if (SkinNames.Count > 0)
        {         
            if (File.Exists(skinPath) || Directory.Exists(skinPath))
            {
                // Put code here to apply the skin extension...
                MessageBox.Show("Skin " + skinName + " found:\r\n" 
                    + skinPath + ". \r\n\r\nApplying skin...");
            }
           else MessageBox.Show("Could not find skin " + skinName);
        }
    }
}

.NET Framework 보안

참고 항목

참조

IVsExtensionManager 인터페이스

GetEnabledExtensionContentLocations 오버로드

Microsoft.VisualStudio.ExtensionManager 네임스페이스