mirror of
https://github.com/claunia/cuetools.net.git
synced 2025-12-16 10:04:24 +00:00
55 lines
1.7 KiB
C#
55 lines
1.7 KiB
C#
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;
|
|
}
|
|
}
|
|
}
|