{"id":3631,"date":"2016-03-09T20:53:04","date_gmt":"2016-03-09T20:53:04","guid":{"rendered":"http:\/\/putridparrot.com\/blog\/?p=3631"},"modified":"2016-03-09T20:53:04","modified_gmt":"2016-03-09T20:53:04","slug":"what-resource-names-exist-in-my-wpf-application","status":"publish","type":"post","link":"https:\/\/putridparrot.com\/blog\/what-resource-names-exist-in-my-wpf-application\/","title":{"rendered":"What resource names exist in my WPF application"},"content":{"rendered":"<p>Occasionally I need to get at the names of the resources in an assembly, usually this coincides with me trying to use a resource which either doesn&#8217;t exist of I otherwise make a typo on its name.<\/p>\n<p>This little snippet simply allows us to iterate of the resources in an assembly and returns an array of the key names<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\npublic static string&#x5B;] GetResourceNames(Assembly assembly)\r\n{\r\n   string resName = assembly.GetName().Name + &quot;.g.resources&quot;;\r\n   using (var stream = assembly.GetManifestResourceStream(resName))\r\n   {\r\n      using (var reader = new System.Resources.ResourceReader(stream))\r\n      {\r\n         return reader.Cast&lt;DictionaryEntry&gt;().\r\n                    Select(entry =&gt;\r\n\t\t       (string)entry.Key).ToArray();\r\n      }\r\n   }\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Occasionally I need to get at the names of the resources in an assembly, usually this coincides with me trying to use a resource which either doesn&#8217;t exist of I otherwise make a typo on its name. This little snippet simply allows us to iterate of the resources in an assembly and returns an array [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[13],"tags":[],"class_list":["post-3631","post","type-post","status-publish","format-standard","hentry","category-wpf"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/3631","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/comments?post=3631"}],"version-history":[{"count":1,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/3631\/revisions"}],"predecessor-version":[{"id":3632,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/3631\/revisions\/3632"}],"wp:attachment":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/media?parent=3631"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/categories?post=3631"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/tags?post=3631"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}