diff options
| author | LukePulverenti <luke.pulverenti@gmail.com> | 2013-02-23 10:32:54 -0500 |
|---|---|---|
| committer | LukePulverenti <luke.pulverenti@gmail.com> | 2013-02-23 10:32:54 -0500 |
| commit | 33ed929b526acbda696f00f5966917ebd6a9ded2 (patch) | |
| tree | 18e75812ce71274a3e02f800536e8c144f4e5c45 /MediaBrowser.ServerApplication | |
| parent | 02634588710f65ce952d0229d7da6b9c9d341492 (diff) | |
| parent | e30b96217333cadb78dcc0a47545afd145c683a7 (diff) | |
Merge branch 'master' of https://github.com/MediaBrowser/MediaBrowser
Conflicts:
MediaBrowser.ServerApplication/CorePlugins/MediaBrowser.Api.dll
MediaBrowser.ServerApplication/CorePlugins/MediaBrowser.ApiInteraction.Javascript.dll
MediaBrowser.ServerApplication/CorePlugins/MediaBrowser.Server.Sqlite.dll
MediaBrowser.ServerApplication/CorePlugins/MediaBrowser.Server.WorldWeatherOnline.dll
MediaBrowser.ServerApplication/CorePlugins/MediaBrowser.WebDashboard.dll
Diffstat (limited to 'MediaBrowser.ServerApplication')
| -rw-r--r-- | MediaBrowser.ServerApplication/App.xaml.cs | 92 | ||||
| -rw-r--r-- | MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj | 23 | ||||
| -rw-r--r-- | MediaBrowser.ServerApplication/packages.config | 1 |
3 files changed, 112 insertions, 4 deletions
diff --git a/MediaBrowser.ServerApplication/App.xaml.cs b/MediaBrowser.ServerApplication/App.xaml.cs index 919898aa3..492fef242 100644 --- a/MediaBrowser.ServerApplication/App.xaml.cs +++ b/MediaBrowser.ServerApplication/App.xaml.cs @@ -1,13 +1,17 @@ using MediaBrowser.ClickOnce; +using MediaBrowser.Common.IO; using MediaBrowser.Common.Kernel; using MediaBrowser.Controller; using MediaBrowser.IsoMounter; using MediaBrowser.Logging.Nlog; +using MediaBrowser.Model.IO; using MediaBrowser.Model.Logging; +using MediaBrowser.Model.MediaInfo; using MediaBrowser.Model.Updates; using MediaBrowser.Server.Uninstall; using MediaBrowser.ServerApplication.Implementations; using Microsoft.Win32; +using SimpleInjector; using System; using System.Diagnostics; using System.IO; @@ -74,6 +78,11 @@ namespace MediaBrowser.ServerApplication public string LogFilePath { get; private set; } /// <summary> + /// The container + /// </summary> + private Container _container = new Container(); + + /// <summary> /// Initializes a new instance of the <see cref="App" /> class. /// </summary> /// <param name="logger">The logger.</param> @@ -121,6 +130,12 @@ namespace MediaBrowser.ServerApplication } /// <summary> + /// Gets or sets the iso manager. + /// </summary> + /// <value>The iso manager.</value> + private IIsoManager IsoManager { get; set; } + + /// <summary> /// Gets or sets a value indicating whether [last run at startup value]. /// </summary> /// <value><c>null</c> if [last run at startup value] contains no value, <c>true</c> if [last run at startup value]; otherwise, <c>false</c>.</value> @@ -177,7 +192,9 @@ namespace MediaBrowser.ServerApplication /// </summary> protected async void LoadKernel() { - Kernel = new Kernel(this, new PismoIsoManager(Logger), new DotNetZipClient(), new BdInfoExaminer(), Logger); + RegisterResources(); + + Kernel = new Kernel(this, Logger); try { @@ -378,7 +395,7 @@ namespace MediaBrowser.ServerApplication NlogManager.AddFileTarget(LogFilePath, Kernel.Configuration.EnableDebugLevelLogging); } - + /// <summary> /// Gets the image. /// </summary> @@ -485,5 +502,76 @@ namespace MediaBrowser.ServerApplication { return new ApplicationUpdater().UpdateApplication(cancellationToken, progress); } + + /// <summary> + /// Registers resources that classes will depend on + /// </summary> + private void RegisterResources() + { + Register<IApplicationHost>(this); + Register(Logger); + + IsoManager = new PismoIsoManager(Logger); + + Register<IIsoManager>(IsoManager); + Register<IBlurayExaminer>(new BdInfoExaminer()); + Register<IZipClient>(new DotNetZipClient()); + } + + /// <summary> + /// Creates an instance of type and resolves all constructor dependancies + /// </summary> + /// <param name="type">The type.</param> + /// <returns>System.Object.</returns> + public object CreateInstance(Type type) + { + try + { + return _container.GetInstance(type); + } + catch + { + Logger.Error("Error creating {0}", type.Name); + + throw; + } + } + + /// <summary> + /// Registers the specified obj. + /// </summary> + /// <typeparam name="T"></typeparam> + /// <param name="obj">The obj.</param> + public void Register<T>(T obj) + where T : class + { + _container.RegisterSingle(obj); + } + + /// <summary> + /// Resolves this instance. + /// </summary> + /// <typeparam name="T"></typeparam> + /// <returns>``0.</returns> + public T Resolve<T>() + { + return (T)_container.GetRegistration(typeof (T), true).GetInstance(); + } + + /// <summary> + /// Resolves this instance. + /// </summary> + /// <typeparam name="T"></typeparam> + /// <returns>``0.</returns> + public T TryResolve<T>() + { + var result = _container.GetRegistration(typeof (T), false); + + if (result == null) + { + return default(T); + } + return (T)result.GetInstance(); + } } } diff --git a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj index 79ced29a7..9f9b87b05 100644 --- a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj +++ b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj @@ -66,7 +66,7 @@ <ApplicationManifest>app.manifest</ApplicationManifest> </PropertyGroup> <PropertyGroup> - <RunPostBuildEvent>Always</RunPostBuildEvent> + <RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent> </PropertyGroup> <PropertyGroup> <ManifestCertificateThumbprint>9633DCDB4A07D3328EFB99299C6DFB1823EBC4BE</ManifestCertificateThumbprint> @@ -128,6 +128,10 @@ <SpecificVersion>False</SpecificVersion> <HintPath>..\ThirdParty\UPnP\Libs\Platinum.Managed.dll</HintPath> </Reference> + <Reference Include="SimpleInjector, Version=2.0.0.0, Culture=neutral, PublicKeyToken=984cb50dea722e99, processorArchitecture=MSIL"> + <SpecificVersion>False</SpecificVersion> + <HintPath>..\packages\SimpleInjector.2.0.0-beta5\lib\net40-client\SimpleInjector.dll</HintPath> + </Reference> <Reference Include="System" /> <Reference Include="System.Configuration" /> <Reference Include="System.Data" /> @@ -373,7 +377,22 @@ <ItemGroup /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <PropertyGroup> - <PostBuildEvent>xcopy "$(SolutionDir)\packages\System.Data.SQLite.1.0.84.0\content\net40\x86\SQLite.Interop.dll" "$(TargetDir)" /y</PostBuildEvent> + <PostBuildEvent>xcopy "$(SolutionDir)\packages\System.Data.SQLite.1.0.84.0\content\net40\x86\SQLite.Interop.dll" "$(TargetDir)" /y + +if $(ConfigurationName) == Release ( +xcopy "$(TargetDir)*.dll" "$(SolutionDir)..\Deploy\Server\System" /y +mkdir "$(SolutionDir)..\Deploy\Server\System\x64" +xcopy "$(TargetDir)x64" "$(SolutionDir)..\Deploy\Server\System\x64" /y + +mkdir "$(SolutionDir)..\Deploy\Server\System\x86" +xcopy "$(TargetDir)x86" "$(SolutionDir)..\Deploy\Server\System\x86" /y + +mkdir "$(SolutionDir)..\Deploy\Server\System\CorePlugins" +xcopy "$(TargetDir)CorePlugins" "$(SolutionDir)..\Deploy\Server\System\CorePlugins" /y + +del "$(SolutionDir)..\Deploy\MBServer.zip" +"$(SolutionDir)7za" a -tzip "$(SolutionDir)..\Deploy\MBServer.zip" "$(SolutionDir)..\Deploy\Server\*" +)</PostBuildEvent> </PropertyGroup> <Import Project="$(SolutionDir)\.nuget\nuget.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. diff --git a/MediaBrowser.ServerApplication/packages.config b/MediaBrowser.ServerApplication/packages.config index c9cf3ee00..e1beae6da 100644 --- a/MediaBrowser.ServerApplication/packages.config +++ b/MediaBrowser.ServerApplication/packages.config @@ -3,5 +3,6 @@ <package id="DotNetZip" version="1.9.1.8" targetFramework="net45" /> <package id="Hardcodet.Wpf.TaskbarNotification" version="1.0.4.0" targetFramework="net45" /> <package id="NLog" version="2.0.0.2000" targetFramework="net45" /> + <package id="SimpleInjector" version="2.0.0-beta5" targetFramework="net45" /> <package id="System.Data.SQLite" version="1.0.84.0" targetFramework="net45" /> </packages>
\ No newline at end of file |
