Beispiel #1
0
 protected override void AppendSpecificMessage(StringBuilder builder)
 {
     builder.Append("<ObjectID>").Append(ObjectID).Append("</ObjectID>").Append("\r\n")
     .Append("<BrowseFlag>").Append(BrowseFlag.ToString()).Append("</BrowseFlag>").Append("\r\n")
     .Append("<Filter>").Append(Filter).Append("</Filter>").Append("\r\n")
     .Append("<StartingIndex>").Append(StartingIndex).Append("</StartingIndex>").Append("\r\n")
     .Append("<RequestedCount>").Append(RequestedCount).Append("</RequestedCount>").Append("\r\n")
     .Append("<SortCriteria>").Append(SortCriteria).Append("</SortCriteria>").Append("\r\n");
 }
 public string Browse (string objectId, BrowseFlag browseFlag, string filter, uint startingIndex, uint requestedCount, string sortCriteria, out uint numberReturned, out uint totalMatches, out uint updateId)
 {
     if (browseFlag < BrowseFlag.BrowseMetadata || browseFlag > BrowseFlag.BrowseDirectChildren)
         throw new ArgumentOutOfRangeException ("browseFlag");
     
     var in_arguments = new Arguments (
         "ObjectID", objectId,
         "BrowseFlag", browseFlag.ToString (),
         "Filter", filter,
         "StartingIndex", startingIndex.ToString (),
         "RequestedCount", requestedCount.ToString (),
         "SortCriteria", sortCriteria);
     var action_result = controller.Actions["Browse"].Invoke (in_arguments, 2);
     numberReturned = uint.Parse (action_result["NumberReturned"]);
     totalMatches = uint.Parse (action_result["TotalMatches"]);
     updateId = uint.Parse (action_result["UpdateID"]);
     return action_result["Result"];
 }
Beispiel #3
0
        public string Browse(string objectId, BrowseFlag browseFlag, string filter, uint startingIndex, uint requestedCount, string sortCriteria, out uint numberReturned, out uint totalMatches, out uint updateId)
        {
            if (browseFlag < BrowseFlag.BrowseMetadata || browseFlag > BrowseFlag.BrowseDirectChildren)
            {
                throw new ArgumentOutOfRangeException("browseFlag");
            }

            var in_arguments = new Arguments(
                "ObjectID", objectId,
                "BrowseFlag", browseFlag.ToString(),
                "Filter", filter,
                "StartingIndex", startingIndex.ToString(),
                "RequestedCount", requestedCount.ToString(),
                "SortCriteria", sortCriteria);
            var action_result = controller.Actions["Browse"].Invoke(in_arguments, 2);

            numberReturned = uint.Parse(action_result["NumberReturned"]);
            totalMatches   = uint.Parse(action_result["TotalMatches"]);
            updateId       = uint.Parse(action_result["UpdateID"]);
            return(action_result["Result"]);
        }
Beispiel #4
0
        private async Task <string> BuildXmlAsync()
        {
            var browseActionXml =
                new XDocument(
                    new XDeclaration("1.0", "utf-8", "yes"),
                    new XElement(envelopeNs + "Envelope",
                                 new XAttribute(XNamespace.Xmlns + "s", envelopeNs),
                                 new XElement(envelopeNs + "Body",
                                              new XElement(upnpNs + "Browse",
                                                           new XAttribute(XNamespace.Xmlns + "u", upnpNs),
                                                           new XElement("ObjectID", new XText(ObjectId)),
                                                           new XElement("BrowseFlag", new XText(BrowseFlag.ToString())),
                                                           new XElement("Filter", new XText(Filter.ToString())),
                                                           new XElement("StartingIndex", new XText(StartingIndex.ToString())),
                                                           new XElement("RequestedCount", new XText(RequestedCount.ToString())),
                                                           new XElement("SortCriteria", new XText(""))))));

            using (var memory = new MemoryStream())
            {
                using (var writer = XmlWriter.Create(memory, new XmlWriterSettings()
                {
                    Indent = true, Encoding = Encoding.UTF8
                }))
                {
                    browseActionXml.WriteTo(writer);
                    writer.Flush();
                }

                memory.Flush();
                memory.Seek(0, SeekOrigin.Begin);

                using (var reader = new StreamReader(memory))
                {
                    return(await reader.ReadToEndAsync());
                }
            }
        }