resharper suggestions in common project
This commit is contained in:
parent
70da0b6ae9
commit
7806ccd42f
|
@ -47,7 +47,7 @@ namespace MediaBrowser.Common.Implementations.Updates
|
|||
{
|
||||
var data = new Dictionary<string, string> { { "key", _securityManager.SupporterKey }, { "mac", _networkManager.GetMacAddress() } };
|
||||
|
||||
using (var json = await _httpClient.Post(Constants.Constants.MBAdminUrl + "service/package/retrieveall", data, cancellationToken).ConfigureAwait(false))
|
||||
using (var json = await _httpClient.Post(Constants.Constants.MbAdminUrl + "service/package/retrieveall", data, cancellationToken).ConfigureAwait(false))
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
|
|
|
@ -1,15 +1,10 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
namespace MediaBrowser.Common.Constants
|
||||
{
|
||||
public static class Constants
|
||||
{
|
||||
public const string MBAdminUrl = "http://www.mb3admin.com/admin/";
|
||||
public const string MBServerPkgName = "MBServer";
|
||||
public const string MBTheaterPkgName = "MBTheater";
|
||||
public const string MbAdminUrl = "http://www.mb3admin.com/admin/";
|
||||
public const string MbServerPkgName = "MBServer";
|
||||
public const string MbTheaterPkgName = "MBTheater";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,37 +12,6 @@ namespace MediaBrowser.Common.Extensions
|
|||
/// </summary>
|
||||
public static class BaseExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Tries the add.
|
||||
/// </summary>
|
||||
/// <typeparam name="TKey">The type of the T key.</typeparam>
|
||||
/// <typeparam name="TValue">The type of the T value.</typeparam>
|
||||
/// <param name="dictionary">The dictionary.</param>
|
||||
/// <param name="key">The key.</param>
|
||||
/// <param name="value">The value.</param>
|
||||
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
|
||||
public static bool TryAdd<TKey, TValue>(this Dictionary<TKey, TValue> dictionary, TKey key, TValue value)
|
||||
{
|
||||
if (dictionary.ContainsKey(key))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
dictionary.Add(key, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Provides an additional overload for string.split
|
||||
/// </summary>
|
||||
/// <param name="val">The val.</param>
|
||||
/// <param name="separator">The separator.</param>
|
||||
/// <param name="options">The options.</param>
|
||||
/// <returns>System.String[][].</returns>
|
||||
public static string[] Split(this string val, char separator, StringSplitOptions options)
|
||||
{
|
||||
return val.Split(new[] { separator }, options);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Strips the HTML.
|
||||
|
@ -55,17 +24,6 @@ namespace MediaBrowser.Common.Extensions
|
|||
const string pattern = @"<(.|\n)*?>";
|
||||
return Regex.Replace(htmlString, pattern, string.Empty).Trim();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shuffles an IEnumerable
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="list">The list.</param>
|
||||
/// <returns>IEnumerable{``0}.</returns>
|
||||
public static IEnumerable<T> Shuffle<T>(this IEnumerable<T> list)
|
||||
{
|
||||
return list.OrderBy(x => Guid.NewGuid());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the M d5.
|
||||
|
|
|
@ -91,11 +91,6 @@
|
|||
<Compile Include="Net\WebSocketConnectEventArgs.cs" />
|
||||
<Compile Include="Plugins\IPlugin.cs" />
|
||||
<Compile Include="Progress\ActionableProgress.cs" />
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ScheduledTasks\IScheduledTask.cs" />
|
||||
<Compile Include="ScheduledTasks\IScheduledTaskWorker.cs" />
|
||||
<Compile Include="ScheduledTasks\ITaskManager.cs" />
|
||||
|
@ -123,13 +118,6 @@
|
|||
<Name>MediaBrowser.Model</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
|
||||
|
|
|
@ -43,12 +43,6 @@ namespace MediaBrowser.Common.Plugins
|
|||
get { return string.Empty; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether this instance is first run.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if this instance is first run; otherwise, <c>false</c>.</value>
|
||||
public bool IsFirstRun { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the type of configuration this plugin uses
|
||||
/// </summary>
|
||||
|
|
|
@ -110,11 +110,5 @@ namespace MediaBrowser.Common.Plugins
|
|||
/// Called when just before the plugin is uninstalled from the server.
|
||||
/// </summary>
|
||||
void OnUninstalling();
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether this instance is first run.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if this instance is first run; otherwise, <c>false</c>.</value>
|
||||
bool IsFirstRun { get; }
|
||||
}
|
||||
}
|
63
MediaBrowser.Common/Properties/Resources.Designer.cs
generated
63
MediaBrowser.Common/Properties/Resources.Designer.cs
generated
|
@ -1,63 +0,0 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.17929
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace MediaBrowser.Common.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MediaBrowser.Common.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,121 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
</root>
|
|
@ -35,6 +35,26 @@ namespace MediaBrowser.Controller.Localization
|
|||
/// </summary>
|
||||
private static readonly Dictionary<int, string> ratingsStrings = new Dictionary<int, string>();
|
||||
|
||||
/// <summary>
|
||||
/// Tries the add.
|
||||
/// </summary>
|
||||
/// <typeparam name="TKey">The type of the T key.</typeparam>
|
||||
/// <typeparam name="TValue">The type of the T value.</typeparam>
|
||||
/// <param name="dictionary">The dictionary.</param>
|
||||
/// <param name="key">The key.</param>
|
||||
/// <param name="value">The value.</param>
|
||||
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
|
||||
private static bool TryAdd<TKey, TValue>(Dictionary<TKey, TValue> dictionary, TKey key, TValue value)
|
||||
{
|
||||
if (dictionary.ContainsKey(key))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
dictionary.Add(key, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the specified block unrated.
|
||||
/// </summary>
|
||||
|
@ -48,19 +68,19 @@ namespace MediaBrowser.Controller.Localization
|
|||
var dict = new Dictionary<string, int> {{"None", -1}};
|
||||
foreach (var pair in ratingsDef.RatingsDict)
|
||||
{
|
||||
dict.TryAdd(pair.Key, pair.Value);
|
||||
TryAdd(dict, pair.Key, pair.Value);
|
||||
}
|
||||
if (configurationManager.Configuration.MetadataCountryCode.ToUpper() != "US")
|
||||
{
|
||||
foreach (var pair in new USRatingsDictionary())
|
||||
{
|
||||
dict.TryAdd(pair.Key, pair.Value);
|
||||
TryAdd(dict, pair.Key, pair.Value);
|
||||
}
|
||||
}
|
||||
//global values of CS
|
||||
dict.TryAdd("CS", 1000);
|
||||
TryAdd(dict, "CS", 1000);
|
||||
|
||||
dict.TryAdd("", blockUnrated ? 1000 : 0);
|
||||
TryAdd(dict, "", blockUnrated ? 1000 : 0);
|
||||
|
||||
//and rating reverse lookup dictionary (non-redundant ones)
|
||||
ratingsStrings.Clear();
|
||||
|
@ -71,11 +91,11 @@ namespace MediaBrowser.Controller.Localization
|
|||
if (pair.Value > lastLevel)
|
||||
{
|
||||
lastLevel = pair.Value;
|
||||
ratingsStrings.TryAdd(pair.Value, pair.Key);
|
||||
TryAdd(ratingsStrings, pair.Value, pair.Key);
|
||||
}
|
||||
}
|
||||
|
||||
ratingsStrings.TryAdd(999, "CS");
|
||||
TryAdd(ratingsStrings, 999, "CS");
|
||||
|
||||
return dict;
|
||||
}
|
||||
|
|
|
@ -617,7 +617,20 @@ namespace MediaBrowser.Controller.Providers
|
|||
|
||||
value = value.Trim().Trim(separator);
|
||||
|
||||
return string.IsNullOrWhiteSpace(value) ? new string[] { } : value.Split(separator, StringSplitOptions.RemoveEmptyEntries);
|
||||
return string.IsNullOrWhiteSpace(value) ? new string[] { } : Split(value, separator, StringSplitOptions.RemoveEmptyEntries);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Provides an additional overload for string.split
|
||||
/// </summary>
|
||||
/// <param name="val">The val.</param>
|
||||
/// <param name="separator">The separator.</param>
|
||||
/// <param name="options">The options.</param>
|
||||
/// <returns>System.String[][].</returns>
|
||||
private static string[] Split(string val, char separator, StringSplitOptions options)
|
||||
{
|
||||
return val.Split(new[] { separator }, options);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace MediaBrowser.ServerApplication
|
|||
{
|
||||
// Look for the existence of an update archive
|
||||
var appPaths = new ServerApplicationPaths();
|
||||
var updateArchive = Path.Combine(appPaths.TempUpdatePath, Constants.MBServerPkgName + ".zip");
|
||||
var updateArchive = Path.Combine(appPaths.TempUpdatePath, Constants.MbServerPkgName + ".zip");
|
||||
if (File.Exists(updateArchive))
|
||||
{
|
||||
// Update is there - execute update
|
||||
|
|
|
@ -424,7 +424,7 @@ namespace MediaBrowser.ServerApplication
|
|||
public async override Task<CheckForUpdateResult> CheckForApplicationUpdate(CancellationToken cancellationToken, IProgress<double> progress)
|
||||
{
|
||||
var availablePackages = await PackageManager.GetAvailablePackages(CancellationToken.None).ConfigureAwait(false);
|
||||
var version = InstallationManager.GetLatestCompatibleVersion(availablePackages, Constants.MBServerPkgName, ConfigurationManager.CommonConfiguration.SystemUpdateLevel);
|
||||
var version = InstallationManager.GetLatestCompatibleVersion(availablePackages, Constants.MbServerPkgName, ConfigurationManager.CommonConfiguration.SystemUpdateLevel);
|
||||
|
||||
return version != null ? new CheckForUpdateResult { AvailableVersion = version.version, IsUpdateAvailable = version.version > ApplicationVersion, Package = version } :
|
||||
new CheckForUpdateResult { AvailableVersion = ApplicationVersion, IsUpdateAvailable = false };
|
||||
|
|
Loading…
Reference in New Issue
Block a user