|
25 | 25 |
|
26 | 26 | namespace Platibus.Config |
27 | 27 | { |
| 28 | + /// <inheritdoc cref="PlatibusConfiguration"/> |
| 29 | + /// <inheritdoc cref="ILoopbackConfiguration"/> |
28 | 30 | /// <summary> |
29 | 31 | /// A loopback configuration |
30 | 32 | /// </summary> |
31 | 33 | public class LoopbackConfiguration : PlatibusConfiguration, ILoopbackConfiguration |
32 | 34 | { |
33 | | - private readonly EndpointName _loopbackEndpoint; |
| 35 | + private static readonly EndpointName LoopbackEndpoint = "loopback"; |
| 36 | + private static readonly Uri LoopbackUri = new Uri("urn:localhost/loopback"); |
34 | 37 |
|
35 | | - /// <summary> |
36 | | - /// The base URI of the loopback bus instance |
37 | | - /// </summary> |
38 | | - public Uri BaseUri { get; } |
| 38 | + /// <inheritdoc /> |
| 39 | + public Uri BaseUri => LoopbackUri; |
39 | 40 |
|
40 | | - /// <summary> |
41 | | - /// The message queueing service to use |
42 | | - /// </summary> |
| 41 | + /// <inheritdoc /> |
43 | 42 | public IMessageQueueingService MessageQueueingService { get; set; } |
44 | 43 |
|
| 44 | + /// <inheritdoc /> |
| 45 | + /// <summary> |
| 46 | + /// Initializes a new <see cref="T:Platibus.Config.LoopbackConfiguration" /> |
| 47 | + /// </summary> |
| 48 | + public LoopbackConfiguration() : this(null) |
| 49 | + { |
| 50 | + } |
45 | 51 |
|
| 52 | + /// <inheritdoc /> |
46 | 53 | /// <summary> |
47 | | - /// Initializes a new <see cref="LoopbackConfiguration"/> with a preconfigured |
48 | | - /// <paramref name="diagnosticService"/> |
| 54 | + /// Initializes a new <see cref="T:Platibus.Config.LoopbackConfiguration" /> with a preconfigured |
| 55 | + /// <paramref name="diagnosticService" /> |
49 | 56 | /// </summary> |
50 | 57 | /// <param name="diagnosticService">(Optional) The service through which diagnostic events |
51 | 58 | /// are reported and processed</param> |
52 | | - public LoopbackConfiguration(IDiagnosticService diagnosticService = null) : base(diagnosticService) |
| 59 | + public LoopbackConfiguration(IDiagnosticService diagnosticService) : base(diagnosticService, new LoopbackEndpoints(LoopbackEndpoint, LoopbackUri)) |
53 | 60 | { |
54 | | - _loopbackEndpoint = new EndpointName("looback"); |
55 | | - BaseUri = new Uri("urn:localhost/loopback"); |
56 | | - base.AddEndpoint(_loopbackEndpoint, new Endpoint(BaseUri)); |
57 | 61 | var allMessages = new MessageNamePatternSpecification(".*"); |
58 | | - base.AddSendRule(new SendRule(allMessages, _loopbackEndpoint)); |
| 62 | + base.AddSendRule(new SendRule(allMessages, LoopbackEndpoint)); |
59 | 63 | } |
60 | | - |
61 | | - /// <summary> |
62 | | - /// Adds a topic to the configuration |
63 | | - /// </summary> |
64 | | - /// <param name="topic">The name of the topic</param> |
65 | | - /// <remarks> |
66 | | - /// Topics must be explicitly added in order to publish messages to them |
67 | | - /// </remarks> |
| 64 | + |
| 65 | + /// <inheritdoc /> |
68 | 66 | public override void AddTopic(TopicName topic) |
69 | 67 | { |
70 | 68 | base.AddTopic(topic); |
71 | | - base.AddSubscription(new Subscription(_loopbackEndpoint, topic)); |
72 | | - } |
73 | | - |
74 | | - /// <summary> |
75 | | - /// Adds a named endpoint to the configuration |
76 | | - /// </summary> |
77 | | - /// <param name="name">The name of the endpoint</param> |
78 | | - /// <param name="endpoint">The endpoint</param> |
79 | | - /// <remarks> |
80 | | - /// Not supported in loopback configurations |
81 | | - /// </remarks> |
82 | | - /// <exception cref="NotSupportedException">Always thrown</exception> |
83 | | - public override void AddEndpoint(EndpointName name, IEndpoint endpoint) |
84 | | - { |
85 | | - throw new NotSupportedException(); |
86 | | - } |
87 | | - |
88 | | - /// <summary> |
89 | | - /// Adds a rule governing to which endpoints messages will be sent |
90 | | - /// </summary> |
91 | | - /// <param name="sendRule">The send rule</param> |
92 | | - /// <remarks> |
93 | | - /// Not supported in loopback configurations |
94 | | - /// </remarks> |
95 | | - /// <exception cref="NotSupportedException">Always thrown</exception> |
96 | | - public override void AddSendRule(ISendRule sendRule) |
97 | | - { |
98 | | - throw new NotSupportedException(); |
99 | | - } |
100 | | - |
101 | | - /// <summary> |
102 | | - /// Adds a subscription to a local or remote topic |
103 | | - /// </summary> |
104 | | - /// <param name="subscription">The subscription</param> |
105 | | - /// <remarks> |
106 | | - /// Not supported in loopback configurations |
107 | | - /// </remarks> |
108 | | - /// <exception cref="NotSupportedException">Always thrown</exception> |
109 | | - public override void AddSubscription(ISubscription subscription) |
110 | | - { |
111 | | - throw new NotSupportedException(); |
| 69 | + AddSubscription(new Subscription(LoopbackEndpoint, topic)); |
112 | 70 | } |
113 | 71 | } |
114 | 72 | } |
0 commit comments