mirror of
https://github.com/jellyfin/jellyfin
synced 2024-09-06 08:04:44 +00:00
added the beginning of a service stack abstraction
This commit is contained in:
parent
9f8aa880aa
commit
7bca933af0
|
@ -409,13 +409,11 @@ namespace MediaBrowser.Api.UserLibrary
|
|||
/// <returns>System.Object.</returns>
|
||||
public object Get(GetIntros request)
|
||||
{
|
||||
var kernel = (Kernel)Kernel;
|
||||
|
||||
var user = _userManager.GetUserById(request.UserId);
|
||||
|
||||
var item = DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager, user.Id);
|
||||
|
||||
var result = kernel.IntroProviders.SelectMany(i => i.GetIntros(item, user));
|
||||
var result = _libraryManager.GetIntros(item, user);
|
||||
|
||||
return ToOptimizedResult(result);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using MediaBrowser.Common.Extensions;
|
||||
using System.Collections.Generic;
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Common.Kernel;
|
||||
using MediaBrowser.Common.Net;
|
||||
|
@ -451,5 +452,14 @@ namespace MediaBrowser.Common.Implementations.HttpServer
|
|||
Response.AddHeader("Age", Convert.ToInt64((DateTime.UtcNow - lastDateModified.Value).TotalSeconds).ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the routes.
|
||||
/// </summary>
|
||||
/// <returns>IEnumerable{RouteInfo}.</returns>
|
||||
public IEnumerable<RouteInfo> GetRoutes()
|
||||
{
|
||||
return new RouteInfo[] {};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -511,6 +511,11 @@ namespace MediaBrowser.Common.Implementations.HttpServer
|
|||
EndpointHost.ConfigureHost(this, ServerName, CreateServiceManager());
|
||||
ContentTypeFilters.Register(ContentType.ProtoBuf, (reqCtx, res, stream) => ProtobufSerializer.SerializeToStream(res, stream), (type, stream) => ProtobufSerializer.DeserializeFromStream(stream, type));
|
||||
|
||||
foreach (var route in services.SelectMany(i => i.GetRoutes()))
|
||||
{
|
||||
Routes.Add(route.RequestType, route.Path, route.Verbs);
|
||||
}
|
||||
|
||||
Init();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,6 +75,7 @@
|
|||
<Compile Include="Net\IWebSocketConnection.cs" />
|
||||
<Compile Include="Net\IWebSocketServer.cs" />
|
||||
<Compile Include="Net\MimeTypes.cs" />
|
||||
<Compile Include="Net\RouteInfo.cs" />
|
||||
<Compile Include="Net\UdpMessageReceivedEventArgs.cs" />
|
||||
<Compile Include="Net\WebSocketConnectEventArgs.cs" />
|
||||
<Compile Include="Net\WebSocketMessageType.cs" />
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MediaBrowser.Common.Net
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -6,5 +7,10 @@ namespace MediaBrowser.Common.Net
|
|||
/// </summary>
|
||||
public interface IRestfulService
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the routes.
|
||||
/// </summary>
|
||||
/// <returns>IEnumerable{RouteInfo}.</returns>
|
||||
IEnumerable<RouteInfo> GetRoutes();
|
||||
}
|
||||
}
|
||||
|
|
28
MediaBrowser.Common/Net/RouteInfo.cs
Normal file
28
MediaBrowser.Common/Net/RouteInfo.cs
Normal file
|
@ -0,0 +1,28 @@
|
|||
using System;
|
||||
|
||||
namespace MediaBrowser.Common.Net
|
||||
{
|
||||
/// <summary>
|
||||
/// Class RouteInfo
|
||||
/// </summary>
|
||||
public class RouteInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the path.
|
||||
/// </summary>
|
||||
/// <value>The path.</value>
|
||||
public string Path { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the verbs.
|
||||
/// </summary>
|
||||
/// <value>The verbs.</value>
|
||||
public string Verbs { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the type of the request.
|
||||
/// </summary>
|
||||
/// <value>The type of the request.</value>
|
||||
public Type RequestType { get; set; }
|
||||
}
|
||||
}
|
|
@ -7,7 +7,6 @@ using MediaBrowser.Controller.Library;
|
|||
using MediaBrowser.Controller.Localization;
|
||||
using MediaBrowser.Controller.MediaInfo;
|
||||
using MediaBrowser.Controller.Persistence;
|
||||
using MediaBrowser.Controller.Playback;
|
||||
using MediaBrowser.Controller.Plugins;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Controller.Updates;
|
||||
|
@ -86,12 +85,6 @@ namespace MediaBrowser.Controller
|
|||
/// <value>The configuration pages.</value>
|
||||
public IEnumerable<IPluginConfigurationPage> PluginConfigurationPages { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the intro providers.
|
||||
/// </summary>
|
||||
/// <value>The intro providers.</value>
|
||||
public IEnumerable<IIntroProvider> IntroProviders { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of currently registered weather prvoiders
|
||||
/// </summary>
|
||||
|
@ -210,7 +203,6 @@ namespace MediaBrowser.Controller
|
|||
DisplayPreferencesRepositories = ApplicationHost.GetExports<IDisplayPreferencesRepository>();
|
||||
ItemRepositories = ApplicationHost.GetExports<IItemRepository>();
|
||||
WeatherProviders = ApplicationHost.GetExports<IWeatherProvider>();
|
||||
IntroProviders = ApplicationHost.GetExports<IIntroProvider>();
|
||||
PluginConfigurationPages = ApplicationHost.GetExports<IPluginConfigurationPage>();
|
||||
ImageEnhancers = ApplicationHost.GetExports<IImageEnhancer>().OrderBy(e => e.Priority).ToArray();
|
||||
StringFiles = ApplicationHost.GetExports<LocalizedStringData>();
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using MediaBrowser.Controller.Entities;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MediaBrowser.Controller.Playback
|
||||
namespace MediaBrowser.Controller.Library
|
||||
{
|
||||
/// <summary>
|
||||
/// Class BaseIntroProvider
|
|
@ -1,11 +1,11 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.IO;
|
||||
using MediaBrowser.Controller.Resolvers;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MediaBrowser.Controller.Library
|
||||
{
|
||||
|
@ -143,13 +143,22 @@ namespace MediaBrowser.Controller.Library
|
|||
/// <returns>BaseItem.</returns>
|
||||
BaseItem GetItemById(Guid id, Guid userId);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the intros.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="user">The user.</param>
|
||||
/// <returns>IEnumerable{System.String}.</returns>
|
||||
IEnumerable<string> GetIntros(BaseItem item, User user);
|
||||
|
||||
/// <summary>
|
||||
/// Adds the parts.
|
||||
/// </summary>
|
||||
/// <param name="rules">The rules.</param>
|
||||
/// <param name="pluginFolders">The plugin folders.</param>
|
||||
/// <param name="resolvers">The resolvers.</param>
|
||||
/// <param name="introProviders">The intro providers.</param>
|
||||
void AddParts(IEnumerable<IResolutionIgnoreRule> rules, IEnumerable<IVirtualFolderCreator> pluginFolders,
|
||||
IEnumerable<IBaseItemResolver> resolvers);
|
||||
IEnumerable<IBaseItemResolver> resolvers, IEnumerable<IIntroProvider> introProviders);
|
||||
}
|
||||
}
|
|
@ -132,7 +132,7 @@
|
|||
<Compile Include="Persistence\IRepository.cs" />
|
||||
<Compile Include="Persistence\IUserDataRepository.cs" />
|
||||
<Compile Include="Persistence\IUserRepository.cs" />
|
||||
<Compile Include="Playback\IIntroProvider.cs" />
|
||||
<Compile Include="Library\IIntroProvider.cs" />
|
||||
<Compile Include="Plugins\IPluginConfigurationPage.cs" />
|
||||
<Compile Include="Plugins\PluginSecurityManager.cs" />
|
||||
<Compile Include="Providers\FanartBaseProvider.cs" />
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
/// The dashboard
|
||||
/// </summary>
|
||||
Dashboard,
|
||||
Dlna,
|
||||
/// <summary>
|
||||
/// The ios
|
||||
/// </summary>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using MediaBrowser.Common.Events;
|
||||
using System.Collections;
|
||||
using MediaBrowser.Common.Events;
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Common.ScheduledTasks;
|
||||
using MediaBrowser.Controller;
|
||||
|
@ -26,23 +27,29 @@ namespace MediaBrowser.Server.Implementations.Library
|
|||
/// </summary>
|
||||
public class LibraryManager : ILibraryManager
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the intro providers.
|
||||
/// </summary>
|
||||
/// <value>The intro providers.</value>
|
||||
private IEnumerable<IIntroProvider> IntroProviders { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of entity resolution ignore rules
|
||||
/// </summary>
|
||||
/// <value>The entity resolution ignore rules.</value>
|
||||
public IEnumerable<IResolutionIgnoreRule> EntityResolutionIgnoreRules { get; private set; }
|
||||
private IEnumerable<IResolutionIgnoreRule> EntityResolutionIgnoreRules { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of BasePluginFolders added by plugins
|
||||
/// </summary>
|
||||
/// <value>The plugin folders.</value>
|
||||
public IEnumerable<IVirtualFolderCreator> PluginFolderCreators { get; set; }
|
||||
private IEnumerable<IVirtualFolderCreator> PluginFolderCreators { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of currently registered entity resolvers
|
||||
/// </summary>
|
||||
/// <value>The entity resolvers enumerable.</value>
|
||||
public IEnumerable<IBaseItemResolver> EntityResolvers { get; private set; }
|
||||
private IEnumerable<IBaseItemResolver> EntityResolvers { get; set; }
|
||||
|
||||
#region LibraryChanged Event
|
||||
/// <summary>
|
||||
|
@ -105,11 +112,13 @@ namespace MediaBrowser.Server.Implementations.Library
|
|||
/// <param name="rules">The rules.</param>
|
||||
/// <param name="pluginFolders">The plugin folders.</param>
|
||||
/// <param name="resolvers">The resolvers.</param>
|
||||
public void AddParts(IEnumerable<IResolutionIgnoreRule> rules, IEnumerable<IVirtualFolderCreator> pluginFolders, IEnumerable<IBaseItemResolver> resolvers)
|
||||
/// <param name="introProviders">The intro providers.</param>
|
||||
public void AddParts(IEnumerable<IResolutionIgnoreRule> rules, IEnumerable<IVirtualFolderCreator> pluginFolders, IEnumerable<IBaseItemResolver> resolvers, IEnumerable<IIntroProvider> introProviders)
|
||||
{
|
||||
EntityResolutionIgnoreRules = rules;
|
||||
PluginFolderCreators = pluginFolders;
|
||||
EntityResolvers = resolvers.OrderBy(i => i.Priority).ToArray();
|
||||
IntroProviders = introProviders;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -655,8 +664,19 @@ namespace MediaBrowser.Server.Implementations.Library
|
|||
{
|
||||
throw new ArgumentNullException("id");
|
||||
}
|
||||
return null;
|
||||
//return RootFolder.FindItemById(id, null);
|
||||
|
||||
return RootFolder.FindItemById(id, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the intros.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="user">The user.</param>
|
||||
/// <returns>IEnumerable{System.String}.</returns>
|
||||
public IEnumerable<string> GetIntros(BaseItem item, User user)
|
||||
{
|
||||
return IntroProviders.SelectMany(i => i.GetIntros(item, user));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -146,7 +146,7 @@ namespace MediaBrowser.ServerApplication
|
|||
{
|
||||
base.FindParts();
|
||||
|
||||
Resolve<ILibraryManager>().AddParts(GetExports<IResolutionIgnoreRule>(), GetExports<IVirtualFolderCreator>(), GetExports<IBaseItemResolver>());
|
||||
Resolve<ILibraryManager>().AddParts(GetExports<IResolutionIgnoreRule>(), GetExports<IVirtualFolderCreator>(), GetExports<IBaseItemResolver>(), GetExports<IIntroProvider>());
|
||||
|
||||
Kernel.InstallationManager = (InstallationManager)CreateInstance(typeof(InstallationManager));
|
||||
|
||||
|
|
Loading…
Reference in a new issue