当前位置: 首页>>代码示例>>C#>>正文


C# PropertyList.Value方法代码示例

本文整理汇总了C#中PropertyList.Value方法的典型用法代码示例。如果您正苦于以下问题:C# PropertyList.Value方法的具体用法?C# PropertyList.Value怎么用?C# PropertyList.Value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PropertyList的用法示例。


在下文中一共展示了PropertyList.Value方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LoadiTunesDataFile

    // parse the iTunes library and read the track data for a given list, returning a reference to the TrackCollection
    public bool LoadiTunesDataFile(string strDataFile, string strPlaylist, out TrackCollection tcOut)
    {
        tcOut = null;       // don't assume this was initialized

        PropertyList plistRoot = new PropertyList();
        plistRoot.ParseFile(strDataFile);

        foreach (PropertyList plistPlaylist in plistRoot.Value("Playlists"))
        {
            if (plistPlaylist.Value("Name") == strPlaylist)
            {
                tcOut = new TrackCollection()
                {
                    Name = plistPlaylist.Value("Name"),
                    PersistentKey = plistPlaylist.Value("Playlist Persistent ID"),
                };

                if (plistPlaylist.Contains("Playlist Items"))
                {
                    // itterate over all the items in the playlist and dereference the track information to get metadata on the song
                    // note - iTunes XML only contains those fields in the original file so we must handle the "optional" data...

                    foreach (PropertyList plistItem in plistPlaylist.Value("Playlist Items"))
                    {
                        PropertyList plistTrack = plistRoot.Value("Tracks").Value(string.Format("{0}", plistItem.Value("Track ID")));
                        if (plistTrack.Value("Track Type") == "File")
                        {
                            string strFile = _UriToFilePath(plistTrack.Value("Location"));
                            TrackReference tr = new TrackReference()
                            {
                                SourcePath = strFile,
                                Name = plistTrack.Value("Name"),
                                Size = plistTrack.Value("Size"),
                                Artist = plistTrack.Value("Artist", "Unknown Artist"),
                                Album = plistTrack.Value("Album", "Unknown Album"),
                                Compilation = plistTrack.Value("Compilation", false),
                                DiscNumber = plistTrack.Value("Disc Number", 1),
                                TrackNumber = plistTrack.Value("Track Number", 1),
                                Duration = plistTrack.Value("Total Time", 0),
                            };

                            tcOut.Tracks.Add(tr);
                        }
                    }
                }

                break;
            }
        }

        return (tcOut != null);
    }
开发者ID:devorchik,项目名称:plcopy,代码行数:53,代码来源:playlist.cs


注:本文中的PropertyList.Value方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。