How to get programatically all capablities that enable in manifest for UWP app

白昼怎懂夜的黑 提交于 2019-12-02 10:16:11

问题


ITNOA

I want to create a library, and I need to programmatically check to what capabilities enable in UWP app that use my library.

I don't know how to do it?


回答1:


Reading the appxmanifest directly as a XML file is the way to go here. Something like this:

var doc = XDocument.Load("AppxManifest.xml", LoadOptions.None);
var xname = XNamespace.Get("http://schemas.microsoft.com/appx/manifest/foundation/windows10");
var capabilitiesNode = doc.Root.Descendants(xname + "Capabilities").First();

foreach (var capability in capabilitiesNode.Descendants())
{
    Debug.WriteLine(capability.Name + ": " + capability.Attribute("Name").Value);
}


来源:https://stackoverflow.com/questions/40043022/how-to-get-programatically-all-capablities-that-enable-in-manifest-for-uwp-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!