Skip to content

Commit 9b1aaa5

Browse files
committed
Move types around
1 parent 01e7e6d commit 9b1aaa5

File tree

3 files changed

+54
-54
lines changed

3 files changed

+54
-54
lines changed

Diff for: App/Services/MutagenController.cs

+34-34
Original file line numberDiff line numberDiff line change
@@ -23,50 +23,50 @@
2323

2424
namespace Coder.Desktop.App.Services;
2525

26-
public enum CreateSyncSessionRequestEndpointProtocol
27-
{
28-
Local,
29-
Ssh,
30-
}
31-
32-
public class CreateSyncSessionRequestEndpoint
26+
public class CreateSyncSessionRequest
3327
{
34-
public required CreateSyncSessionRequestEndpointProtocol Protocol { get; init; }
35-
public string User { get; init; } = "";
36-
public string Host { get; init; } = "";
37-
public uint Port { get; init; } = 0;
38-
public string Path { get; init; } = "";
28+
public required Endpoint Alpha { get; init; }
29+
public required Endpoint Beta { get; init; }
3930

40-
public URL MutagenUrl
31+
public class Endpoint
4132
{
42-
get
33+
public enum ProtocolKind
4334
{
44-
var protocol = Protocol switch
45-
{
46-
CreateSyncSessionRequestEndpointProtocol.Local => MutagenProtocol.Local,
47-
CreateSyncSessionRequestEndpointProtocol.Ssh => MutagenProtocol.Ssh,
48-
_ => throw new ArgumentException($"Invalid protocol '{Protocol}'", nameof(Protocol)),
49-
};
35+
Local,
36+
Ssh,
37+
}
5038

51-
return new URL
39+
public required ProtocolKind Protocol { get; init; }
40+
public string User { get; init; } = "";
41+
public string Host { get; init; } = "";
42+
public uint Port { get; init; } = 0;
43+
public string Path { get; init; } = "";
44+
45+
public URL MutagenUrl
46+
{
47+
get
5248
{
53-
Kind = Kind.Synchronization,
54-
Protocol = protocol,
55-
User = User,
56-
Host = Host,
57-
Port = Port,
58-
Path = Path,
59-
};
49+
var protocol = Protocol switch
50+
{
51+
ProtocolKind.Local => MutagenProtocol.Local,
52+
ProtocolKind.Ssh => MutagenProtocol.Ssh,
53+
_ => throw new ArgumentException($"Invalid protocol '{Protocol}'", nameof(Protocol)),
54+
};
55+
56+
return new URL
57+
{
58+
Kind = Kind.Synchronization,
59+
Protocol = protocol,
60+
User = User,
61+
Host = Host,
62+
Port = Port,
63+
Path = Path,
64+
};
65+
}
6066
}
6167
}
6268
}
6369

64-
public class CreateSyncSessionRequest
65-
{
66-
public required CreateSyncSessionRequestEndpoint Alpha { get; init; }
67-
public required CreateSyncSessionRequestEndpoint Beta { get; init; }
68-
}
69-
7070
public interface ISyncSessionController : IAsyncDisposable
7171
{
7272
Task<IEnumerable<SyncSessionModel>> ListSyncSessions(CancellationToken ct = default);

Diff for: App/ViewModels/FileSyncListViewModel.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -250,14 +250,14 @@ private async Task ConfirmNewSession()
250250
{
251251
await _syncSessionController.CreateSyncSession(new CreateSyncSessionRequest
252252
{
253-
Alpha = new CreateSyncSessionRequestEndpoint
253+
Alpha = new CreateSyncSessionRequest.Endpoint
254254
{
255-
Protocol = CreateSyncSessionRequestEndpointProtocol.Local,
255+
Protocol = CreateSyncSessionRequest.Endpoint.ProtocolKind.Local,
256256
Path = NewSessionLocalPath,
257257
},
258-
Beta = new CreateSyncSessionRequestEndpoint
258+
Beta = new CreateSyncSessionRequest.Endpoint
259259
{
260-
Protocol = CreateSyncSessionRequestEndpointProtocol.Ssh,
260+
Protocol = CreateSyncSessionRequest.Endpoint.ProtocolKind.Ssh,
261261
Host = NewSessionRemoteHost,
262262
Path = NewSessionRemotePath,
263263
},

Diff for: Tests.App/Services/MutagenControllerTest.cs

+16-16
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,14 @@ public async Task Ok(CancellationToken ct)
101101

102102
var session1 = await controller.CreateSyncSession(new CreateSyncSessionRequest
103103
{
104-
Alpha = new CreateSyncSessionRequestEndpoint
104+
Alpha = new CreateSyncSessionRequest.Endpoint
105105
{
106-
Protocol = CreateSyncSessionRequestEndpointProtocol.Local,
106+
Protocol = CreateSyncSessionRequest.Endpoint.ProtocolKind.Local,
107107
Path = alphaDirectory.FullName,
108108
},
109-
Beta = new CreateSyncSessionRequestEndpoint
109+
Beta = new CreateSyncSessionRequest.Endpoint
110110
{
111-
Protocol = CreateSyncSessionRequestEndpointProtocol.Local,
111+
Protocol = CreateSyncSessionRequest.Endpoint.ProtocolKind.Local,
112112
Path = betaDirectory.FullName,
113113
},
114114
}, ct);
@@ -119,14 +119,14 @@ public async Task Ok(CancellationToken ct)
119119

120120
var session2 = await controller.CreateSyncSession(new CreateSyncSessionRequest
121121
{
122-
Alpha = new CreateSyncSessionRequestEndpoint
122+
Alpha = new CreateSyncSessionRequest.Endpoint
123123
{
124-
Protocol = CreateSyncSessionRequestEndpointProtocol.Local,
124+
Protocol = CreateSyncSessionRequest.Endpoint.ProtocolKind.Local,
125125
Path = alphaDirectory.FullName,
126126
},
127-
Beta = new CreateSyncSessionRequestEndpoint
127+
Beta = new CreateSyncSessionRequest.Endpoint
128128
{
129-
Protocol = CreateSyncSessionRequestEndpointProtocol.Local,
129+
Protocol = CreateSyncSessionRequest.Endpoint.ProtocolKind.Local,
130130
Path = betaDirectory.FullName,
131131
},
132132
}, ct);
@@ -199,14 +199,14 @@ public async Task CreateRestartsDaemon(CancellationToken ct)
199199
await controller.Initialize(ct);
200200
await controller.CreateSyncSession(new CreateSyncSessionRequest
201201
{
202-
Alpha = new CreateSyncSessionRequestEndpoint
202+
Alpha = new CreateSyncSessionRequest.Endpoint
203203
{
204-
Protocol = CreateSyncSessionRequestEndpointProtocol.Local,
204+
Protocol = CreateSyncSessionRequest.Endpoint.ProtocolKind.Local,
205205
Path = alphaDirectory.FullName,
206206
},
207-
Beta = new CreateSyncSessionRequestEndpoint
207+
Beta = new CreateSyncSessionRequest.Endpoint
208208
{
209-
Protocol = CreateSyncSessionRequestEndpointProtocol.Local,
209+
Protocol = CreateSyncSessionRequest.Endpoint.ProtocolKind.Local,
210210
Path = betaDirectory.FullName,
211211
},
212212
}, ct);
@@ -239,14 +239,14 @@ public async Task Orphaned(CancellationToken ct)
239239
await controller1.Initialize(ct);
240240
await controller1.CreateSyncSession(new CreateSyncSessionRequest
241241
{
242-
Alpha = new CreateSyncSessionRequestEndpoint
242+
Alpha = new CreateSyncSessionRequest.Endpoint
243243
{
244-
Protocol = CreateSyncSessionRequestEndpointProtocol.Local,
244+
Protocol = CreateSyncSessionRequest.Endpoint.ProtocolKind.Local,
245245
Path = alphaDirectory.FullName,
246246
},
247-
Beta = new CreateSyncSessionRequestEndpoint
247+
Beta = new CreateSyncSessionRequest.Endpoint
248248
{
249-
Protocol = CreateSyncSessionRequestEndpointProtocol.Local,
249+
Protocol = CreateSyncSessionRequest.Endpoint.ProtocolKind.Local,
250250
Path = betaDirectory.FullName,
251251
},
252252
}, ct);

0 commit comments

Comments
 (0)