remove IChannelItem interface

This commit is contained in:
Luke Pulverenti 2016-03-19 00:05:33 -04:00
parent bd06308f2c
commit 9e495d3886
14 changed files with 38 additions and 38 deletions

View File

@ -11,7 +11,7 @@ using MediaBrowser.Model.Entities;
namespace MediaBrowser.Controller.Channels namespace MediaBrowser.Controller.Channels
{ {
public class ChannelFolderItem : Folder, IChannelItem public class ChannelFolderItem : Folder
{ {
public ChannelFolderType ChannelFolderType { get; set; } public ChannelFolderType ChannelFolderType { get; set; }

View File

@ -132,9 +132,9 @@ namespace MediaBrowser.Controller.Channels
return IsVisibleStandaloneInternal(user, false) && IsChannelVisible(this, user); return IsVisibleStandaloneInternal(user, false) && IsChannelVisible(this, user);
} }
internal static bool IsChannelVisible(IChannelItem item, User user) internal static bool IsChannelVisible(BaseItem channelItem, User user)
{ {
var channel = ChannelManager.GetChannel(item.ChannelId); var channel = ChannelManager.GetChannel(channelItem.ChannelId);
return channel.IsVisible(user); return channel.IsVisible(user);
} }

View File

@ -1,11 +0,0 @@
using MediaBrowser.Controller.Entities;
namespace MediaBrowser.Controller.Channels
{
public interface IChannelItem : IHasImages, IHasTags
{
string ChannelId { get; set; }
string ExternalId { get; set; }
}
}

View File

@ -1,11 +1,16 @@
using MediaBrowser.Model.Channels; using System;
using MediaBrowser.Model.Channels;
using MediaBrowser.Model.Entities; using MediaBrowser.Model.Entities;
using System.Collections.Generic; using System.Collections.Generic;
namespace MediaBrowser.Controller.Channels namespace MediaBrowser.Controller.Channels
{ {
public interface IChannelMediaItem : IChannelItem public interface IChannelMediaItem
{ {
string ChannelId { get; set; }
Guid Id { get; set; }
string ExternalId { get; set; }
long? RunTimeTicks { get; set; } long? RunTimeTicks { get; set; }
string MediaType { get; } string MediaType { get; }

View File

@ -169,6 +169,9 @@ namespace MediaBrowser.Controller.Entities
[IgnoreDataMember] [IgnoreDataMember]
public bool IsOffline { get; set; } public bool IsOffline { get; set; }
[IgnoreDataMember]
public SourceType SourceType { get; set; }
/// <summary> /// <summary>
/// Returns the folder containing the item. /// Returns the folder containing the item.
/// If the item is a folder, it returns the folder itself /// If the item is a folder, it returns the folder itself

View File

@ -0,0 +1,10 @@

namespace MediaBrowser.Controller.Entities
{
public enum SourceType
{
Library = 0,
Channel = 1,
LiveTV = 2
}
}

View File

@ -84,7 +84,6 @@
<Compile Include="Channels\ChannelSearchInfo.cs" /> <Compile Include="Channels\ChannelSearchInfo.cs" />
<Compile Include="Channels\IChannel.cs" /> <Compile Include="Channels\IChannel.cs" />
<Compile Include="Channels\IChannelManager.cs" /> <Compile Include="Channels\IChannelManager.cs" />
<Compile Include="Channels\IChannelItem.cs" />
<Compile Include="Channels\ChannelAudioItem.cs" /> <Compile Include="Channels\ChannelAudioItem.cs" />
<Compile Include="Channels\ChannelVideoItem.cs" /> <Compile Include="Channels\ChannelVideoItem.cs" />
<Compile Include="Channels\Channel.cs" /> <Compile Include="Channels\Channel.cs" />
@ -180,6 +179,7 @@
<Compile Include="Entities\Photo.cs" /> <Compile Include="Entities\Photo.cs" />
<Compile Include="Entities\PhotoAlbum.cs" /> <Compile Include="Entities\PhotoAlbum.cs" />
<Compile Include="Entities\Share.cs" /> <Compile Include="Entities\Share.cs" />
<Compile Include="Entities\SourceType.cs" />
<Compile Include="Entities\UserView.cs" /> <Compile Include="Entities\UserView.cs" />
<Compile Include="Entities\UserViewBuilder.cs" /> <Compile Include="Entities\UserViewBuilder.cs" />
<Compile Include="FileOrganization\IFileOrganizationService.cs" /> <Compile Include="FileOrganization\IFileOrganizationService.cs" />

View File

@ -1079,7 +1079,7 @@ namespace MediaBrowser.Server.Implementations.Channels
if (!string.IsNullOrWhiteSpace(folderId)) if (!string.IsNullOrWhiteSpace(folderId))
{ {
var categoryItem = (IChannelItem)_libraryManager.GetItemById(new Guid(folderId)); var categoryItem = _libraryManager.GetItemById(new Guid(folderId));
query.FolderId = categoryItem.ExternalId; query.FolderId = categoryItem.ExternalId;
} }
@ -1195,7 +1195,7 @@ namespace MediaBrowser.Server.Implementations.Channels
} }
private T GetItemById<T>(string idString, string channelName, string channnelDataVersion, out bool isNew) private T GetItemById<T>(string idString, string channelName, string channnelDataVersion, out bool isNew)
where T : BaseItem, IChannelItem, new() where T : BaseItem, new()
{ {
var id = GetIdToHash(idString, channelName).GetMBId(typeof(T)); var id = GetIdToHash(idString, channelName).GetMBId(typeof(T));
@ -1263,9 +1263,7 @@ namespace MediaBrowser.Server.Implementations.Channels
item.Tags = info.Tags; item.Tags = info.Tags;
} }
var channelItem = (IChannelItem)item; item.ChannelId = internalChannelId.ToString("N");
channelItem.ChannelId = internalChannelId.ToString("N");
if (item.ParentId != internalChannelId) if (item.ParentId != internalChannelId)
{ {
@ -1273,11 +1271,11 @@ namespace MediaBrowser.Server.Implementations.Channels
} }
item.ParentId = internalChannelId; item.ParentId = internalChannelId;
if (!string.Equals(channelItem.ExternalId, info.Id, StringComparison.OrdinalIgnoreCase)) if (!string.Equals(item.ExternalId, info.Id, StringComparison.OrdinalIgnoreCase))
{ {
forceUpdate = true; forceUpdate = true;
} }
channelItem.ExternalId = info.Id; item.ExternalId = info.Id;
var channelMediaItem = item as IChannelMediaItem; var channelMediaItem = item as IChannelMediaItem;

View File

@ -480,7 +480,7 @@ namespace MediaBrowser.Server.Implementations.Dto
var folder = (Folder)item; var folder = (Folder)item;
if (!(folder is IChannelItem) && !(folder is Channel)) if (item.SourceType == SourceType.Library)
{ {
dto.ChildCount = GetChildCount(folder, user); dto.ChildCount = GetChildCount(folder, user);
@ -1531,10 +1531,9 @@ namespace MediaBrowser.Server.Implementations.Dto
dto.ChannelId = item.ChannelId; dto.ChannelId = item.ChannelId;
var channelItem = item as IChannelItem; if (item.SourceType == SourceType.Channel)
if (channelItem != null)
{ {
dto.ChannelName = _channelManagerFactory().GetChannel(channelItem.ChannelId).Name; dto.ChannelName = _channelManagerFactory().GetChannel(item.ChannelId).Name;
} }
var channelMediaItem = item as IChannelMediaItem; var channelMediaItem = item as IChannelMediaItem;

View File

@ -342,7 +342,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
void _libraryManager_ItemRemoved(object sender, ItemChangeEventArgs e) void _libraryManager_ItemRemoved(object sender, ItemChangeEventArgs e)
{ {
if (e.Item is LiveTvProgram || e.Item is IChannelItem) if (e.Item.SourceType != SourceType.Library)
{ {
return; return;
} }
@ -356,7 +356,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
void _libraryManager_ItemAdded(object sender, ItemChangeEventArgs e) void _libraryManager_ItemAdded(object sender, ItemChangeEventArgs e)
{ {
if (e.Item is LiveTvProgram || e.Item is IChannelItem) if (e.Item.SourceType != SourceType.Library)
{ {
return; return;
} }

View File

@ -282,7 +282,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
return false; return false;
} }
return !(item is IChannelItem) && !(item is ILiveTvItem); return item.SourceType == SourceType.Library;
} }
/// <summary> /// <summary>

View File

@ -346,7 +346,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints.Notifications
return false; return false;
} }
return !(item is IChannelItem) && !(item is ILiveTvItem); return item.SourceType == SourceType.Library;
} }
private async void LibraryUpdateTimerCallback(object state) private async void LibraryUpdateTimerCallback(object state)

View File

@ -347,11 +347,7 @@ namespace MediaBrowser.Server.Implementations.Library
private void RegisterItem(Guid id, BaseItem item) private void RegisterItem(Guid id, BaseItem item)
{ {
if (item is LiveTvProgram) if (item.SourceType != SourceType.Library)
{
return;
}
if (item is IChannelItem)
{ {
return; return;
} }

View File

@ -536,7 +536,7 @@ namespace MediaBrowser.Server.Implementations.Sync
} }
} }
if (item is LiveTvChannel || item is IChannelItem) if (item.SourceType != SourceType.Library)
{ {
return false; return false;
} }