internal RenderingSession(string sessionId, RenderingServerSize size, RenderingSessionStatus status) { if (sessionId == null) { throw new ArgumentNullException(nameof(sessionId)); } SessionId = sessionId; Size = size; Status = status; }
internal RenderingSession(string sessionId, int?arrInspectorPort, int?handshakePort, int?elapsedTimeMinutes, string host, int?maxLeaseTimeMinutes, RenderingServerSize size, RenderingSessionStatus status, float?teraflops, RemoteRenderingServiceError error, DateTimeOffset?createdOn) { SessionId = sessionId; ArrInspectorPort = arrInspectorPort; HandshakePort = handshakePort; ElapsedTimeMinutes = elapsedTimeMinutes; Host = host; MaxLeaseTimeMinutes = maxLeaseTimeMinutes; Size = size; Status = status; Teraflops = teraflops; Error = error; CreatedOn = createdOn; }
/// <summary> /// Initializes a new instance of the <see cref="RenderingSession"/> class for mocking purposes. /// </summary> public static RenderingSession RenderingSession(string sessionId, int?arrInspectorPort, int?handshakePort, int?elapsedTimeMinutes, string host, int?maxLeaseTimeMinutes, RenderingServerSize size, RenderingSessionStatus status, float?teraflops, RemoteRenderingServiceError error, DateTimeOffset?createdOn) => new RenderingSession(sessionId, arrInspectorPort, handshakePort, elapsedTimeMinutes, host, maxLeaseTimeMinutes, size, status, teraflops, error, createdOn);
internal static RenderingSession DeserializeRenderingSession(JsonElement element) { string id = default; Optional <int> arrInspectorPort = default; Optional <int> handshakePort = default; Optional <int> elapsedTimeMinutes = default; Optional <string> hostname = default; Optional <int> maxLeaseTimeMinutes = default; RenderingServerSize size = default; RenderingSessionStatus status = default; Optional <float> teraflops = default; Optional <RemoteRenderingServiceError> error = default; Optional <DateTimeOffset> creationTime = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("id")) { id = property.Value.GetString(); continue; } if (property.NameEquals("arrInspectorPort")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } arrInspectorPort = property.Value.GetInt32(); continue; } if (property.NameEquals("handshakePort")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } handshakePort = property.Value.GetInt32(); continue; } if (property.NameEquals("elapsedTimeMinutes")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } elapsedTimeMinutes = property.Value.GetInt32(); continue; } if (property.NameEquals("hostname")) { hostname = property.Value.GetString(); continue; } if (property.NameEquals("maxLeaseTimeMinutes")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } maxLeaseTimeMinutes = property.Value.GetInt32(); continue; } if (property.NameEquals("size")) { size = new RenderingServerSize(property.Value.GetString()); continue; } if (property.NameEquals("status")) { status = new RenderingSessionStatus(property.Value.GetString()); continue; } if (property.NameEquals("teraflops")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } teraflops = property.Value.GetSingle(); continue; } if (property.NameEquals("error")) { if (property.Value.ValueKind == JsonValueKind.Null) { error = null; continue; } error = RemoteRenderingServiceError.DeserializeRemoteRenderingServiceError(property.Value); continue; } if (property.NameEquals("creationTime")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } creationTime = property.Value.GetDateTimeOffset("O"); continue; } } return(new RenderingSession(id, Optional.ToNullable(arrInspectorPort), Optional.ToNullable(handshakePort), Optional.ToNullable(elapsedTimeMinutes), hostname.Value, Optional.ToNullable(maxLeaseTimeMinutes), size, status, Optional.ToNullable(teraflops), error.Value, Optional.ToNullable(creationTime))); }