Particle.ParticleCloud.GetDevicesAsync C# (CSharp) 메소드

GetDevicesAsync() 공개 메소드

Get the list of devices the user has access to
public GetDevicesAsync ( ) : Task>>
리턴 Task>>
		public async Task<Result<List<ParticleDevice>>> GetDevicesAsync()
		{
			try
			{
				var response = await MakeGetRequestWithAuthTestAsync("devices");

				if (response.StatusCode == System.Net.HttpStatusCode.OK)
				{
					List<ParticleDevice> items = new List<ParticleDevice>();
					await Task.Run(() =>
						{
							foreach (JObject obj in (JArray)response.Response)
							{
								items.Add(new ParticleDevice(this, obj));
							}
						});

					return new Result<List<ParticleDevice>>(true, items);
				}
				else
				{
					return response.AsResult<List<ParticleDevice>>();
				}
			}
			catch (HttpRequestException re)
			{
				return new Result<List<ParticleDevice>>(false, new List<ParticleDevice>())
				{
					Error = re.Message,
					Exception = re
				};
			}
		}