home
products
contribute
download
documentation
forum
Home
Forums
New posts
Search forums
What's new
New posts
All posts
Latest activity
Members
Registered members
Current visitors
Donate
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Search titles only
By:
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
MediaPortal 2
Plugin Development
Featured Plugins
MP2Extended
Plugin: MP2Extended
Contact us
RSS
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="MrTechno" data-source="post: 1160149" data-attributes="member: 111518"><p>[USER=106003]@FreakyJ[/USER] my first thought would be to split the method in two:</p><p>[CODE=C#] public dynamic Process(IHttpRequest request)</p><p> {</p><p> // sort and filter</p><p> HttpParam httpParam = request.Param;</p><p> WebSortField? sort = GetHttpParam<WebSortField>(httpParam, "sort");</p><p> WebSortOrder? order = GetHttpParam<WebSortOrder>(httpParam, "order");</p><p></p><p> return Process(sort, order);</p><p> }</p><p></p><p> [ApiFunctionDescription(Type = ApiFunctionDescription.FunctionType.Json, Summary = "")]</p><p> [ApiFunctionParam(Name = "sort", Type = typeof(WebSortField), Nullable = true)]</p><p> [ApiFunctionParam(Name = "order", Type = typeof(WebSortOrder), Nullable = true)]</p><p> public List<WebDriveBasic> Process(WebSortField? sort, WebSortOrder? order)</p><p> {</p><p> List<WebDriveBasic> output = DriveBasic();</p><p> if (sort != null && order != null)</p><p> {</p><p> output = output.AsQueryable().SortMediaItemList(sort.Value, order.Value).ToList();</p><p> }</p><p> return output;</p><p> }[/CODE]</p><p>Now it's a bit more obvious which ApiFunctionParam annotations belong to which parameter. Depending on the complexity of your documentation generator you might be able to get a lot of the information from the parameters themselves.</p><p></p><p>My second thought which would require a lot more work up front but could be better in the long run would be to define the whole web API in RAML or Swagger and generate code stubs from the definition.</p></blockquote><p></p>
[QUOTE="MrTechno, post: 1160149, member: 111518"] [USER=106003]@FreakyJ[/USER] my first thought would be to split the method in two: [CODE=C#] public dynamic Process(IHttpRequest request) { // sort and filter HttpParam httpParam = request.Param; WebSortField? sort = GetHttpParam<WebSortField>(httpParam, "sort"); WebSortOrder? order = GetHttpParam<WebSortOrder>(httpParam, "order"); return Process(sort, order); } [ApiFunctionDescription(Type = ApiFunctionDescription.FunctionType.Json, Summary = "")] [ApiFunctionParam(Name = "sort", Type = typeof(WebSortField), Nullable = true)] [ApiFunctionParam(Name = "order", Type = typeof(WebSortOrder), Nullable = true)] public List<WebDriveBasic> Process(WebSortField? sort, WebSortOrder? order) { List<WebDriveBasic> output = DriveBasic(); if (sort != null && order != null) { output = output.AsQueryable().SortMediaItemList(sort.Value, order.Value).ToList(); } return output; }[/CODE] Now it's a bit more obvious which ApiFunctionParam annotations belong to which parameter. Depending on the complexity of your documentation generator you might be able to get a lot of the information from the parameters themselves. My second thought which would require a lot more work up front but could be better in the long run would be to define the whole web API in RAML or Swagger and generate code stubs from the definition. [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
MediaPortal 2
Plugin Development
Featured Plugins
MP2Extended
Plugin: MP2Extended
Contact us
RSS
Top
Bottom