mirror of
https://github.com/claunia/cuetools.net.git
synced 2025-12-16 18:14:25 +00:00
Code cleanup: some lowlevel codec infrastructure moved
from CUETools.Processor to CUETools.Codecs
This commit is contained in:
51
CUETools.Codecs/CUEToolsUDCList.cs
Normal file
51
CUETools.Codecs/CUEToolsUDCList.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace CUETools.Codecs
|
||||
{
|
||||
public class CUEToolsUDCList : BindingList<CUEToolsUDC>
|
||||
{
|
||||
bool m_encoder;
|
||||
|
||||
public CUEToolsUDCList(bool encoder)
|
||||
: base()
|
||||
{
|
||||
AddingNew += OnAddingNew;
|
||||
m_encoder = encoder;
|
||||
}
|
||||
|
||||
private void OnAddingNew(object sender, AddingNewEventArgs e)
|
||||
{
|
||||
e.NewObject = m_encoder ?
|
||||
new CUEToolsUDC("new", "wav", true, "", "", "", "") :
|
||||
new CUEToolsUDC("new", "wav", "", "");
|
||||
}
|
||||
|
||||
public bool TryGetValue(string extension, bool lossless, string name, out CUEToolsUDC result)
|
||||
{
|
||||
foreach (CUEToolsUDC udc in this)
|
||||
{
|
||||
if (udc.extension == extension && udc.lossless == lossless && udc.name == name)
|
||||
{
|
||||
result = udc;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
result = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
public CUEToolsUDC GetDefault(string extension, bool lossless)
|
||||
{
|
||||
CUEToolsUDC result = null;
|
||||
foreach (CUEToolsUDC udc in this)
|
||||
{
|
||||
if (udc.extension == extension && udc.lossless == lossless && (result == null || result.priority < udc.priority))
|
||||
{
|
||||
result = udc;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user