Add some analyzers to MediaBrowser.MediaEncoding

This commit is contained in:
Bond-009
2020-08-04 17:08:09 +02:00
parent 18efa25a6f
commit 53f99d5d4b
11 changed files with 210 additions and 169 deletions

View File

@@ -1,11 +1,7 @@
#pragma warning disable CS1591
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Model.Configuration;
namespace MediaBrowser.MediaEncoding.Configuration
{
@@ -19,32 +15,4 @@ namespace MediaBrowser.MediaEncoding.Configuration
};
}
}
public class EncodingConfigurationStore : ConfigurationStore, IValidatingConfiguration
{
public EncodingConfigurationStore()
{
ConfigurationType = typeof(EncodingOptions);
Key = "encoding";
}
public void Validate(object oldConfig, object newConfig)
{
var newPath = ((EncodingOptions)newConfig).TranscodingTempPath;
if (!string.IsNullOrWhiteSpace(newPath)
&& !string.Equals(((EncodingOptions)oldConfig).TranscodingTempPath, newPath, StringComparison.Ordinal))
{
// Validate
if (!Directory.Exists(newPath))
{
throw new DirectoryNotFoundException(
string.Format(
CultureInfo.InvariantCulture,
"{0} does not exist.",
newPath));
}
}
}
}
}