/// <summary>Creates a new queue in the service namespace with the specified queue description.</summary> /// <param name="description">A /// <see cref="T:Microsoft.ServiceBus.Messaging.QueueDescription" /> object describing the attributes with which the new queue will be created.</param> /// <returns>The <see cref="T:Microsoft.ServiceBus.Messaging.QueueDescription" /> of the newly created queue.</returns> public QueueDescription CreateQueue(QueueDescription description) { CheckNameLength(description.Path, MAXPATHLENGTH, "description.Path"); string queueName = description.Path; string address, saddress; GetAddressesNeeded(queueName, out address, out saddress); entry creationEntry = entry.Build(endpointAddresses.First(), queueName, saddress); creationEntry.content.QueueDescription = description.xml; var content = Create(creationEntry.ToXml(), address, saddress); var queueDesc = new QueueDescription(description.Path, content?.QueueDescription); if (null != queueDesc.xml) { queueDesc.xml.ResetSerialization(); queueDesc.xml.Path = queueName; } return(queueDesc); }
/// <summary>Creates a new topic inside the service namespace with the specified topic description.</summary> /// <param name="topicDescription">A /// <see cref="T:Microsoft.ServiceBus.Messaging.TopicDescription" /> object describing the attributes with which the new topic will be created.</param> /// <returns>The <see cref="T:Microsoft.ServiceBus.Messaging.TopicDescription" /> of the newly created topic.</returns> public TopicDescription CreateTopic(TopicDescription topicDescription) { CheckNameLength(topicDescription.Path, MAXPATHLENGTH, "description.Path"); string topicName = topicDescription.Path; string address, saddress; GetAddressesNeeded(topicName, out address, out saddress); entry creationEntry = entry.Build(endpointAddresses.First(), topicName, saddress); creationEntry.content.TopicDescription = topicDescription.xml; var content = Create(creationEntry.ToXml(), address, saddress); var topicDesc = new TopicDescription(topicDescription.Path, content?.TopicDescription); if (null != topicDesc.xml) { topicDesc.xml.ResetSerialization(); topicDesc.xml.Path = topicName; } return(topicDesc); }
public SubscriptionDescription CreateSubscription(SubscriptionDescription description) { CheckNameLength(description.TopicPath, MAXPATHLENGTH, "description.Path"); CheckNameLength(description.Name, MAXNAMELENGTH, "description.Name"); string address, saddress; GetAddressesNeeded(description.TopicPath, description.Name, out address, out saddress); entry creationEntry = entry.Build(endpointAddresses.First(), description.Name, saddress); creationEntry.content.SubscriptionDescription = description.xml; string xml = creationEntry.ToXml(); var content = Create(xml, address, saddress); var subDesc = new SubscriptionDescription(description.TopicPath, description.Name, content?.SubscriptionDescription); if (null != subDesc.xml) { subDesc.xml.ResetSerialization(); subDesc.xml.TopicPath = description.TopicPath; subDesc.xml.Name = description.Name; } return(subDesc); }
internal static entry Build(Uri endpoint, string path, string saddress) { entry toXml = new entry(); toXml.id = "uuid:e" + Guid.NewGuid().ToString() + ";id=1"; toXml.author = new entryAuthor(); toXml.author.name = endpoint.Host.Split('.').First(); toXml.title = new entryTitle() { type = "text", Value = path }; toXml.updated = DateTime.UtcNow; if (!String.IsNullOrEmpty(saddress)) { toXml.link = new entryLink() { rel = "self", href = saddress } } ; toXml.content = new entryContent(); return(toXml); }
/// <summary>Enables you to update the queue.</summary> /// <param name="description">A <see cref="T:Microsoft.ServiceBus.Messaging.QueueDescription" /> object describing the queue to be updated.</param> /// <returns>The <see cref="T:Microsoft.ServiceBus.Messaging.QueueDescription" /> of the updated queue.</returns> public TopicDescription UpdateTopic(TopicDescription description) { if (String.IsNullOrWhiteSpace(description.Path)) { throw new NullReferenceException("Topic Path was null or empty"); } CheckNameLength(description.Path, MAXPATHLENGTH, "description.Path"); string address, saddress; GetAddressesNeeded(description.Path, out address, out saddress, true); entry toXml = entry.Build(endpointAddresses.First(), description.Path, saddress); toXml.content.TopicDescription = description.xml; using (System.Net.WebClient request = new WebClient()) { request.AddCommmonHeaders(provider, address, true, true, true); var t = request.UploadEntryXml(saddress, toXml); return(new TopicDescription(description.Path, t?.content?.TopicDescription)); } }
public static entry UploadEntryXml(this WebClient request, string saddress, entry XmlPayload) { return(request.UploadEntryXml(saddress, XmlPayload.ToXml())); }