void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) { writer.WriteStartObject(); if (Optional.IsDefined(ManagedBy)) { writer.WritePropertyName("managedBy"); writer.WriteStringValue(ManagedBy); } if (Optional.IsDefined(Sku)) { writer.WritePropertyName("sku"); writer.WriteObjectValue(Sku); } writer.WritePropertyName("tags"); writer.WriteStartObject(); foreach (var item in Tags) { writer.WritePropertyName(item.Key); writer.WriteStringValue(item.Value); } writer.WriteEndObject(); writer.WritePropertyName("location"); writer.WriteStringValue(Location); writer.WritePropertyName("properties"); writer.WriteStartObject(); writer.WritePropertyName("lockLevel"); writer.WriteStringValue(LockLevel.ToSerialString()); if (Optional.IsDefined(DisplayName)) { writer.WritePropertyName("displayName"); writer.WriteStringValue(DisplayName); } if (Optional.IsDefined(IsEnabled)) { writer.WritePropertyName("isEnabled"); writer.WriteBooleanValue(IsEnabled.Value); } if (Optional.IsCollectionDefined(Authorizations)) { writer.WritePropertyName("authorizations"); writer.WriteStartArray(); foreach (var item in Authorizations) { writer.WriteObjectValue(item); } writer.WriteEndArray(); } if (Optional.IsCollectionDefined(Artifacts)) { writer.WritePropertyName("artifacts"); writer.WriteStartArray(); foreach (var item in Artifacts) { writer.WriteObjectValue(item); } writer.WriteEndArray(); } if (Optional.IsDefined(Description)) { writer.WritePropertyName("description"); writer.WriteStringValue(Description); } if (Optional.IsDefined(PackageFileUri)) { writer.WritePropertyName("packageFileUri"); writer.WriteStringValue(PackageFileUri.AbsoluteUri); } if (Optional.IsDefined(MainTemplate)) { writer.WritePropertyName("mainTemplate"); #if NET6_0_OR_GREATER writer.WriteRawValue(MainTemplate); #else JsonSerializer.Serialize(writer, JsonDocument.Parse(MainTemplate.ToString()).RootElement); #endif } if (Optional.IsDefined(CreateUiDefinition)) { writer.WritePropertyName("createUiDefinition"); #if NET6_0_OR_GREATER writer.WriteRawValue(CreateUiDefinition); #else JsonSerializer.Serialize(writer, JsonDocument.Parse(CreateUiDefinition.ToString()).RootElement); #endif } if (Optional.IsDefined(NotificationPolicy)) { writer.WritePropertyName("notificationPolicy"); writer.WriteObjectValue(NotificationPolicy); } if (Optional.IsDefined(LockingPolicy)) { writer.WritePropertyName("lockingPolicy"); writer.WriteObjectValue(LockingPolicy); } if (Optional.IsDefined(DeploymentPolicy)) { writer.WritePropertyName("deploymentPolicy"); writer.WriteObjectValue(DeploymentPolicy); } if (Optional.IsDefined(ManagementPolicy)) { writer.WritePropertyName("managementPolicy"); writer.WriteObjectValue(ManagementPolicy); } if (Optional.IsCollectionDefined(Policies)) { writer.WritePropertyName("policies"); writer.WriteStartArray(); foreach (var item in Policies) { writer.WriteObjectValue(item); } writer.WriteEndArray(); } writer.WriteEndObject(); writer.WriteEndObject(); }