Beispiel #1
0
 internal Usage(string id, UsageUnit unit, long currentValue, long limit, UsageName name) : base(id)
 {
     Unit         = unit;
     CurrentValue = currentValue;
     Limit        = limit;
     Name         = name;
 }
Beispiel #2
0
 internal Usage(string id, string unit, long currentValue, long limit, UsageName name)
 {
     Id = id;
     Unit = unit;
     CurrentValue = currentValue;
     Limit = limit;
     Name = name;
 }
Beispiel #3
0
 internal NetworkUsage(ResourceIdentifier id, UsageUnit unit, long currentValue, long limit, UsageName name)
 {
     Id           = id;
     Unit         = unit;
     CurrentValue = currentValue;
     Limit        = limit;
     Name         = name;
 }
Beispiel #4
0
        internal Usage(UsageUnit unit, long currentValue, long limit, UsageName name)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            Unit         = unit;
            CurrentValue = currentValue;
            Limit        = limit;
            Name         = name;
        }
Beispiel #5
0
        internal static NetworkUsage DeserializeNetworkUsage(JsonElement element)
        {
            Optional <ResourceIdentifier> id = default;
            UsageUnit unit         = default;
            long      currentValue = default;
            long      limit        = default;
            UsageName name         = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("id"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    id = new ResourceIdentifier(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("unit"))
                {
                    unit = new UsageUnit(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("currentValue"))
                {
                    currentValue = property.Value.GetInt64();
                    continue;
                }
                if (property.NameEquals("limit"))
                {
                    limit = property.Value.GetInt64();
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = UsageName.DeserializeUsageName(property.Value);
                    continue;
                }
            }
            return(new NetworkUsage(id.Value, unit, currentValue, limit, name));
        }
Beispiel #6
0
        internal static Usage DeserializeUsage(JsonElement element)
        {
            string    id           = default;
            string    unit         = default;
            long      currentValue = default;
            long      limit        = default;
            UsageName name         = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("id"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("unit"))
                {
                    unit = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("currentValue"))
                {
                    currentValue = property.Value.GetInt64();
                    continue;
                }
                if (property.NameEquals("limit"))
                {
                    limit = property.Value.GetInt64();
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = UsageName.DeserializeUsageName(property.Value);
                    continue;
                }
            }
            return(new Usage(id, unit, currentValue, limit, name));
        }
Beispiel #7
0
        internal static NetworkUsage DeserializeNetworkUsage(JsonElement element)
        {
            Optional <string> id   = default;
            UsageUnit         unit = default;
            long      currentValue = default;
            long      limit        = default;
            UsageName name         = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("id"))
                {
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("unit"))
                {
                    unit = new UsageUnit(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("currentValue"))
                {
                    currentValue = property.Value.GetInt64();
                    continue;
                }
                if (property.NameEquals("limit"))
                {
                    limit = property.Value.GetInt64();
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = UsageName.DeserializeUsageName(property.Value);
                    continue;
                }
            }
            return(new NetworkUsage(id.Value, unit, currentValue, limit, name));
        }