{"id":598,"date":"2013-07-22T11:35:03","date_gmt":"2013-07-22T11:35:03","guid":{"rendered":"http:\/\/putridparrot.com\/blog\/?p=598"},"modified":"2013-07-22T11:35:29","modified_gmt":"2013-07-22T11:35:29","slug":"enumerated-types-in-wcf","status":"publish","type":"post","link":"https:\/\/putridparrot.com\/blog\/enumerated-types-in-wcf\/","title":{"rendered":"Enumerations in WCF"},"content":{"rendered":"<p>Like other data types designed to go over the WCF wire (as it were) we need to mark the enum with a DataContractAttribute. Unlike classes, which use the DataMemberAttribute for any published methods we use the EnumMemberAttribute. For example<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n&#x5B;DataContract]\r\npublic enum Status\r\n{\r\n   &#x5B;EnumMember]\r\n   None,\r\n   &#x5B;EnumMember]\r\n   Running,\r\n   &#x5B;EnumMember]\r\n   Failed,\r\n   &#x5B;EnumMember]\r\n   Succeeded\r\n}\r\n<\/pre>\n<p>Don&#8217;t forget to add a FlagsAttribute if you are requiring the enum to work as flags otherwise you&#8217;ll get an error from WCF when combining your flags, as the value will be unexpected.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Like other data types designed to go over the WCF wire (as it were) we need to mark the enum with a DataContractAttribute. Unlike classes, which use the DataMemberAttribute for any published methods we use the EnumMemberAttribute. For example &#x5B;DataContract] public enum Status { &#x5B;EnumMember] None, &#x5B;EnumMember] Running, &#x5B;EnumMember] Failed, &#x5B;EnumMember] Succeeded } Don&#8217;t forget [&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":[11],"tags":[],"class_list":["post-598","post","type-post","status-publish","format-standard","hentry","category-wcf"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/598","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=598"}],"version-history":[{"count":5,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/598\/revisions"}],"predecessor-version":[{"id":603,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/598\/revisions\/603"}],"wp:attachment":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/media?parent=598"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/categories?post=598"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/tags?post=598"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}