-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathBindingsCollection.cs
More file actions
111 lines (97 loc) · 3.3 KB
/
Copy pathBindingsCollection.cs
File metadata and controls
111 lines (97 loc) · 3.3 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// Copyright (c) The LEGO Group. All rights reserved.
namespace LEGO.AsyncAPI.Bindings
{
using System;
using System.Collections.Generic;
using LEGO.AsyncAPI.Bindings.AMQP;
using LEGO.AsyncAPI.Bindings.Http;
using LEGO.AsyncAPI.Bindings.Kafka;
using LEGO.AsyncAPI.Bindings.MQTT;
using LEGO.AsyncAPI.Bindings.Pulsar;
using LEGO.AsyncAPI.Bindings.Sns;
using LEGO.AsyncAPI.Bindings.Sqs;
using LEGO.AsyncAPI.Bindings.WebSockets;
using LEGO.AsyncAPI.Models.Interfaces;
using LEGO.AsyncAPI.Readers.Interface;
public static class BindingsCollection
{
public static TCollection Add<TCollection, TItem>(
this TCollection destination,
IEnumerable<TItem> source)
where TCollection : ICollection<TItem>
{
if (destination == null)
{
throw new ArgumentNullException(nameof(destination));
}
if (source == null)
{
throw new ArgumentNullException(nameof(source));
}
if (destination is List<TItem> list)
{
list.AddRange(source);
return destination;
}
foreach (var item in source)
{
destination.Add(item);
}
return destination;
}
public static ICollection<IBindingParser<IBinding>> All => new List<IBindingParser<IBinding>>
{
Pulsar,
Kafka,
Http,
Websockets,
Sqs,
Sns,
AMQP,
MQTT,
};
public static ICollection<IBindingParser<IBinding>> Http => new List<IBindingParser<IBinding>>
{
new HttpOperationBinding(),
new HttpMessageBinding(),
};
public static ICollection<IBindingParser<IBinding>> Websockets => new List<IBindingParser<IBinding>>
{
new WebSocketsChannelBinding(),
};
public static ICollection<IBindingParser<IBinding>> Kafka => new List<IBindingParser<IBinding>>
{
new KafkaServerBinding(),
new KafkaChannelBinding(),
new KafkaOperationBinding(),
new KafkaMessageBinding(),
};
public static ICollection<IBindingParser<IBinding>> Pulsar => new List<IBindingParser<IBinding>>
{
new PulsarServerBinding(),
new PulsarChannelBinding(),
};
public static ICollection<IBindingParser<IBinding>> Sqs => new List<IBindingParser<IBinding>>
{
new SqsChannelBinding(),
new SqsOperationBinding(),
};
public static ICollection<IBindingParser<IBinding>> Sns => new List<IBindingParser<IBinding>>
{
new SnsChannelBinding(),
new SnsOperationBinding(),
};
public static ICollection<IBindingParser<IBinding>> AMQP => new List<IBindingParser<IBinding>>
{
new AMQPChannelBinding(),
new AMQPOperationBinding(),
new AMQPMessageBinding(),
};
public static ICollection<IBindingParser<IBinding>> MQTT => new List<IBindingParser<IBinding>>
{
new MQTTServerBinding(),
new MQTTOperationBinding(),
new MQTTMessageBinding(),
};
}
}