MSDN.WhiteKnight - Stack Overflow answers
Ответ на "Как составить словарь из XAML файла"
Answer 1178314
Можно еще так (добавить ссылки на PresentationFramework и System.Xaml):
using System; using System.Collections.Generic; using System.IO; using System.Text; using System.Windows; using System.Windows.Markup; namespace ConsoleApp1 { class Program { public static object LoadXaml(string path) { StreamReader sr = new StreamReader(path); using (sr) { object el = XamlReader.Load(sr.BaseStream); return el; } } static void Main(string[] args) { ResourceDictionary rd = LoadXaml("...") as ResourceDictionary; if (rd == null) { Console.WriteLine("File is not a resource dictionary"); return; } StringBuilder sb = new StringBuilder(); foreach (var x in rd.Keys) { sb.AppendLine((string)rd[x]); } string res = sb.ToString(); Console.WriteLine(res); Console.ReadKey(); } } }
Content is retrieved from StackExchange API.
Auto-generated by ruso-archive tools.