Skip to content

Commit a2416b9

Browse files
committed
Removed GetType from Set functions
1 parent 9f8686f commit a2416b9

File tree

2 files changed

+3
-24
lines changed

2 files changed

+3
-24
lines changed

src/Peering/Peering/Direct/SetAzureDirectPeeringConnectionCommand.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -176,15 +176,12 @@ public override void Execute()
176176
/// </returns>
177177
private PSDirectConnection UpdatePeeringOffer()
178178
{
179-
if (this.InputObject.GetType().Equals(typeof(PSDirectConnection)))
180-
{
181179
this.InputObject.BandwidthInMbps =
182180
this.ValidUpgradeBandwidth(this.InputObject.BandwidthInMbps, this.BandwidthInMbps)
183181
? this.BandwidthInMbps
184182
: this.InputObject.BandwidthInMbps;
185183
if (this.IsValidConnection(this.InputObject))
186184
return this.InputObject;
187-
}
188185

189186
throw new InvalidOperationException(string.Format(Resources.Error_WrongCommandForDirectObject));
190187
}
@@ -197,12 +194,9 @@ private PSDirectConnection UpdatePeeringOffer()
197194
/// </returns>
198195
private PSDirectConnection UpdateMD5Authentication()
199196
{
200-
if (this.InputObject.GetType().Equals(typeof(PSDirectConnection)))
201-
{
202197
this.InputObject.BgpSession.Md5AuthenticationKey = this.MD5AuthenticationKey;
203198
if (this.IsValidConnection(this.InputObject))
204199
return this.InputObject;
205-
}
206200

207201
throw new InvalidOperationException(string.Format(Resources.Error_WrongCommandForDirectObject));
208202
}
@@ -215,14 +209,11 @@ private PSDirectConnection UpdateMD5Authentication()
215209
/// </returns>
216210
private PSDirectConnection UpdateIpV4Prefix()
217211
{
218-
if (this.InputObject.GetType().Equals(typeof(PSDirectConnection)))
219-
{
220212
this.InputObject.BgpSession.MaxPrefixesAdvertisedV4 =
221213
this.MaxPrefixesAdvertisedIPv4 == null ? this.InputObject.BgpSession.MaxPrefixesAdvertisedV4 : 20000;
222214
this.InputObject.BgpSession.SessionPrefixV4 = this.ValidatePrefix(this.SessionPrefixV4, Constants.Direct);
223215
if (this.IsValidConnection(this.InputObject))
224216
return this.InputObject;
225-
}
226217

227218
throw new InvalidOperationException(string.Format(Resources.Error_WrongCommandForDirectObject));
228219
}
@@ -235,14 +226,11 @@ private PSDirectConnection UpdateIpV4Prefix()
235226
/// </returns>
236227
private PSDirectConnection UpdateIpV6Prefix()
237228
{
238-
if (this.InputObject.GetType().Equals(typeof(PSDirectConnection)))
239-
{
240229
this.InputObject.BgpSession.MaxPrefixesAdvertisedV6 =
241230
this.MaxPrefixesAdvertisedIPv6 == null ? this.InputObject.BgpSession.MaxPrefixesAdvertisedV6 : 2000;
242231
this.InputObject.BgpSession.SessionPrefixV6 = this.ValidatePrefix(this.SessionPrefixV6, Constants.Direct);
243232
if (this.IsValidConnection(this.InputObject))
244233
return this.InputObject;
245-
}
246234

247235
throw new InvalidOperationException(string.Format(Resources.Error_WrongCommandForDirectObject));
248236
}

src/Peering/Peering/Exchange/SetAzureExchangePeeringConnectionCommand.cs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,9 @@ public override void Execute()
153153
/// </returns>
154154
private PSExchangeConnection UpdateMD5Authentication()
155155
{
156-
if (this.InputObject is PSExchangeConnection inputObject)
157-
{
158-
inputObject.BgpSession.Md5AuthenticationKey = this.MD5AuthenticationKey;
159-
if (this.IsValidConnection(inputObject))
160-
return inputObject;
161-
}
156+
this.InputObject.BgpSession.Md5AuthenticationKey = this.MD5AuthenticationKey;
157+
if (this.IsValidConnection(this.InputObject))
158+
return this.InputObject;
162159

163160
throw new InvalidOperationException(string.Format(Resources.Error_InvalidInputObject_Exchange));
164161
}
@@ -171,14 +168,11 @@ private PSExchangeConnection UpdateMD5Authentication()
171168
/// </returns>
172169
private PSExchangeConnection UpdateIpV4Prefix()
173170
{
174-
if (this.InputObject.GetType().Equals(typeof(PSExchangeConnection)))
175-
{
176171
this.InputObject.BgpSession.MaxPrefixesAdvertisedV4 =
177172
this.MaxPrefixesAdvertisedIPv4 == null ? (this.InputObject.BgpSession.MaxPrefixesAdvertisedV4 != 0 ? this.InputObject.BgpSession.MaxPrefixesAdvertisedV4 : 2000) : 2000;
178173
this.InputObject.BgpSession.PeerSessionIPv6Address = this.ValidatePrefix(this.PeerSessionIPv4Address, Constants.Exchange);
179174
if (this.IsValidConnection(this.InputObject))
180175
return this.InputObject;
181-
}
182176

183177
throw new InvalidOperationException(string.Format(Resources.Error_InvalidInputObject_Exchange));
184178
}
@@ -191,14 +185,11 @@ private PSExchangeConnection UpdateIpV4Prefix()
191185
/// </returns>
192186
private PSExchangeConnection UpdateIpV6Prefix()
193187
{
194-
if (this.InputObject.GetType().Equals(typeof(PSExchangeConnection)))
195-
{
196188
this.InputObject.BgpSession.MaxPrefixesAdvertisedV6 =
197189
this.MaxPrefixesAdvertisedIPv6 == null ? (this.InputObject.BgpSession.MaxPrefixesAdvertisedV6 != 0 ? this.InputObject.BgpSession.MaxPrefixesAdvertisedV6 : 2000) : 2000;
198190
this.InputObject.BgpSession.PeerSessionIPv6Address = this.ValidatePrefix(this.PeerSessionIPv6Address, Constants.Exchange);
199191
if (this.IsValidConnection(this.InputObject))
200192
return this.InputObject;
201-
}
202193

203194
throw new InvalidOperationException(string.Format(Resources.Error_InvalidInputObject_Exchange));
204195
}

0 commit comments

Comments
 (0)