diff options
| author | LukePulverenti <luke.pulverenti@gmail.com> | 2013-03-01 21:44:46 -0500 |
|---|---|---|
| committer | LukePulverenti <luke.pulverenti@gmail.com> | 2013-03-01 21:44:46 -0500 |
| commit | 7bca933af0f1b85e289306ae482db8846f94026c (patch) | |
| tree | ace079674d0e11daa3dda3fb675e34efefc4880b | |
| parent | 9f8aa880aa11a84eb32e1ff0066daa1c1685aab3 (diff) | |
added the beginning of a service stack abstraction
| -rw-r--r-- | MediaBrowser.Api/UserLibrary/UserLibraryService.cs | 4 | ||||
| -rw-r--r-- | MediaBrowser.Common.Implementations/HttpServer/BaseRestService.cs | 12 | ||||
| -rw-r--r-- | MediaBrowser.Common.Implementations/HttpServer/HttpServer.cs | 5 | ||||
| -rw-r--r-- | MediaBrowser.Common/MediaBrowser.Common.csproj | 1 | ||||
| -rw-r--r-- | MediaBrowser.Common/Net/IRestfulService.cs | 8 | ||||
| -rw-r--r-- | MediaBrowser.Common/Net/RouteInfo.cs | 28 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Kernel.cs | 8 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Library/IIntroProvider.cs (renamed from MediaBrowser.Controller/Playback/IIntroProvider.cs) | 2 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Library/ILibraryManager.cs | 21 | ||||
| -rw-r--r-- | MediaBrowser.Controller/MediaBrowser.Controller.csproj | 2 | ||||
| -rw-r--r-- | MediaBrowser.Model/Connectivity/ClientType.cs | 1 | ||||
| -rw-r--r-- | MediaBrowser.Server.Implementations/Library/LibraryManager.cs | 34 | ||||
| -rw-r--r-- | MediaBrowser.ServerApplication/ApplicationHost.cs | 2 |
13 files changed, 99 insertions, 29 deletions
diff --git a/MediaBrowser.Api/UserLibrary/UserLibraryService.cs b/MediaBrowser.Api/UserLibrary/UserLibraryService.cs index 920532609..78e9ad63e 100644 --- a/MediaBrowser.Api/UserLibrary/UserLibraryService.cs +++ b/MediaBrowser.Api/UserLibrary/UserLibraryService.cs @@ -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); } diff --git a/MediaBrowser.Common.Implementations/HttpServer/BaseRestService.cs b/MediaBrowser.Common.Implementations/HttpServer/BaseRestService.cs index 1c64194a6..bf487b760 100644 --- a/MediaBrowser.Common.Implementations/HttpServer/BaseRestService.cs +++ b/MediaBrowser.Common.Implementations/HttpServer/BaseRestService.cs @@ -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[] {}; + } } } diff --git a/MediaBrowser.Common.Implementations/HttpServer/HttpServer.cs b/MediaBrowser.Common.Implementations/HttpServer/HttpServer.cs index c0f075c5a..785ca56c6 100644 --- a/MediaBrowser.Common.Implementations/HttpServer/HttpServer.cs +++ b/MediaBrowser.Common.Implementations/HttpServer/HttpServer.cs @@ -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(); } } diff --git a/MediaBrowser.Common/MediaBrowser.Common.csproj b/MediaBrowser.Common/MediaBrowser.Common.csproj index c8543168f..d2bfcc38f 100644 --- a/MediaBrowser.Common/MediaBrowser.Common.csproj +++ b/MediaBrowser.Common/MediaBrowser.Common.csproj @@ -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" /> diff --git a/MediaBrowser.Common/Net/IRestfulService.cs b/MediaBrowser.Common/Net/IRestfulService.cs index d62be4987..9f3767645 100644 --- a/MediaBrowser.Common/Net/IRestfulService.cs +++ b/MediaBrowser.Common/Net/IRestfulService.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(); } } diff --git a/MediaBrowser.Common/Net/RouteInfo.cs b/MediaBrowser.Common/Net/RouteInfo.cs new file mode 100644 index 000000000..379aff9c5 --- /dev/null +++ b/MediaBrowser.Common/Net/RouteInfo.cs @@ -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; } + } +} diff --git a/MediaBrowser.Controller/Kernel.cs b/MediaBrowser.Controller/Kernel.cs index 275b7868b..145171fd8 100644 --- a/MediaBrowser.Controller/Kernel.cs +++ b/MediaBrowser.Controller/Kernel.cs @@ -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; @@ -87,12 +86,6 @@ namespace MediaBrowser.Controller 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> /// <value>The weather providers.</value> @@ -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>(); diff --git a/MediaBrowser.Controller/Playback/IIntroProvider.cs b/MediaBrowser.Controller/Library/IIntroProvider.cs index 1f7d12fee..f54c3a329 100644 --- a/MediaBrowser.Controller/Playback/IIntroProvider.cs +++ b/MediaBrowser.Controller/Library/IIntroProvider.cs @@ -1,7 +1,7 @@ using MediaBrowser.Controller.Entities; using System.Collections.Generic; -namespace MediaBrowser.Controller.Playback +namespace MediaBrowser.Controller.Library { /// <summary> /// Class BaseIntroProvider diff --git a/MediaBrowser.Controller/Library/ILibraryManager.cs b/MediaBrowser.Controller/Library/ILibraryManager.cs index 721b5c216..64070cb83 100644 --- a/MediaBrowser.Controller/Library/ILibraryManager.cs +++ b/MediaBrowser.Controller/Library/ILibraryManager.cs @@ -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 { @@ -144,12 +144,21 @@ namespace MediaBrowser.Controller.Library 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); } }
\ No newline at end of file diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index 3806defe7..1e55ae78e 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -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" /> diff --git a/MediaBrowser.Model/Connectivity/ClientType.cs b/MediaBrowser.Model/Connectivity/ClientType.cs index 409dc9637..7e837ed0e 100644 --- a/MediaBrowser.Model/Connectivity/ClientType.cs +++ b/MediaBrowser.Model/Connectivity/ClientType.cs @@ -17,6 +17,7 @@ /// The dashboard /// </summary> Dashboard, + Dlna, /// <summary> /// The ios /// </summary> diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs index f25f7b2bb..18108842f 100644 --- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs +++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs @@ -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; @@ -27,22 +28,28 @@ namespace MediaBrowser.Server.Implementations.Library 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)); } } } diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.cs index 654fce42e..ce4aa5ebd 100644 --- a/MediaBrowser.ServerApplication/ApplicationHost.cs +++ b/MediaBrowser.ServerApplication/ApplicationHost.cs @@ -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)); |
