mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Move cuetools.net codec locally.
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Collections.Generic;
|
||||
using System.Xml.Serialization;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json;
|
||||
using System.IO;
|
||||
|
||||
namespace CUETools.Codecs
|
||||
{
|
||||
public interface IAudioDecoderSettings
|
||||
{
|
||||
string Name { get; }
|
||||
|
||||
string Extension { get; }
|
||||
|
||||
Type DecoderType { get; }
|
||||
|
||||
int Priority { get; }
|
||||
|
||||
IAudioDecoderSettings Clone();
|
||||
}
|
||||
|
||||
public static class IAudioDecoderSettingsExtensions
|
||||
{
|
||||
public static bool HasBrowsableAttributes(this IAudioDecoderSettings settings)
|
||||
{
|
||||
bool hasBrowsable = false;
|
||||
foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(settings))
|
||||
{
|
||||
bool isBrowsable = true;
|
||||
foreach (var attribute in property.Attributes)
|
||||
{
|
||||
var browsable = attribute as BrowsableAttribute;
|
||||
isBrowsable &= browsable == null || browsable.Browsable;
|
||||
}
|
||||
hasBrowsable |= isBrowsable;
|
||||
}
|
||||
return hasBrowsable;
|
||||
}
|
||||
|
||||
public static void Init(this IAudioDecoderSettings settings)
|
||||
{
|
||||
// Iterate through each property and call ResetValue()
|
||||
foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(settings))
|
||||
property.ResetValue(settings);
|
||||
}
|
||||
|
||||
public static IAudioSource Open(this IAudioDecoderSettings settings, string path, Stream IO = null)
|
||||
{
|
||||
return Activator.CreateInstance(settings.DecoderType, settings, path, IO) as IAudioSource;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user