private static async Task <NamespaceProperties> ParseFromEntryElementAsync(XElement xEntry, Response response, ClientDiagnostics diagnostics)
        {
            var nsInfo = new NamespaceProperties();

            var nsInfoXml = xEntry.Element(XName.Get("content", AdministrationClientConstants.AtomNamespace))?
                            .Element(XName.Get("NamespaceInfo", AdministrationClientConstants.ServiceBusNamespace));

            if (nsInfoXml == null)
            {
                throw new ServiceBusException(
                          false,
                          "Unknown error.",
                          innerException: await diagnostics.CreateRequestFailedExceptionAsync(response).ConfigureAwait(false));
            }

            foreach (var element in nsInfoXml.Elements())
            {
                switch (element.Name.LocalName)
                {
                case "CreatedTime":
                    nsInfo.CreatedTime = DateTimeOffset.Parse(element.Value, CultureInfo.InvariantCulture);
                    break;

                case "ModifiedTime":
                    nsInfo.ModifiedTime = DateTimeOffset.Parse(element.Value, CultureInfo.InvariantCulture);
                    break;

                case "Name":
                    nsInfo.Name = element.Value;
                    break;

                case "Alias":
                    nsInfo.Alias = element.Value;
                    break;

                case "MessagingUnits":
                    _ = int.TryParse(element.Value, out var units);
                    nsInfo.MessagingUnits = units;
                    break;

                case "NamespaceType":
                    nsInfo.NamespaceType = element.Value;
                    break;

                case "MessagingSKU":
                    nsInfo.MessagingSku = element.Value;
                    break;
                }
            }

            return(nsInfo);
        }
Example #2
0
        private static NamespaceProperties ParseFromEntryElement(XElement xEntry)
        {
            var nsInfo = new NamespaceProperties();

            var nsInfoXml = xEntry.Element(XName.Get("content", AdministrationClientConstants.AtomNamespace))?
                            .Element(XName.Get("NamespaceInfo", AdministrationClientConstants.ServiceBusNamespace));

            if (nsInfoXml == null)
            {
                throw new ServiceBusException(true, "Unknown error.");
            }

            foreach (var element in nsInfoXml.Elements())
            {
                switch (element.Name.LocalName)
                {
                case "CreatedTime":
                    nsInfo.CreatedTime = DateTimeOffset.Parse(element.Value, CultureInfo.InvariantCulture);
                    break;

                case "ModifiedTime":
                    nsInfo.ModifiedTime = DateTimeOffset.Parse(element.Value, CultureInfo.InvariantCulture);
                    break;

                case "Name":
                    nsInfo.Name = element.Value;
                    break;

                case "Alias":
                    nsInfo.Alias = element.Value;
                    break;

                case "MessagingUnits":
                    _ = int.TryParse(element.Value, out var units);
                    nsInfo.MessagingUnits = units;
                    break;

                case "NamespaceType":
                    nsInfo.NamespaceType = element.Value;
                    break;

                case "MessagingSKU":
                    nsInfo.MessagingSku = element.Value;
                    break;
                }
            }

            return(nsInfo);
        }