resharper suggestions in api project

This commit is contained in:
Luke Pulverenti 2013-04-10 11:32:09 -04:00
parent c645b3ff64
commit 70da0b6ae9
18 changed files with 66 additions and 73 deletions

View File

@ -59,9 +59,9 @@ namespace MediaBrowser.Api
/// <param name="dispose"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
protected virtual void Dispose(bool dispose)
{
var jobCount = ActiveTranscodingJobs.Count;
var jobCount = _activeTranscodingJobs.Count;
Parallel.ForEach(ActiveTranscodingJobs, OnTranscodeKillTimerStopped);
Parallel.ForEach(_activeTranscodingJobs, OnTranscodeKillTimerStopped);
// Try to allow for some time to kill the ffmpeg processes and delete the partial stream files
if (jobCount > 0)
@ -73,7 +73,7 @@ namespace MediaBrowser.Api
/// <summary>
/// The active transcoding jobs
/// </summary>
private readonly List<TranscodingJob> ActiveTranscodingJobs = new List<TranscodingJob>();
private readonly List<TranscodingJob> _activeTranscodingJobs = new List<TranscodingJob>();
/// <summary>
/// Called when [transcode beginning].
@ -83,9 +83,9 @@ namespace MediaBrowser.Api
/// <param name="process">The process.</param>
public void OnTranscodeBeginning(string path, TranscodingJobType type, Process process)
{
lock (ActiveTranscodingJobs)
lock (_activeTranscodingJobs)
{
ActiveTranscodingJobs.Add(new TranscodingJob
_activeTranscodingJobs.Add(new TranscodingJob
{
Type = type,
Path = path,
@ -105,11 +105,11 @@ namespace MediaBrowser.Api
/// <param name="type">The type.</param>
public void OnTranscodeFailedToStart(string path, TranscodingJobType type)
{
lock (ActiveTranscodingJobs)
lock (_activeTranscodingJobs)
{
var job = ActiveTranscodingJobs.First(j => j.Type == type && j.Path.Equals(path, StringComparison.OrdinalIgnoreCase));
var job = _activeTranscodingJobs.First(j => j.Type == type && j.Path.Equals(path, StringComparison.OrdinalIgnoreCase));
ActiveTranscodingJobs.Remove(job);
_activeTranscodingJobs.Remove(job);
}
}
@ -121,9 +121,9 @@ namespace MediaBrowser.Api
/// <returns><c>true</c> if [has active transcoding job] [the specified path]; otherwise, <c>false</c>.</returns>
public bool HasActiveTranscodingJob(string path, TranscodingJobType type)
{
lock (ActiveTranscodingJobs)
lock (_activeTranscodingJobs)
{
return ActiveTranscodingJobs.Any(j => j.Type == type && j.Path.Equals(path, StringComparison.OrdinalIgnoreCase));
return _activeTranscodingJobs.Any(j => j.Type == type && j.Path.Equals(path, StringComparison.OrdinalIgnoreCase));
}
}
@ -134,9 +134,9 @@ namespace MediaBrowser.Api
/// <param name="type">The type.</param>
public void OnTranscodeBeginRequest(string path, TranscodingJobType type)
{
lock (ActiveTranscodingJobs)
lock (_activeTranscodingJobs)
{
var job = ActiveTranscodingJobs.FirstOrDefault(j => j.Type == type && j.Path.Equals(path, StringComparison.OrdinalIgnoreCase));
var job = _activeTranscodingJobs.FirstOrDefault(j => j.Type == type && j.Path.Equals(path, StringComparison.OrdinalIgnoreCase));
if (job == null)
{
@ -160,9 +160,9 @@ namespace MediaBrowser.Api
/// <param name="type">The type.</param>
public void OnTranscodeEndRequest(string path, TranscodingJobType type)
{
lock (ActiveTranscodingJobs)
lock (_activeTranscodingJobs)
{
var job = ActiveTranscodingJobs.FirstOrDefault(j => j.Type == type && j.Path.Equals(path, StringComparison.OrdinalIgnoreCase));
var job = _activeTranscodingJobs.FirstOrDefault(j => j.Type == type && j.Path.Equals(path, StringComparison.OrdinalIgnoreCase));
if (job == null)
{
@ -194,16 +194,16 @@ namespace MediaBrowser.Api
/// <param name="type">The type.</param>
public void OnTranscodingFinished(string path, TranscodingJobType type)
{
lock (ActiveTranscodingJobs)
lock (_activeTranscodingJobs)
{
var job = ActiveTranscodingJobs.FirstOrDefault(j => j.Type == type && j.Path.Equals(path, StringComparison.OrdinalIgnoreCase));
var job = _activeTranscodingJobs.FirstOrDefault(j => j.Type == type && j.Path.Equals(path, StringComparison.OrdinalIgnoreCase));
if (job == null)
{
return;
}
ActiveTranscodingJobs.Remove(job);
_activeTranscodingJobs.Remove(job);
if (job.KillTimer != null)
{
@ -221,9 +221,9 @@ namespace MediaBrowser.Api
{
var job = (TranscodingJob)state;
lock (ActiveTranscodingJobs)
lock (_activeTranscodingJobs)
{
ActiveTranscodingJobs.Remove(job);
_activeTranscodingJobs.Remove(job);
if (job.KillTimer != null)
{
@ -306,10 +306,6 @@ namespace MediaBrowser.Api
/// <value>The active request count.</value>
public int ActiveRequestCount { get; set; }
/// <summary>
/// <summary>
/// Enum TranscodingJobType
/// </summary>
/// <summary>
/// Gets or sets the kill timer.
/// </summary>
/// <value>The kill timer.</value>

View File

@ -2,7 +2,6 @@
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Serialization;
using ServiceStack.ServiceHost;
using ServiceStack.Text.Controller;
using System;
using System.Threading;
using System.Threading.Tasks;
@ -78,11 +77,6 @@ namespace MediaBrowser.Api
/// <param name="request">The request.</param>
public void Post(UpdateDisplayPreferences request)
{
// We need to parse this manually because we told service stack not to with IRequiresRequestStream
// https://code.google.com/p/servicestack/source/browse/trunk/Common/ServiceStack.Text/ServiceStack.Text/Controller/PathInfo.cs
var pathInfo = PathInfo.Parse(RequestContext.PathInfo);
var displayPreferencesId = new Guid(pathInfo.GetArgumentValue<string>(1));
// Serialize to json and then back so that the core doesn't see the request dto type
var displayPreferences = _jsonSerializer.DeserializeFromString<DisplayPreferences>(_jsonSerializer.SerializeToString(request));

View File

@ -51,7 +51,7 @@ namespace MediaBrowser.Api
/// Class GetDrives
/// </summary>
[Route("/Environment/Drives", "GET")]
[ServiceStack.ServiceHost.Api(Description = "Gets available drives from the server's file system")]
[Api(Description = "Gets available drives from the server's file system")]
public class GetDrives : IReturn<List<FileSystemEntryInfo>>
{
}
@ -60,7 +60,7 @@ namespace MediaBrowser.Api
/// Class GetNetworkComputers
/// </summary>
[Route("/Environment/NetworkDevices", "GET")]
[ServiceStack.ServiceHost.Api(Description = "Gets a list of devices on the network")]
[Api(Description = "Gets a list of devices on the network")]
public class GetNetworkDevices : IReturn<List<FileSystemEntryInfo>>
{
}

View File

@ -144,13 +144,14 @@ namespace MediaBrowser.Api.Library
/// The _library manager
/// </summary>
private readonly ILibraryManager _libraryManager;
/// <summary>
/// Initializes a new instance of the <see cref="LibraryService" /> class.
/// Initializes a new instance of the <see cref="LibraryStructureService"/> class.
/// </summary>
/// <param name="appPaths">The app paths.</param>
/// <param name="userManager">The user manager.</param>
/// <exception cref="System.ArgumentNullException">appHost</exception>
/// <param name="libraryManager">The library manager.</param>
/// <exception cref="System.ArgumentNullException">appPaths</exception>
public LibraryStructureService(IServerApplicationPaths appPaths, IUserManager userManager, ILibraryManager libraryManager)
{
if (appPaths == null)

View File

@ -13,7 +13,7 @@ namespace MediaBrowser.Api
/// Class GetCultures
/// </summary>
[Route("/Localization/Cultures", "GET")]
[ServiceStack.ServiceHost.Api(Description = "Gets known cultures")]
[Api(Description = "Gets known cultures")]
public class GetCultures : IReturn<List<CultureDto>>
{
}
@ -22,7 +22,7 @@ namespace MediaBrowser.Api
/// Class GetCountries
/// </summary>
[Route("/Localization/Countries", "GET")]
[ServiceStack.ServiceHost.Api(Description = "Gets known countries")]
[Api(Description = "Gets known countries")]
public class GetCountries : IReturn<List<CountryInfo>>
{
}
@ -31,7 +31,7 @@ namespace MediaBrowser.Api
/// Class ParentalRatings
/// </summary>
[Route("/Localization/ParentalRatings", "GET")]
[ServiceStack.ServiceHost.Api(Description = "Gets known parental ratings")]
[Api(Description = "Gets known parental ratings")]
public class GetParentalRatings : IReturn<List<ParentalRating>>
{
}

View File

@ -137,7 +137,7 @@ namespace MediaBrowser.Api
else if (request.PackageType == PackageType.System || request.PackageType == PackageType.All)
{
var updateCheckResult = _appHost.CheckForApplicationUpdate(CancellationToken.None, new Progress<double> { }).Result;
var updateCheckResult = _appHost.CheckForApplicationUpdate(CancellationToken.None, new Progress<double>()).Result;
if (updateCheckResult.IsUpdateAvailable)
{
@ -202,7 +202,7 @@ namespace MediaBrowser.Api
throw new ResourceNotFoundException(string.Format("Package not found: {0}", request.Name));
}
Task.Run(() => _installationManager.InstallPackage(package, new Progress<double> { }, CancellationToken.None));
Task.Run(() => _installationManager.InstallPackage(package, new Progress<double>(), CancellationToken.None));
}
/// <summary>

View File

@ -529,7 +529,7 @@ namespace MediaBrowser.Api.Playback
/// <param name="state">The state.</param>
/// <param name="outputPath">The output path.</param>
/// <returns>Task.</returns>
protected async Task StartFFMpeg(StreamState state, string outputPath)
protected async Task StartFfMpeg(StreamState state, string outputPath)
{
var video = state.Item as Video;
@ -569,7 +569,7 @@ namespace MediaBrowser.Api.Playback
// FFMpeg writes debug/error info to stderr. This is useful when debugging so let's put it in the log directory.
state.LogFileStream = new FileStream(logFilePath, FileMode.Create, FileAccess.Write, FileShare.Read, StreamDefaults.DefaultFileStreamBufferSize, FileOptions.Asynchronous);
process.Exited += (sender, args) => OnFFMpegProcessExited(process, state);
process.Exited += (sender, args) => OnFfMpegProcessExited(process, state);
try
{
@ -604,7 +604,7 @@ namespace MediaBrowser.Api.Playback
/// </summary>
/// <param name="process">The process.</param>
/// <param name="state">The state.</param>
protected void OnFFMpegProcessExited(Process process, StreamState state)
protected void OnFfMpegProcessExited(Process process, StreamState state)
{
if (state.IsoMount != null)
{
@ -691,9 +691,9 @@ namespace MediaBrowser.Api.Playback
videoRequest.VideoCodec = InferVideoCodec(url);
}
state.VideoStream = GetMediaStream(media.MediaStreams, videoRequest.VideoStreamIndex, MediaStreamType.Video, true);
state.VideoStream = GetMediaStream(media.MediaStreams, videoRequest.VideoStreamIndex, MediaStreamType.Video);
state.SubtitleStream = GetMediaStream(media.MediaStreams, videoRequest.SubtitleStreamIndex, MediaStreamType.Subtitle, false);
state.AudioStream = GetMediaStream(media.MediaStreams, videoRequest.AudioStreamIndex, MediaStreamType.Audio, true);
state.AudioStream = GetMediaStream(media.MediaStreams, videoRequest.AudioStreamIndex, MediaStreamType.Audio);
}
else
{

View File

@ -13,7 +13,7 @@ namespace MediaBrowser.Api.Playback.Hls
/// Class GetHlsAudioStream
/// </summary>
[Route("/Audio/{Id}/stream.m3u8", "GET")]
[ServiceStack.ServiceHost.Api(Description = "Gets an audio stream using HTTP live streaming.")]
[Api(Description = "Gets an audio stream using HTTP live streaming.")]
public class GetHlsAudioStream : StreamRequest
{
@ -21,7 +21,7 @@ namespace MediaBrowser.Api.Playback.Hls
[Route("/Audio/{Id}/segments/{SegmentId}/stream.mp3", "GET")]
[Route("/Audio/{Id}/segments/{SegmentId}/stream.aac", "GET")]
[ServiceStack.ServiceHost.Api(Description = "Gets an Http live streaming segment file. Internal use only.")]
[Api(Description = "Gets an Http live streaming segment file. Internal use only.")]
public class GetHlsAudioSegment
{
public string Id { get; set; }

View File

@ -75,7 +75,7 @@ namespace MediaBrowser.Api.Playback.Hls
if (!File.Exists(playlist))
{
isPlaylistNewlyCreated = true;
await StartFFMpeg(state, playlist).ConfigureAwait(false);
await StartFfMpeg(state, playlist).ConfigureAwait(false);
}
else
{

View File

@ -110,12 +110,12 @@ namespace MediaBrowser.Api.Playback.Progressive
var extension = GetOutputFileExtension(state);
// first bit means Time based seek supported, second byte range seek supported (not sure about the order now), so 01 = only byte seek, 10 = time based, 11 = both, 00 = none
var org_op = isStaticallyStreamed ? ";DLNA.ORG_OP=01" : ";DLNA.ORG_OP=00";
var orgOp = isStaticallyStreamed ? ";DLNA.ORG_OP=01" : ";DLNA.ORG_OP=00";
// 0 = native, 1 = transcoded
var org_ci = isStaticallyStreamed ? ";DLNA.ORG_CI=0" : ";DLNA.ORG_CI=1";
var orgCi = isStaticallyStreamed ? ";DLNA.ORG_CI=0" : ";DLNA.ORG_CI=1";
var dlnaflags = ";DLNA.ORG_FLAGS=01500000000000000000000000000000";
const string dlnaflags = ";DLNA.ORG_FLAGS=01500000000000000000000000000000";
if (string.Equals(extension, ".mp3", StringComparison.OrdinalIgnoreCase))
{
@ -158,7 +158,7 @@ namespace MediaBrowser.Api.Playback.Progressive
if (!string.IsNullOrEmpty(contentFeatures))
{
responseHeaders["ContentFeatures.DLNA.ORG"] = (contentFeatures + org_op + org_ci + dlnaflags).Trim(';');
responseHeaders["ContentFeatures.DLNA.ORG"] = (contentFeatures + orgOp + orgCi + dlnaflags).Trim(';');
}
}
@ -274,7 +274,7 @@ namespace MediaBrowser.Api.Playback.Progressive
if (!File.Exists(outputPath))
{
await StartFFMpeg(state, outputPath).ConfigureAwait(false);
await StartFfMpeg(state, outputPath).ConfigureAwait(false);
}
else
{

View File

@ -42,7 +42,7 @@ namespace MediaBrowser.Api
/// Class UninstallPlugin
/// </summary>
[Route("/Plugins/{Id}", "DELETE")]
[ServiceStack.ServiceHost.Api(("Uninstalls a plugin"))]
[Api(("Uninstalls a plugin"))]
public class UninstallPlugin : IReturnVoid
{
/// <summary>
@ -161,6 +161,7 @@ namespace MediaBrowser.Api
/// <param name="jsonSerializer">The json serializer.</param>
/// <param name="appHost">The app host.</param>
/// <param name="securityManager">The security manager.</param>
/// <param name="installationManager">The installation manager.</param>
/// <exception cref="System.ArgumentNullException">jsonSerializer</exception>
public PluginService(IJsonSerializer jsonSerializer, IApplicationHost appHost, ISecurityManager securityManager, IInstallationManager installationManager)
: base()

View File

@ -13,7 +13,7 @@ namespace MediaBrowser.Api.ScheduledTasks
/// Class GetScheduledTask
/// </summary>
[Route("/ScheduledTasks/{Id}", "GET")]
[ServiceStack.ServiceHost.Api(Description = "Gets a scheduled task, by Id")]
[Api(Description = "Gets a scheduled task, by Id")]
public class GetScheduledTask : IReturn<TaskInfo>
{
/// <summary>
@ -28,7 +28,7 @@ namespace MediaBrowser.Api.ScheduledTasks
/// Class GetScheduledTasks
/// </summary>
[Route("/ScheduledTasks", "GET")]
[ServiceStack.ServiceHost.Api(Description = "Gets scheduled tasks")]
[Api(Description = "Gets scheduled tasks")]
public class GetScheduledTasks : IReturn<List<TaskInfo>>
{
@ -38,7 +38,7 @@ namespace MediaBrowser.Api.ScheduledTasks
/// Class StartScheduledTask
/// </summary>
[Route("/ScheduledTasks/Running/{Id}", "POST")]
[ServiceStack.ServiceHost.Api(Description = "Starts a scheduled task")]
[Api(Description = "Starts a scheduled task")]
public class StartScheduledTask : IReturnVoid
{
/// <summary>
@ -53,7 +53,7 @@ namespace MediaBrowser.Api.ScheduledTasks
/// Class StopScheduledTask
/// </summary>
[Route("/ScheduledTasks/Running/{Id}", "DELETE")]
[ServiceStack.ServiceHost.Api(Description = "Stops a scheduled task")]
[Api(Description = "Stops a scheduled task")]
public class StopScheduledTask : IReturnVoid
{
/// <summary>
@ -68,7 +68,7 @@ namespace MediaBrowser.Api.ScheduledTasks
/// Class UpdateScheduledTaskTriggers
/// </summary>
[Route("/ScheduledTasks/{Id}/Triggers", "POST")]
[ServiceStack.ServiceHost.Api(Description = "Updates the triggers for a scheduled task")]
[Api(Description = "Updates the triggers for a scheduled task")]
public class UpdateScheduledTaskTriggers : List<TaskTriggerInfo>, IReturnVoid
{
/// <summary>

View File

@ -15,7 +15,7 @@ namespace MediaBrowser.Api
/// Class GetSystemInfo
/// </summary>
[Route("/System/Info", "GET")]
[ServiceStack.ServiceHost.Api(Description = "Gets information about the server")]
[Api(Description = "Gets information about the server")]
public class GetSystemInfo : IReturn<SystemInfo>
{
@ -25,13 +25,13 @@ namespace MediaBrowser.Api
/// Class RestartApplication
/// </summary>
[Route("/System/Restart", "POST")]
[ServiceStack.ServiceHost.Api(("Restarts the application, if needed"))]
[Api(("Restarts the application, if needed"))]
public class RestartApplication
{
}
[Route("/System/Shutdown", "POST")]
[ServiceStack.ServiceHost.Api(("Shuts down the application"))]
[Api(("Shuts down the application"))]
public class ShutdownApplication
{
}
@ -40,7 +40,7 @@ namespace MediaBrowser.Api
/// Class GetConfiguration
/// </summary>
[Route("/System/Configuration", "GET")]
[ServiceStack.ServiceHost.Api(("Gets application configuration"))]
[Api(("Gets application configuration"))]
public class GetConfiguration : IReturn<ServerConfiguration>
{
@ -50,7 +50,7 @@ namespace MediaBrowser.Api
/// Class UpdateConfiguration
/// </summary>
[Route("/System/Configuration", "POST")]
[ServiceStack.ServiceHost.Api(("Updates application configuration"))]
[Api(("Updates application configuration"))]
public class UpdateConfiguration : ServerConfiguration, IReturnVoid
{
}

View File

@ -13,7 +13,7 @@ namespace MediaBrowser.Api.UserLibrary
/// </summary>
[Route("/Users/{UserId}/Items/{ParentId}/Persons", "GET")]
[Route("/Users/{UserId}/Items/Root/Persons", "GET")]
[ServiceStack.ServiceHost.Api(Description = "Gets all persons from a given item, folder, or the entire library")]
[Api(Description = "Gets all persons from a given item, folder, or the entire library")]
public class GetPersons : GetItemsByName
{
/// <summary>

View File

@ -13,7 +13,7 @@ namespace MediaBrowser.Api.UserLibrary
/// </summary>
[Route("/Users/{UserId}/Items/{ParentId}/Studios", "GET")]
[Route("/Users/{UserId}/Items/Root/Studios", "GET")]
[ServiceStack.ServiceHost.Api(Description = "Gets all studios from a given item, folder, or the entire library")]
[Api(Description = "Gets all studios from a given item, folder, or the entire library")]
public class GetStudios : GetItemsByName
{
}

View File

@ -14,7 +14,7 @@ namespace MediaBrowser.Api.UserLibrary
/// </summary>
[Route("/Users/{UserId}/Items/{ParentId}/Years", "GET")]
[Route("/Users/{UserId}/Items/Root/Years", "GET")]
[ServiceStack.ServiceHost.Api(Description = "Gets all years from a given item, folder, or the entire library")]
[Api(Description = "Gets all years from a given item, folder, or the entire library")]
public class GetYears : GetItemsByName
{
}

View File

@ -15,7 +15,7 @@ namespace MediaBrowser.Api
/// Class GetUsers
/// </summary>
[Route("/Users", "GET")]
[ServiceStack.ServiceHost.Api(Description = "Gets a list of users")]
[Api(Description = "Gets a list of users")]
public class GetUsers : IReturn<List<UserDto>>
{
}
@ -24,7 +24,7 @@ namespace MediaBrowser.Api
/// Class GetUser
/// </summary>
[Route("/Users/{Id}", "GET")]
[ServiceStack.ServiceHost.Api(Description = "Gets a user by Id")]
[Api(Description = "Gets a user by Id")]
public class GetUser : IReturn<UserDto>
{
/// <summary>
@ -39,7 +39,7 @@ namespace MediaBrowser.Api
/// Class DeleteUser
/// </summary>
[Route("/Users/{Id}", "DELETE")]
[ServiceStack.ServiceHost.Api(Description = "Deletes a user")]
[Api(Description = "Deletes a user")]
public class DeleteUser : IReturnVoid
{
/// <summary>
@ -54,7 +54,7 @@ namespace MediaBrowser.Api
/// Class AuthenticateUser
/// </summary>
[Route("/Users/{Id}/Authenticate", "POST")]
[ServiceStack.ServiceHost.Api(Description = "Authenticates a user")]
[Api(Description = "Authenticates a user")]
public class AuthenticateUser : IReturnVoid
{
/// <summary>
@ -76,7 +76,7 @@ namespace MediaBrowser.Api
/// Class UpdateUserPassword
/// </summary>
[Route("/Users/{Id}/Password", "POST")]
[ServiceStack.ServiceHost.Api(Description = "Updates a user's password")]
[Api(Description = "Updates a user's password")]
public class UpdateUserPassword : IReturnVoid
{
/// <summary>
@ -108,7 +108,7 @@ namespace MediaBrowser.Api
/// Class UpdateUser
/// </summary>
[Route("/Users/{Id}", "POST")]
[ServiceStack.ServiceHost.Api(Description = "Updates a user")]
[Api(Description = "Updates a user")]
public class UpdateUser : UserDto, IReturnVoid
{
}
@ -117,7 +117,7 @@ namespace MediaBrowser.Api
/// Class CreateUser
/// </summary>
[Route("/Users", "POST")]
[ServiceStack.ServiceHost.Api(Description = "Creates a user")]
[Api(Description = "Creates a user")]
public class CreateUser : UserDto, IReturn<UserDto>
{
}

View File

@ -29,6 +29,7 @@ namespace MediaBrowser.Api.WebSocket
/// Initializes a new instance of the <see cref="SystemInfoWebSocketListener" /> class.
/// </summary>
/// <param name="logger">The logger.</param>
/// <param name="appHost">The app host.</param>
public SystemInfoWebSocketListener(ILogger logger, IServerApplicationHost appHost)
: base(logger)
{