コード例 #1
0
        /// <summary>
        /// Takes picture and downloads image to specified stream.
        /// </summary>
        /// <param name="client">The <see cref="ICameraClient"/> method extends.</param>
        /// <param name="targetStream">The target stream image is downloaded to.</param>
        /// <param name="useLocalFileUri">Optional flag for if absolute uri returned from camera should be used or absolute uri created from <see cref="ICameraClient.EndPoint"/> and relative uri, useful if called through a proxy. Default value <c>false</c></param>
        public static async Task TakePicture(this ICameraClient client, Stream targetStream, bool useLocalFileUri = false)
        {
            var uri = await client.TakePicture(useLocalFileUri);

            using (var sourceStream = await client.GetHttpClient().GetStreamAsync(uri))
            {
                await sourceStream.CopyToAsync(targetStream);
            }
        }
コード例 #2
0
        private static async Task <TResult> PostAsJson <TResult>(this ICameraClient client, object value, Uri uri = null)
        {
            var response = await client.GetHttpClient().PostAsJsonAsync(
                uri ?? ExecuteUri,
                value
                );

            response.EnsureSuccessStatusCode();

            var result = await response.Content.ReadAsAsync <TResult>();

            return(result);
        }