Ejemplo n.º 1
0
        protected byte[] CreateErrorContent(XcapErrors error, string phrase)
        {
            using (var memoryStream = new MemoryStream(2048))
                using (var writer = XmlWriter.Create(memoryStream, new XmlWriterSettings()
                {
                    Indent = true, Encoding = new UTF8Encoding(false),
                }))
                {
                    writer.WriteStartElement("xcap-error", "urn:ietf:params:xml:ns:xcap-error");

                    writer.WriteStartElement(error.Convert());
                    if (string.IsNullOrEmpty(phrase) == false)
                    {
                        writer.WriteAttributeString("phrase", phrase);
                    }
                    writer.WriteEndElement();

                    writer.WriteEndElement();

                    writer.Flush();

                    var result = Encoding.UTF8.GetString(memoryStream.ToArray());

                    return(memoryStream.ToArray());
                }
        }
Ejemplo n.º 2
0
		protected byte[] CreateErrorContent(XcapErrors error, string phrase)
		{
			using (var memoryStream = new MemoryStream(2048))
			using (var writer = XmlWriter.Create(memoryStream, new XmlWriterSettings() { Indent = true, Encoding = new UTF8Encoding(false), }))
			{
				writer.WriteStartElement("xcap-error", "urn:ietf:params:xml:ns:xcap-error");

				writer.WriteStartElement(error.Convert());
				if (string.IsNullOrEmpty(phrase) == false)
					writer.WriteAttributeString("phrase", phrase);
				writer.WriteEndElement();

				writer.WriteEndElement();

				writer.Flush();

				var result = Encoding.UTF8.GetString(memoryStream.ToArray());

				return memoryStream.ToArray();
			}
		}
Ejemplo n.º 3
0
 protected HttpMessageWriter CreateErrorResponse(XcapErrors error, string phrase)
 {
     return(CreateResponse(StatusCodes.Conflict, ContentType.ApplicationXcapErrorXml, CreateErrorContent(XcapErrors.CannotInsert, phrase)));
 }
Ejemplo n.º 4
0
		protected HttpMessageWriter CreateErrorResponse(XcapErrors error, string phrase)
		{
			return CreateResponse(StatusCodes.Conflict, ContentType.ApplicationXcapErrorXml, CreateErrorContent(XcapErrors.CannotInsert, phrase));
		}
Ejemplo n.º 5
0
 public static string Convert(this XcapErrors error)
 {
     return(values[(int)error]);
 }