diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-12-21 14:40:37 -0500 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-12-21 14:40:37 -0500 |
| commit | 97ae93fe5eb0f010db9835efd72954f31ccdd2cd (patch) | |
| tree | 607b38c6a281c3eb0f76441259f77660668990dd /MediaBrowser.MediaEncoding/Configuration/EncodingConfigurationFactory.cs | |
| parent | 74520804f80974ec018a6c45f4e221276ded4cd3 (diff) | |
add standalone EncodingOptions
Diffstat (limited to 'MediaBrowser.MediaEncoding/Configuration/EncodingConfigurationFactory.cs')
| -rw-r--r-- | MediaBrowser.MediaEncoding/Configuration/EncodingConfigurationFactory.cs | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/MediaBrowser.MediaEncoding/Configuration/EncodingConfigurationFactory.cs b/MediaBrowser.MediaEncoding/Configuration/EncodingConfigurationFactory.cs new file mode 100644 index 000000000..17470d206 --- /dev/null +++ b/MediaBrowser.MediaEncoding/Configuration/EncodingConfigurationFactory.cs @@ -0,0 +1,45 @@ +using MediaBrowser.Common.Configuration; +using MediaBrowser.Model.Configuration; +using System.Collections.Generic; +using System.IO; + +namespace MediaBrowser.MediaEncoding.Configuration +{ + public class EncodingConfigurationFactory : IConfigurationFactory + { + public IEnumerable<ConfigurationStore> GetConfigurations() + { + return new[] + { + new EncodingConfigurationStore() + }; + } + } + + public class EncodingConfigurationStore : ConfigurationStore, IValidatingConfiguration + { + public EncodingConfigurationStore() + { + ConfigurationType = typeof(EncodingOptions); + Key = "encoding"; + } + + public void Validate(object oldConfig, object newConfig) + { + var oldEncodingConfig = (EncodingOptions)oldConfig; + var newEncodingConfig = (EncodingOptions)newConfig; + + var newPath = newEncodingConfig.TranscodingTempPath; + + if (!string.IsNullOrWhiteSpace(newPath) + && !string.Equals(oldEncodingConfig.TranscodingTempPath ?? string.Empty, newPath)) + { + // Validate + if (!Directory.Exists(newPath)) + { + throw new DirectoryNotFoundException(string.Format("{0} does not exist.", newPath)); + } + } + } + } +} |
