Ejemplo n.º 1
0
        /// <summary>
        /// Base class for all Mds API calls
        /// </summary>
        /// <param name="deviceName">Name of the device, e.g. Movesense 174430000051</param>
        /// <param name="restOp">The type of REST call to make to MdsLib</param>
        /// <param name="path">The path of the MdsLib resource</param>
        /// <param name="body">JSON body if any</param>
        /// <param name="prefixPath">optional prefix of the target URI before the device serial number (defaults to empty string)</param>
        public ApiCallAsync(string deviceName, MdsOp restOp, string path, string body = null, string prefixPath = "")
        {
            mDeviceName = deviceName;
            mPath       = path;
            mRestOp     = restOp;
            mBody       = body;
            mPrefixPath = prefixPath;

            // Define the built-in implementation of the retry function
            // This just retries 2 times, regardless of the exception thrown
            // The user may provide their own implementation of the Retry function to override this behavior
            RetryFunction = new Func <Exception, bool?>((Exception ex) =>
            {
                bool?cancel = false;
                if (++retries > MAX_RETRY_COUNT)
                {
                    cancel = true;
                }
                return(cancel);
            }
                                                        );
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Function to make Mds API call that returns a value of type T
 /// </summary>
 /// <param name="movesenseDevice">IMovesenseDevice for the device</param>
 /// <param name="restOp">The type of REST call to make to MdsLib</param>
 /// <param name="path">The path of the MdsLib resource</param>
 /// <param name="body">JSON body if any</param>
 /// <param name="prefixPath">optional prefix of the target URI before the device serial number (defaults to empty string)</param>
 public async Task <T> ApiCallAsync <T>(IMovesenseDevice movesenseDevice, MdsOp restOp, string path, string body = null, string prefixPath = "")
 {
     return(await new ApiCallAsync <T>(movesenseDevice, restOp, path, body, prefixPath).CallAsync().ConfigureAwait(false));
 }
 /// <summary>
 /// Function to make Mds API call that does not return a value
 /// </summary>
 /// <param name="movesenseDevice">IMovesenseDevice for the device</param>
 /// <param name="restOp">The type of REST call to make to MdsLib</param>
 /// <param name="path">The path of the MdsLib resource</param>
 /// <param name="body">JSON body if any</param>
 /// <param name="prefixPath">optional prefix of the target URI before the device serial number (defaults to empty string)</param>
 public async Task ApiCallAsync(IMovesenseDevice movesenseDevice, MdsOp restOp, string path, string body = null, string prefixPath = "")
 {
     await new ApiCallAsync(movesenseDevice, restOp, path, body, prefixPath).CallAsync();
 }
Ejemplo n.º 4
0
 public async Task ApiCallAsync(string deviceName, MdsOp restOp, string path, string body = null, string prefixPath = "")
 {
     await new ApiCallAsync(deviceName, restOp, path, body, prefixPath).CallAsync().ConfigureAwait(false);
 }
 public async Task <T> ApiCallAsync <T>(string deviceName, MdsOp restOp, string path, string body = null, string prefixPath = "")
 {
     return(await new ApiCallAsync <T>(deviceName, restOp, path, body, prefixPath).CallAsync());
 }