{"id":121,"date":"2006-05-31T11:50:20","date_gmt":"2006-05-31T18:50:20","guid":{"rendered":"http:\/\/kennyw.com\/indigo\/121"},"modified":"2006-05-31T11:50:20","modified_gmt":"2006-05-31T18:50:20","slug":"using-overloaded-operations-in-your-servicecontract","status":"publish","type":"post","link":"https:\/\/kennyw.com\/?p=121","title":{"rendered":"Using Overloaded Operations in your ServiceContract"},"content":{"rendered":"<p>A common programming paradigm with objects is the use of overloaded methods. That is, multiple methods with the same name, but different parameters.  In reality though, this paradigm is syntactic sugar on top of a compiler that is generating different fully-qualified names.<\/p>\n<p>It may be that you&#8217;ve done your service-oriented scrub and decided you want to expose two overloaded methods. From a service-orientation perspective, the compiler isn&#8217;t adding extra qualifications to differentiate the methods. Our <a href=\"http:\/\/kennyw.com\/indigo\/78\">default action generation<\/a> is based on the operation name, which defaults to the name of your method. As  such, in order for a client (and our dispatcher) to distinguish between multiple overloaded methods, you need to provide them with unique names. For example:<\/p>\n<div class=\"code\">\n[<code class=\"classname\">ServiceContract<\/code>]<br \/>\n<code class=\"keyword\">interface<\/code> <code class=\"classname\">ICalculator<\/code><br \/>\n{<\/p>\n<div class=\"indent1\">[<code class=\"classname\">OperationContract<\/code>(Name= <code class=\"string\">\"Add_Int\"<\/code>)]<br \/>\n    <code class=\"keyword\">int<\/code> Add(<code class=\"keyword\">int<\/code> x, <code class=\"keyword\">int<\/code> y);<\/p>\n<p>    [<code class=\"classname\">OperationContract<\/code>(Name= <code class=\"string\">\"Add_Long\"<\/code>)]<br \/>\n    <code class=\"keyword\">long<\/code> Add(<code class=\"keyword\">long<\/code> x, <code class=\"keyword\">long<\/code> y);<\/div>\n<p>}<\/p><\/div>\n","protected":false},"excerpt":{"rendered":"<p>A common programming paradigm with objects is the use of overloaded methods. That is, multiple methods with the same name, but different parameters. In reality though, this paradigm is syntactic sugar on top of a compiler that is generating different fully-qualified names. It may be that you&#8217;ve done your service-oriented scrub and decided you want [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-121","post","type-post","status-publish","format-standard","hentry","category-indigo"],"_links":{"self":[{"href":"https:\/\/kennyw.com\/index.php?rest_route=\/wp\/v2\/posts\/121","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kennyw.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kennyw.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kennyw.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/kennyw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=121"}],"version-history":[{"count":0,"href":"https:\/\/kennyw.com\/index.php?rest_route=\/wp\/v2\/posts\/121\/revisions"}],"wp:attachment":[{"href":"https:\/\/kennyw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=121"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kennyw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=121"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kennyw.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=121"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}