-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathService.cs
60 lines (49 loc) · 1.36 KB
/
Service.cs
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
#region
using System.Security.Authentication;
using System.Xml;
using EppLib.Entities;
#endregion
namespace EppLib
{
/// <summary>
/// Encapsulates the EPP protocol
/// </summary>
public class Service
{
private readonly TcpTransport _transport;
public Service(TcpTransport transport)
{
_transport = transport;
}
/// <summary>
/// Connects to the registry end point
/// </summary>
public void Connect(SslProtocols sslProtocols = SslProtocols.Tls)
{
_transport.Connect(sslProtocols);
_transport.Read();
}
/// <summary>
/// Executes an EPP command
/// </summary>
/// <param name="command">The EPP command</param>
/// <returns></returns>
public T Execute<T>(EppBase<T> command) where T : EppResponse
{
var bytes = SendAndReceive(command.ToXml());
return command.FromBytes(bytes);
}
internal byte[] SendAndReceive(XmlDocument xmlDocument)
{
_transport.Write(xmlDocument);
return _transport.Read();
}
/// <summary>
/// Disconects from the registry end point
/// </summary>
public void Disconnect()
{
_transport.Disconnect();
}
}
}