internal RoleInstance(ResourceIdentifier id, string name, ResourceType type, string location, IReadOnlyDictionary <string, string> tags, InstanceSku sku, RoleInstanceProperties properties) : base(id, name, type) { Location = location; Tags = tags; Sku = sku; Properties = properties; }
internal static RoleInstance DeserializeRoleInstance(JsonElement element) { Optional <string> location = default; Optional <IReadOnlyDictionary <string, string> > tags = default; Optional <InstanceSku> sku = default; Optional <RoleInstanceProperties> properties = default; ResourceIdentifier id = default; string name = default; ResourceType type = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("location")) { location = property.Value.GetString(); continue; } if (property.NameEquals("tags")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } Dictionary <string, string> dictionary = new Dictionary <string, string>(); foreach (var property0 in property.Value.EnumerateObject()) { dictionary.Add(property0.Name, property0.Value.GetString()); } tags = dictionary; continue; } if (property.NameEquals("sku")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } sku = InstanceSku.DeserializeInstanceSku(property.Value); continue; } if (property.NameEquals("properties")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } properties = RoleInstanceProperties.DeserializeRoleInstanceProperties(property.Value); continue; } if (property.NameEquals("id")) { id = property.Value.GetString(); continue; } if (property.NameEquals("name")) { name = property.Value.GetString(); continue; } if (property.NameEquals("type")) { type = property.Value.GetString(); continue; } } return(new RoleInstance(id, name, type, location.Value, Optional.ToDictionary(tags), sku.Value, properties.Value)); }