コード例 #1
0
        private async Task <DIDLLite> BrowseFolderAsync(string id)
        {
            try
            {
                if (_browseAction != null)
                {
                    DIDLLite didllite = new DIDLLite();
                    didllite.Containers = new List <Container>();
                    didllite.Items      = new List <Item>();
                    int  start_from = 0;
                    int  limit      = 100;
                    bool found      = false;
                    do
                    {
                        _browseAction.ClearArgumentsValue();
                        _browseAction.SetArgumentValue("ObjectId", id);
                        _browseAction.SetArgumentValue("BrowseFlag", "BrowseDirectChildren");
                        _browseAction.SetArgumentValue("Filter", "*");
                        _browseAction.SetArgumentValue("StartingIndex", start_from.ToString());
                        _browseAction.SetArgumentValue("RequestedCount", limit.ToString());
                        _browseAction.SetArgumentValue("SortCriteria", "");
                        await _browseAction.InvokeAsync(ServiceTypes.CONTENTDIRECTORY, this.ContentDirectoryControlUrl.AbsoluteUri);

                        DIDLLite tmp_didllite = Deserializer.DeserializeXml <DIDLLite>(_browseAction.GetArgumentValue("Result"));
                        foreach (Container container in tmp_didllite.Containers)
                        {
                            didllite.Containers.Add(container);
                        }
                        foreach (Item item in tmp_didllite.Items)
                        {
                            didllite.Items.Add(item);
                        }
                        found       = (tmp_didllite.Containers.Count > 0 || tmp_didllite.Items.Count > 0);
                        start_from += limit;
                    }while (found);

                    return(didllite);
                }
                return(null);
            }
            catch
            {
                return(null);
            }
        }