コード例 #1
0
        internal static DedicatedHostInstanceView DeserializeDedicatedHostInstanceView(JsonElement element)
        {
            Optional <string> assetId = default;
            Optional <DedicatedHostAvailableCapacity>      availableCapacity = default;
            Optional <IReadOnlyList <InstanceViewStatus> > statuses          = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("assetId"))
                {
                    assetId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("availableCapacity"))
                {
                    availableCapacity = DedicatedHostAvailableCapacity.DeserializeDedicatedHostAvailableCapacity(property.Value);
                    continue;
                }
                if (property.NameEquals("statuses"))
                {
                    List <InstanceViewStatus> array = new List <InstanceViewStatus>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(InstanceViewStatus.DeserializeInstanceViewStatus(item));
                    }
                    statuses = array;
                    continue;
                }
            }
            return(new DedicatedHostInstanceView(assetId.Value, availableCapacity.Value, Optional.ToList(statuses)));
        }
コード例 #2
0
        internal static DedicatedHostInstanceView DeserializeDedicatedHostInstanceView(JsonElement element)
        {
            string assetId = default;
            DedicatedHostAvailableCapacity availableCapacity = default;
            IList <InstanceViewStatus>     statuses          = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("assetId"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    assetId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("availableCapacity"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    availableCapacity = DedicatedHostAvailableCapacity.DeserializeDedicatedHostAvailableCapacity(property.Value);
                    continue;
                }
                if (property.NameEquals("statuses"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <InstanceViewStatus> array = new List <InstanceViewStatus>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(InstanceViewStatus.DeserializeInstanceViewStatus(item));
                        }
                    }
                    statuses = array;
                    continue;
                }
            }
            return(new DedicatedHostInstanceView(assetId, availableCapacity, statuses));
        }
コード例 #3
0
 internal DedicatedHostInstanceView(string assetId, DedicatedHostAvailableCapacity availableCapacity, IReadOnlyList <InstanceViewStatus> statuses)
 {
     AssetId           = assetId;
     AvailableCapacity = availableCapacity;
     Statuses          = statuses;
 }