{"id":2585,"date":"2019-09-17T13:14:12","date_gmt":"2019-09-17T12:14:12","guid":{"rendered":"https:\/\/solidt.eu\/site\/?p=2585"},"modified":"2022-07-25T08:33:26","modified_gmt":"2022-07-25T07:33:26","slug":"c-get-attribute-info","status":"publish","type":"post","link":"https:\/\/solidt.eu\/site\/c-get-attribute-info\/","title":{"rendered":"C# Get attribute info"},"content":{"rendered":"\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">private static T1 GetAttribute&lt;T1>(global::System.Reflection.PropertyInfo prop) where T1 : Attribute\n{\n\treturn prop.GetCustomAttributes(typeof(T1), false).FirstOrDefault() as T1;\n}\n\nvar properties = typeof(T).GetProperties();\nforeach (var prop in properties)\n{\n\tvar requiredAttr = GetAttribute&lt;RequiredAttribute>(prop);\n}\n<\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[6,4,1],"tags":[],"class_list":["post-2585","post","type-post","status-publish","format-standard","hentry","category-dotnet","category-programming","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/2585","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/comments?post=2585"}],"version-history":[{"count":1,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/2585\/revisions"}],"predecessor-version":[{"id":2586,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/2585\/revisions\/2586"}],"wp:attachment":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/media?parent=2585"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/categories?post=2585"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/tags?post=2585"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}