67 lines
1.8 KiB
C#
67 lines
1.8 KiB
C#
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Configuration;
|
|||
|
|
using System.Data;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Runtime.CompilerServices;
|
|||
|
|
using System.Security.Policy;
|
|||
|
|
using System.Text;
|
|||
|
|
using System.Threading.Tasks;
|
|||
|
|
using System.Windows;
|
|||
|
|
|
|||
|
|
namespace WPFAppTest;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// App.xaml 的交互逻辑
|
|||
|
|
/// </summary>
|
|||
|
|
public partial class App : Application
|
|||
|
|
{
|
|||
|
|
static int n = 0;
|
|||
|
|
public App()
|
|||
|
|
{
|
|||
|
|
InitializeComponent();
|
|||
|
|
var res = Resources;
|
|||
|
|
|
|||
|
|
FetchResources(res);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static void FetchResources(ResourceDictionary res, [CallerMemberName] string callerName = null)
|
|||
|
|
{
|
|||
|
|
StringBuilder sb = new StringBuilder();
|
|||
|
|
var resourceDictionary = res.MergedDictionaries.FirstOrDefault();
|
|||
|
|
if (resourceDictionary == null)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
foreach (string r in resourceDictionary.Keys)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
var value = resourceDictionary[r];
|
|||
|
|
if (value is string str)
|
|||
|
|
{
|
|||
|
|
sb.AppendLine($"{r} = {str}");
|
|||
|
|
}
|
|||
|
|
else if (value is Uri uri)
|
|||
|
|
{
|
|||
|
|
sb.AppendLine($"{r} = {uri}");
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
sb.AppendLine($"{r} = {value}");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception)
|
|||
|
|
{
|
|||
|
|
sb.AppendLine($"{r}");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
//将结果输出到桌面的一个文本文件
|
|||
|
|
string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
|
|||
|
|
string filePath = System.IO.Path.Combine(desktopPath, $"{callerName}{n}.txt");
|
|||
|
|
System.IO.File.WriteAllText(filePath, sb.ToString());
|
|||
|
|
n++;
|
|||
|
|
//MessageBox.Show(sb.ToString());
|
|||
|
|
}
|
|||
|
|
}
|