-
Notifications
You must be signed in to change notification settings - Fork 66
Expand file tree
/
Copy pathNode.cs
More file actions
88 lines (78 loc) · 2.79 KB
/
Copy pathNode.cs
File metadata and controls
88 lines (78 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
using System;
using System.Linq;
namespace Typesense.Setup;
/// <summary>
/// The node contains the configuration for a remote Typesense service.
/// </summary>
public record Node
{
/// <summary>
/// Hostname for the Typesense service.
/// </summary>
public string Host { get; set; }
/// <summary>
/// Port for the Typesense service.
/// </summary>
public string Port { get; set; }
/// <summary>
/// Protocol for the Typesense service - defaults to http.
/// </summary>
public string Protocol { get; set; } = "http";
/// <summary>
/// Protocol for the Typesense service - defaults to http.
/// </summary>
public string AdditionalPath { get; set; } = "";
[Obsolete("Use multi-arity constructor instead.")]
public Node()
{
Host = "";
Port = "";
Protocol = "";
}
/// <param name="host">Hostname for the Typesense service.</param>
/// <param name="port">Port for the typesense service.</param>
/// <param name="protocol">Protocol for the Typesense service - defaults to http.</param>
/// <exception cref="ArgumentException"></exception>
public Node(string host, string port, string protocol = "http")
{
if (string.IsNullOrEmpty(host))
{
throw new ArgumentException("Cannot be NULL or empty.", nameof(host));
}
if (string.IsNullOrEmpty(protocol))
{
throw new ArgumentException("Cannot be NULL or empty.", nameof(protocol));
}
if (string.IsNullOrEmpty(port))
{
throw new ArgumentException("Cannot be NULL or empty.", nameof(port));
}
Host = host;
Port = port;
Protocol = protocol;
}
/// <param name="host">Hostname for the Typesense service.</param>
/// <param name="port">Port for the typesense service.</param>
/// <param name="protocol">Protocol for the Typesense service - defaults to http.</param>
/// <param name="additionalPath">additionalPath (without trailing or leading '/') for the Typesense service - defaults to empty string.</param>
/// <exception cref="ArgumentException"></exception>
public Node(string host, string port, string protocol = "http", string additionalPath = "")
{
if (string.IsNullOrEmpty(host))
{
throw new ArgumentException("Cannot be NULL or empty.", nameof(host));
}
if (string.IsNullOrEmpty(protocol))
{
throw new ArgumentException("Cannot be NULL or empty.", nameof(protocol));
}
if (string.IsNullOrEmpty(port))
{
throw new ArgumentException("Cannot be NULL or empty.", nameof(port));
}
Host = host;
Port = port;
Protocol = protocol;
AdditionalPath = additionalPath + "/";
}
}