C# Client Library
A C# Client Library for the AnalyzeRe REST API
Loading...
Searching...
No Matches
ExtensionMethods.Rest.InferredType.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using RestSharp;
4
5namespace AnalyzeRe
6{
8 public static partial class ExtensionMethods
9 {
10 // Get methods that return an object of the same type it was called on
17 public static O Get<O>(this O obj, IEnumerable<Parameter> requestParameters = null, int? timeout = null) where O : IAPIResource
18 {
19 return typeof(O) == obj.GetType() ?
20 Get_AsType<O>(obj, requestParameters, timeout) :
21 (O)obj.Get(obj.GetType(), requestParameters, timeout);
22 }
23
30 public static O Post<O>(this O obj, IEnumerable<Parameter> requestParameters = null, int? timeout = null) where O : IAPIResource
31 {
32 return typeof(O) == obj.GetType() ?
33 Post_AsType<O>(obj, requestParameters, timeout) :
34 (O)obj.Post(obj.GetType(), requestParameters, timeout);
35 }
36
43 public static O Put<O>(this O obj, IEnumerable<Parameter> requestParameters = null, int? timeout = null) where O : IAPIResource
44 {
45 return typeof(O) == obj.GetType() ?
46 Put_AsType<O>(obj, requestParameters, timeout) :
47 (O)obj.Put(obj.GetType(), requestParameters, timeout);
48 }
49
56 public static O Save<O>(this O obj, IEnumerable<Parameter> requestParameters = null, int? timeout = null) where O : IAPIResource
57 {
58 return String.IsNullOrWhiteSpace(obj.id) ?
59 obj.Post(requestParameters, timeout) :
60 obj.Put(requestParameters, timeout);
61 }
62 }
63}
static O Get< O >(this O obj, IEnumerable< Parameter > requestParameters=null, int? timeout=null)
Perform a GET on the current resource to return the equivalent resource stored on the server....
static O Save< O >(this O obj, IEnumerable< Parameter > requestParameters=null, int? timeout=null)
Calls either the POST object if the current resource is new, or PUT if the current resource already h...
static O Put< O >(this O obj, IEnumerable< Parameter > requestParameters=null, int? timeout=null)
Perform a PUT on the current resource, with the expectation that the server will respond with the upd...
static O Post< O >(this O obj, IEnumerable< Parameter > requestParameters=null, int? timeout=null)
Perform a POST on the current resource, with the expectation that the server will respond with the ob...
Interface for Base class used by all resources.