in sdk/servicebus/Azure.Messaging.ServiceBus/src/Administration/TopicPropertiesExtensions.cs [74:172]
private static TopicProperties ParseFromEntryElement(XElement xEntry, Response response)
{
var name = xEntry.Element(XName.Get("title", AdministrationClientConstants.AtomNamespace)).Value;
var topicXml = xEntry.Element(XName.Get("content", AdministrationClientConstants.AtomNamespace))?
.Element(XName.Get("TopicDescription", AdministrationClientConstants.ServiceBusNamespace));
if (topicXml == null)
{
throw new ServiceBusException(
"Topic was not found",
ServiceBusFailureReason.MessagingEntityNotFound,
innerException: new RequestFailedException(response));
}
var topicProperties = new TopicProperties(name);
foreach (var element in topicXml.Elements())
{
switch (element.Name.LocalName)
{
case "DefaultMessageTimeToLive":
topicProperties.DefaultMessageTimeToLive = XmlConvert.ToTimeSpan(element.Value);
break;
case "MaxSizeInMegabytes":
topicProperties.MaxSizeInMegabytes = long.Parse(element.Value, CultureInfo.InvariantCulture);
break;
case "RequiresDuplicateDetection":
topicProperties.RequiresDuplicateDetection = bool.Parse(element.Value);
break;
case "DuplicateDetectionHistoryTimeWindow":
topicProperties.DuplicateDetectionHistoryTimeWindow = XmlConvert.ToTimeSpan(element.Value);
break;
case "EnableBatchedOperations":
topicProperties.EnableBatchedOperations = bool.Parse(element.Value);
break;
case "FilteringMessagesBeforePublishing":
topicProperties.FilteringMessagesBeforePublishing = bool.Parse(element.Value);
break;
case "IsAnonymousAccessible":
topicProperties.IsAnonymousAccessible = bool.Parse(element.Value);
break;
case "AuthorizationRules":
topicProperties.AuthorizationRules = AuthorizationRules.ParseFromXElement(element);
break;
case "Status":
topicProperties.Status = element.Value;
break;
case "ForwardTo":
if (!string.IsNullOrWhiteSpace(element.Value))
{
topicProperties.ForwardTo = element.Value;
}
break;
case "UserMetadata":
topicProperties.UserMetadata = element.Value;
break;
case "SupportOrdering":
topicProperties.SupportOrdering = bool.Parse(element.Value);
break;
case "AutoDeleteOnIdle":
topicProperties.AutoDeleteOnIdle = XmlConvert.ToTimeSpan(element.Value);
break;
case "EnablePartitioning":
topicProperties.EnablePartitioning = bool.Parse(element.Value);
break;
case "EnableSubscriptionPartitioning":
topicProperties.EnableSubscriptionPartitioning = bool.Parse(element.Value);
break;
case "EnableExpress":
topicProperties.EnableExpress = bool.Parse(element.Value);
break;
case "MaxMessageSizeInKilobytes":
topicProperties.MaxMessageSizeInKilobytes = long.Parse(element.Value, CultureInfo.InvariantCulture);
break;
case "AccessedAt":
case "CreatedAt":
case "MessageCount":
case "SizeInBytes":
case "UpdatedAt":
case "CountDetails":
case "SubscriptionCount":
case "EntityAvailabilityStatus":
case "SkippedUpdate":
// Ignore known properties
// Do nothing
break;
default:
// For unknown properties, keep them as-is for forward proof.
if (topicProperties.UnknownProperties == null)
{
topicProperties.UnknownProperties = new List<XElement>();
}
topicProperties.UnknownProperties.Add(element);
break;
}
}
return topicProperties;
}