Skip to content

Commit 7a76b1b

Browse files
committed
Change endpoints to implement IEnumerable.
1 parent 689aba3 commit 7a76b1b

File tree

3 files changed

+21
-24
lines changed

3 files changed

+21
-24
lines changed

Elastacloud.AzureManagement.Fluent/Clients/LinuxVirtualMachineClient.cs

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
1-
/*****************************************************************`*******************************************
1+
using Elastacloud.AzureManagement.Fluent.Clients.Helpers;
2+
using Elastacloud.AzureManagement.Fluent.Clients.Interfaces;
3+
using Elastacloud.AzureManagement.Fluent.Commands.Services;
4+
using Elastacloud.AzureManagement.Fluent.Commands.VirtualMachines;
5+
using Elastacloud.AzureManagement.Fluent.Commands.VirtualNetworks;
6+
using Elastacloud.AzureManagement.Fluent.Helpers;
7+
using Elastacloud.AzureManagement.Fluent.Types;
8+
using Elastacloud.AzureManagement.Fluent.Types.Exceptions;
9+
using Elastacloud.AzureManagement.Fluent.Types.VirtualMachines;
10+
using Elastacloud.AzureManagement.Fluent.Types.VirtualNetworks;
11+
using Elastacloud.AzureManagement.Fluent.VirtualMachines.Classes;
12+
/*****************************************************************`*******************************************
213
* This software is distributed under a GNU Lesser License by Elastacloud Limited and it is free to *
314
* modify and distribute providing the terms of the license are followed. From the root of the source the *
415
* license can be found in /Resources/license.txt *
@@ -9,24 +20,10 @@
920
using System;
1021
using System.Collections.Generic;
1122
using System.Diagnostics;
12-
using System.IO;
1323
using System.Linq;
14-
using System.Net;
1524
using System.Security.Cryptography.X509Certificates;
1625
using System.Threading;
1726
using System.Threading.Tasks;
18-
using Elastacloud.AzureManagement.Fluent.Clients.Helpers;
19-
using Elastacloud.AzureManagement.Fluent.Clients.Interfaces;
20-
using Elastacloud.AzureManagement.Fluent.Commands.Blobs;
21-
using Elastacloud.AzureManagement.Fluent.Commands.Services;
22-
using Elastacloud.AzureManagement.Fluent.Commands.VirtualMachines;
23-
using Elastacloud.AzureManagement.Fluent.Commands.VirtualNetworks;
24-
using Elastacloud.AzureManagement.Fluent.Helpers;
25-
using Elastacloud.AzureManagement.Fluent.Types;
26-
using Elastacloud.AzureManagement.Fluent.Types.Exceptions;
27-
using Elastacloud.AzureManagement.Fluent.Types.VirtualMachines;
28-
using Elastacloud.AzureManagement.Fluent.Types.VirtualNetworks;
29-
using Elastacloud.AzureManagement.Fluent.VirtualMachines.Classes;
3027

3128
namespace Elastacloud.AzureManagement.Fluent.Clients
3229
{
@@ -583,7 +580,7 @@ public List<VmHost> GetHostDetails(string cloudServiceName)
583580
HostName = vm.RoleName,
584581
IpAddress = vm.IPAddress,
585582
RoleName = vm.RoleName,
586-
Endpoints = vm.NetworkConfigurationSet.InputEndpoints
583+
Endpoints = vm.NetworkConfigurationSet.InputEndpoints.Endpoints.AsReadOnly()
587584
}));
588585
return hosts;
589586
}

Elastacloud.AzureManagement.Fluent/Types/Virtual Machines/InputEndpoints.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ public class InputEndpoints : ICustomXmlSerializer
2323
/// <summary>
2424
/// The local collection of InputEndpoint values
2525
/// </summary>
26-
private readonly List<InputEndpoint> _endpoints;
26+
public List<InputEndpoint> Endpoints { get; private set; }
2727

2828
/// <summary>
2929
/// Creates a new instance of the InputEndpoints collection class
3030
/// </summary>
3131
public InputEndpoints()
3232
{
33-
_endpoints = new List<InputEndpoint>();
33+
Endpoints = new List<InputEndpoint>();
3434
}
3535

3636
/// <summary>
@@ -41,22 +41,22 @@ public void AddEndpoint(InputEndpoint endpoint)
4141
{
4242
// check to see whether the endpoint exists or not
4343
IEnumerable<InputEndpoint> endpoints =
44-
_endpoints.Where(a => a.LocalPort == endpoint.LocalPort || (a.Port == endpoint.LocalPort && a.Port != 0)
44+
Endpoints.Where(a => a.LocalPort == endpoint.LocalPort || (a.Port == endpoint.LocalPort && a.Port != 0)
4545
|| a.EndpointName == endpoint.EndpointName);
4646
if (endpoints.Any())
4747
throw new ApplicationException(
4848
"An endpoint containing the Local/Remote port and/or endpoint name already exists");
4949
// continue if it doesn't
50-
_endpoints.Add(endpoint);
50+
Endpoints.Add(endpoint);
5151
}
5252

5353
public InputEndpoint this[int index]
5454
{
5555
get
5656
{
57-
if(index < 0 || index >= _endpoints.Count)
57+
if(index < 0 || index >= Endpoints.Count)
5858
throw new ArgumentOutOfRangeException("endpoint index out of range");
59-
return _endpoints[index];
59+
return Endpoints[index];
6060
}
6161
}
6262

@@ -70,7 +70,7 @@ public XElement GetXmlTree()
7070
{
7171
var inputEndpoints = new XElement(Namespaces.NsWindowsAzure + "InputEndpoints");
7272
// iterate through all of the various input endpoints and
73-
foreach (InputEndpoint inputEndpoint in _endpoints)
73+
foreach (InputEndpoint inputEndpoint in Endpoints)
7474
{
7575
inputEndpoints.Add(inputEndpoint.GetXmlTree());
7676
}

Elastacloud.AzureManagement.Fluent/Types/Virtual Machines/VmHost.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ public class VmHost
2626
/// <summary>
2727
/// The internal endpoints referenced by this virtual machine
2828
/// </summary>
29-
public InputEndpoints Endpoints { get; internal set; }
29+
public IEnumerable<InputEndpoint> Endpoints { get; internal set; }
3030
}
3131
}

0 commit comments

Comments
 (0)