Matroska-Solution / MediaContainers.Matroska / EBML / EBMLDocTypeLookup.cs
Code · 23 lines · 586 bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23using System;
using System.Collections.Generic;

namespace MediaContainers;

public static class EBMLDocTypeLookup
{
	private static readonly List<Func<EBMLHeader, EBMLReader, bool>> handlers = new List<Func<EBMLHeader, EBMLReader, bool>>();

	public static void AddEBMLDocType(Func<EBMLHeader, EBMLReader, bool> handler)
	{
		lock (handlers) { handlers.Add(handler); }
	}

	public static bool HandleEBMLDocType(EBMLHeader header, EBMLReader reader)
	{
		for (int i = handlers.Count - 1; i >= 0; i--)
		{
			if (handlers[i](header, reader)) { return true; }
		}
		return false;
	}
}