如何以编程方式获取在 UWP 应用程序清单中启用的所有功能 [英] How to get programatically all capablities that enable in manifest for UWP app

查看:17
本文介绍了如何以编程方式获取在 UWP 应用程序清单中启用的所有功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ITNOA

我想创建一个库,我需要以编程方式检查使用我的库的 UWP 应用中启用了哪些功能.

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

我不知道该怎么做?

推荐答案

直接将 appxmanifest 作为 XML 文件读取是这里的方法.像这样:

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);
}

这篇关于如何以编程方式获取在 UWP 应用程序清单中启用的所有功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆