Skip to content

Commit aa4cb95

Browse files
Make protocol version non-configurable
1 parent 0a737ae commit aa4cb95

File tree

1 file changed

+1
-143
lines changed

1 file changed

+1
-143
lines changed

projects/client/RabbitMQ.Client/src/client/api/Protocols.cs

Lines changed: 1 addition & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -44,34 +44,13 @@
4444

4545
namespace RabbitMQ.Client
4646
{
47-
///<summary>Concrete, predefined IProtocol instances ready for use
48-
///with ConnectionFactory.</summary>
49-
///<remarks>
50-
///<para>
51-
/// Applications will in the common case use the FromEnvironment()
52-
/// method to search a fallback-chain of configuration sources for
53-
/// the IProtocol instance to use. However, in some cases, the
54-
/// default fallback-chain is not appropriate; in these cases,
55-
/// other methods such as FromConfiguration(string) or
56-
/// SafeLookup(string) may suffice.
57-
///</para>
58-
///</remarks>
47+
///<summary>Provides access to the supported IProtocol implementations</summary>
5948
public class Protocols
6049
{
6150
// Hide the constructor - no instances of Protocols needed.
6251
// We'd make this class static, but for MS's .NET 1.1 compilers
6352
private Protocols() {}
6453

65-
///<summary>The default App.config appSettings key used by
66-
///FromConfiguration and FromEnvironment. At the time of
67-
///writing, "AMQP_PROTOCOL".</summary>
68-
public readonly static string DefaultAppSettingsKey = "AMQP_PROTOCOL";
69-
70-
///<summary>The environment variable read by
71-
///FromEnvironmentVariable() and FromEnvironment(). At the
72-
///time of writing, "AMQP_PROTOCOL".</summary>
73-
public readonly static string EnvironmentVariable = "AMQP_PROTOCOL";
74-
7554
///<summary>Protocol version 0-9-1 as modified by VMWare.</summary>
7655
public static IProtocol AMQP_0_9_1
7756
{
@@ -84,126 +63,5 @@ public static IProtocol DefaultProtocol
8463
{
8564
get { return AMQP_0_9_1; }
8665
}
87-
88-
///<summary>Low-level method for retrieving a protocol version
89-
///by name (of one of the static properties on this
90-
///class)</summary>
91-
///<remarks>
92-
///<para>
93-
/// Returns null if no suitable property could be found.
94-
///</para>
95-
///<para>
96-
/// In many cases, FromEnvironment() will be a more
97-
/// appropriate method for applications to call; this method
98-
/// is provided for cases where the caller wishes to know the
99-
/// answer to the question "does a suitable IProtocol property
100-
/// with this name exist, and if so, what is its value?"
101-
///</para>
102-
///</remarks>
103-
public static IProtocol Lookup(string name)
104-
{
105-
PropertyInfo pi = typeof(Protocols).GetProperty(name,
106-
BindingFlags.Public |
107-
BindingFlags.Static);
108-
if (pi == null)
109-
{
110-
return null;
111-
}
112-
return pi.GetValue(null, new object[0]) as IProtocol;
113-
}
114-
115-
///<summary>Retrieve a protocol version by name (of one of the
116-
///static properties on this class)</summary>
117-
///<remarks>
118-
///<para>
119-
/// If the argument is null, Protocols.DefaultProtocol is
120-
/// used. If the protocol variant named is not found,
121-
/// ConfigurationErrorsException is thrown.
122-
///</para>
123-
///<para>
124-
/// In many cases, FromEnvironment() will be a more
125-
/// appropriate method for applications to call; this method
126-
/// is provided for cases where the caller wishes to know the
127-
/// answer to the question "does a suitable IProtocol property
128-
/// with this name exist, and if so, what is its value?", with
129-
/// the additional guarantee that if a suitable property does
130-
/// not exist, a ConfigurationErrorsException will be thrown.
131-
///</para>
132-
///</remarks>
133-
///<exception cref="System.Configuration.ConfigurationErrorsException"/>
134-
public static IProtocol SafeLookup(string name)
135-
{
136-
if (name != null)
137-
{
138-
IProtocol p = Lookup(name);
139-
if (p != null)
140-
{
141-
return p;
142-
}
143-
else
144-
{
145-
throw new ConfigurationErrorsException("Unsupported protocol variant name: " + name);
146-
}
147-
}
148-
return DefaultProtocol;
149-
}
150-
151-
private static string ReadEnvironmentVariable()
152-
{
153-
return Environment.GetEnvironmentVariable(EnvironmentVariable);
154-
}
155-
156-
///<summary>Uses the process environment variable
157-
///<code>EnvironmentVariable</code> to retrieve an IProtocol
158-
///instance.</summary>
159-
///<remarks>
160-
///If the environment variable is unset,
161-
///Protocols.DefaultProtocol is used. If the protocol variant
162-
///named is not found, ConfigurationErrorsException is thrown.
163-
///</remarks>
164-
///<exception cref="System.Configuration.ConfigurationErrorsException"/>
165-
public static IProtocol FromEnvironmentVariable()
166-
{
167-
return SafeLookup(ReadEnvironmentVariable());
168-
}
169-
170-
///<summary>Uses App.config's appSettings section to retrieve
171-
///an IProtocol instance.</summary>
172-
///<remarks>
173-
///If the appSettings key is missing,
174-
///Protocols.DefaultProtocol is used. If the protocol variant
175-
///named is not found, ConfigurationErrorsException is thrown.
176-
///</remarks>
177-
///<exception cref="System.Configuration.ConfigurationErrorsException"/>
178-
public static IProtocol FromConfiguration(string appSettingsKey)
179-
{
180-
string name = ConfigurationManager.AppSettings[appSettingsKey];
181-
return SafeLookup(name);
182-
}
183-
184-
///<summary>Returns FromConfiguration(DefaultAppSettingsKey).</summary>
185-
public static IProtocol FromConfiguration()
186-
{
187-
return FromConfiguration(DefaultAppSettingsKey);
188-
}
189-
190-
///<summary>Tries FromConfiguration() first, followed by
191-
///FromEnvironmentVariable() if no setting was found in the
192-
///App.config.</summary>
193-
///<exception cref="System.Configuration.ConfigurationErrorsException"/>
194-
public static IProtocol FromEnvironment(string appSettingsKey)
195-
{
196-
string name = ConfigurationManager.AppSettings[appSettingsKey];
197-
if (name == null) {
198-
name = ReadEnvironmentVariable();
199-
}
200-
return SafeLookup(name);
201-
}
202-
203-
///<summary>Returns FromEnvironment(DefaultAppSettingsKey).</summary>
204-
public static IProtocol FromEnvironment()
205-
{
206-
return FromEnvironment(DefaultAppSettingsKey);
207-
}
20866
}
20967
}

0 commit comments

Comments
 (0)