| 1 | using System;
|
|---|
| 2 | using System.Collections;
|
|---|
| 3 | using System.Collections.Generic;
|
|---|
| 4 | using System.Linq;
|
|---|
| 5 | using Clovery.iTunesHelper.COMWrap.Interfaces;
|
|---|
| 6 | using iTunes = iTunesLib;
|
|---|
| 7 |
|
|---|
| 8 | namespace Clovery.iTunesHelper.COMWrap
|
|---|
| 9 | {
|
|---|
| 10 | internal class Source : ITObject, ISource
|
|---|
| 11 | {
|
|---|
| 12 | protected internal Source(iTunes.IITSource _internal, ITunesApp _app) : base(_internal, _app)
|
|---|
| 13 | {
|
|---|
| 14 | }
|
|---|
| 15 |
|
|---|
| 16 | protected internal iTunes.IITSource _asIITSource
|
|---|
| 17 | {
|
|---|
| 18 | get { return (iTunesLib.IITSource) this._internal; }
|
|---|
| 19 | }
|
|---|
| 20 |
|
|---|
| 21 | public SourceKind Kind
|
|---|
| 22 | {
|
|---|
| 23 | get { return (SourceKind) this._asIITSource.Kind; }
|
|---|
| 24 | }
|
|---|
| 25 |
|
|---|
| 26 | public double Capacity
|
|---|
| 27 | {
|
|---|
| 28 | get { return this._asIITSource.Capacity; }
|
|---|
| 29 | }
|
|---|
| 30 |
|
|---|
| 31 | public double FreeSpace
|
|---|
| 32 | {
|
|---|
| 33 | get { return this._asIITSource.FreeSpace; }
|
|---|
| 34 | }
|
|---|
| 35 |
|
|---|
| 36 | public IPlaylistCollection Playlists
|
|---|
| 37 | {
|
|---|
| 38 | get { return this._app.factory.CreatePlaylistCollection(this._asIITSource.Playlists); }
|
|---|
| 39 | }
|
|---|
| 40 |
|
|---|
| 41 | public IPlaylist CreateFolder(string folderName)
|
|---|
| 42 | {
|
|---|
| 43 | object _real = this._asIITSource;
|
|---|
| 44 | return
|
|---|
| 45 | this._app.factory.CreatePlaylist(this._app._asIiTunes.CreateFolderInSource(folderName, ref _real));
|
|---|
| 46 | }
|
|---|
| 47 |
|
|---|
| 48 | public IPlaylist CreatePlaylist(string playlistName)
|
|---|
| 49 | {
|
|---|
| 50 | object _real = this._asIITSource;
|
|---|
| 51 | return
|
|---|
| 52 | this._app.factory.CreatePlaylist(
|
|---|
| 53 | this._app._asIiTunes.CreatePlaylistInSource(playlistName, ref _real));
|
|---|
| 54 | }
|
|---|
| 55 |
|
|---|
| 56 | public IPlaylist GetOrCreatePlaylist(string playlistName)
|
|---|
| 57 | {
|
|---|
| 58 | IPlaylist playlist = this.Children[playlistName];
|
|---|
| 59 | if (playlist != null)
|
|---|
| 60 | {
|
|---|
| 61 | return playlist;
|
|---|
| 62 | }
|
|---|
| 63 | return this.CreatePlaylist(playlistName);
|
|---|
| 64 | }
|
|---|
| 65 |
|
|---|
| 66 | public IPlaylist GetOrCreateFolder(string folderName)
|
|---|
| 67 | {
|
|---|
| 68 | IPlaylist playlist = this.Children[folderName];
|
|---|
| 69 | if (playlist != null)
|
|---|
| 70 | {
|
|---|
| 71 | return playlist;
|
|---|
| 72 | }
|
|---|
| 73 | return this.CreateFolder(folderName);
|
|---|
| 74 | }
|
|---|
| 75 |
|
|---|
| 76 | public IChildPlaylistCollection Children
|
|---|
| 77 | {
|
|---|
| 78 | get { return new ChildPlaylistCollection(null, this); }
|
|---|
| 79 | }
|
|---|
| 80 | }
|
|---|
| 81 |
|
|---|
| 82 |
|
|---|
| 83 | internal class IPodSource : Source, IIPodSource
|
|---|
| 84 | {
|
|---|
| 85 | protected internal IPodSource(iTunes.IITIPodSource _internal, ITunesApp _app)
|
|---|
| 86 | : base(_internal, _app)
|
|---|
| 87 | {
|
|---|
| 88 | }
|
|---|
| 89 |
|
|---|
| 90 | protected internal iTunes.IITIPodSource _asIITIPodSource
|
|---|
| 91 | {
|
|---|
| 92 | get { return (iTunes.IITIPodSource) this._internal; }
|
|---|
| 93 | }
|
|---|
| 94 |
|
|---|
| 95 | public void EjectIPod()
|
|---|
| 96 | {
|
|---|
| 97 | this._asIITIPodSource.EjectIPod();
|
|---|
| 98 | }
|
|---|
| 99 |
|
|---|
| 100 | public string SoftwareVersion
|
|---|
| 101 | {
|
|---|
| 102 | get { return this._asIITIPodSource.SoftwareVersion; }
|
|---|
| 103 | }
|
|---|
| 104 |
|
|---|
| 105 | public void UpdateIPod()
|
|---|
| 106 | {
|
|---|
| 107 | this._asIITIPodSource.UpdateIPod();
|
|---|
| 108 | }
|
|---|
| 109 | }
|
|---|
| 110 |
|
|---|
| 111 | internal class SourceCollection : ITBaseCollection<ISource>,
|
|---|
| 112 | ItemCreatableCollection<iTunesLib.IITSource, ISource>, ISourceCollection
|
|---|
| 113 | {
|
|---|
| 114 | private readonly IIndexedCollection<string, ISource> _itemByName;
|
|---|
| 115 |
|
|---|
| 116 | protected internal SourceCollection(iTunes.IITSourceCollection _internal, ITunesApp _app)
|
|---|
| 117 | : base(_internal, _app)
|
|---|
| 118 | {
|
|---|
| 119 | this._itemByName = new ParentStringIndexerReferrer<SourceCollection, ISource>(this);
|
|---|
| 120 | }
|
|---|
| 121 |
|
|---|
| 122 | protected internal iTunesLib.IITSourceCollection _asIITSourceCollection
|
|---|
| 123 | {
|
|---|
| 124 | get { return (iTunesLib.IITSourceCollection) this._internal; }
|
|---|
| 125 | }
|
|---|
| 126 |
|
|---|
| 127 | public override int Count
|
|---|
| 128 | {
|
|---|
| 129 | get { return this._asIITSourceCollection.Count; }
|
|---|
| 130 | }
|
|---|
| 131 |
|
|---|
| 132 | public ISource this[int Index]
|
|---|
| 133 | {
|
|---|
| 134 | get { return this.CreateItem(this._asIITSourceCollection[Index]); }
|
|---|
| 135 | }
|
|---|
| 136 |
|
|---|
| 137 | public ISource this[string Name]
|
|---|
| 138 | {
|
|---|
| 139 | get { return this.CreateItem(this._asIITSourceCollection.get_ItemByName(Name)); }
|
|---|
| 140 | }
|
|---|
| 141 |
|
|---|
| 142 | public IIndexedCollection<string, ISource> ItemByName
|
|---|
| 143 | {
|
|---|
| 144 | get { return this._itemByName; }
|
|---|
| 145 | }
|
|---|
| 146 |
|
|---|
| 147 | public ISource CreateItem(iTunesLib.IITSource item)
|
|---|
| 148 | {
|
|---|
| 149 | return this._app.factory.CreateSource(item);
|
|---|
| 150 | }
|
|---|
| 151 |
|
|---|
| 152 | protected internal override IEnumerator<ISource> _GetEnumerator()
|
|---|
| 153 | {
|
|---|
| 154 | return
|
|---|
| 155 | new ITBaseEnumerator<iTunesLib.IITSource, ISource, SourceCollection>(
|
|---|
| 156 | this._asIITSourceCollection.GetEnumerator(), this);
|
|---|
| 157 | }
|
|---|
| 158 | }
|
|---|
| 159 | } |
|---|