private void WriteEndpointObject(IotHubDescription iotHubDescription, PSEndpointType psEndpointType, string endpointName) { switch (psEndpointType) { case PSEndpointType.EventHub: if (string.IsNullOrEmpty(endpointName)) { if (iotHubDescription.Properties.Routing.Endpoints.EventHubs.Count == 1) { this.WriteObject(IotHubUtils.ToPSRoutingEventHubEndpoint(iotHubDescription.Properties.Routing.Endpoints.EventHubs[0]), false); } else { this.WriteObject(IotHubUtils.ToPSRoutingEventHubProperties(iotHubDescription.Properties.Routing.Endpoints.EventHubs), true); } } else { this.WriteObject(IotHubUtils.ToPSRoutingEventHubEndpoint(iotHubDescription.Properties.Routing.Endpoints.EventHubs.FirstOrDefault(x => x.Name.Equals(endpointName, StringComparison.OrdinalIgnoreCase))), false); } break; case PSEndpointType.ServiceBusQueue: if (string.IsNullOrEmpty(endpointName)) { if (iotHubDescription.Properties.Routing.Endpoints.ServiceBusQueues.Count == 1) { this.WriteObject(IotHubUtils.ToPSRoutingServiceBusQueueEndpoint(iotHubDescription.Properties.Routing.Endpoints.ServiceBusQueues[0]), false); } else { this.WriteObject(IotHubUtils.ToPSRoutingServiceBusQueueEndpointProperties(iotHubDescription.Properties.Routing.Endpoints.ServiceBusQueues), true); } } else { this.WriteObject(IotHubUtils.ToPSRoutingServiceBusQueueEndpoint(iotHubDescription.Properties.Routing.Endpoints.ServiceBusQueues.FirstOrDefault(x => x.Name.Equals(endpointName, StringComparison.OrdinalIgnoreCase))), false); } break; case PSEndpointType.ServiceBusTopic: if (string.IsNullOrEmpty(endpointName)) { if (iotHubDescription.Properties.Routing.Endpoints.ServiceBusTopics.Count == 1) { this.WriteObject(IotHubUtils.ToPSRoutingServiceBusTopicEndpoint(iotHubDescription.Properties.Routing.Endpoints.ServiceBusTopics[0]), false); } else { this.WriteObject(IotHubUtils.ToPSRoutingServiceBusTopicEndpointProperties(iotHubDescription.Properties.Routing.Endpoints.ServiceBusTopics), true); } } else { this.WriteObject(IotHubUtils.ToPSRoutingServiceBusTopicEndpoint(iotHubDescription.Properties.Routing.Endpoints.ServiceBusTopics.FirstOrDefault(x => x.Name.Equals(endpointName, StringComparison.OrdinalIgnoreCase))), false); } break; case PSEndpointType.AzureStorageContainer: if (string.IsNullOrEmpty(endpointName)) { if (iotHubDescription.Properties.Routing.Endpoints.StorageContainers.Count == 1) { this.WriteObject(IotHubUtils.ToPSRoutingStorageContainerEndpoint(iotHubDescription.Properties.Routing.Endpoints.StorageContainers[0]), false); } else { this.WriteObject(IotHubUtils.ToPSRoutingStorageContainerProperties(iotHubDescription.Properties.Routing.Endpoints.StorageContainers), true); } } else { this.WriteObject(IotHubUtils.ToPSRoutingStorageContainerEndpoint(iotHubDescription.Properties.Routing.Endpoints.StorageContainers.FirstOrDefault(x => x.Name.Equals(endpointName, StringComparison.OrdinalIgnoreCase))), false); } break; } }