-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathProgram.cs
More file actions
64 lines (58 loc) · 1.92 KB
/
Copy pathProgram.cs
File metadata and controls
64 lines (58 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using System;
using System.IO;
using System.Linq;
using FFmpeg.AutoGen;
namespace FFmpeg.Sharp.Example
{
internal class Program
{
private static void Main(string[] args)
{
ffmpeg.RootPath = Path.Combine(AppContext.BaseDirectory, "runtimes\\win-x64\\native");
try
{
typeof(Program).Assembly
.GetTypes()
.Where(t => t.IsSubclassOf(typeof(ExampleBase)) && !t.IsAbstract)
.Select(t => (ExampleBase)Activator.CreateInstance(t))
.Where(e => e.Enable)
.OrderBy(e => e.Index)
.ToList()
.ForEach(e =>
{
var name = e.GetType().Name;
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine($"=== {name} ===");
Console.ResetColor();
try { e.Execute(); }
catch (Exception ex)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine($"[{name}] FAILED: {ex.Message}");
Console.ResetColor();
}
});
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
Console.WriteLine(ex.StackTrace);
}
#if RELEASE
Console.WriteLine("Press Enter to exit");
Console.ReadLine();
#endif
}
}
public abstract class ExampleBase
{
protected string[] args = [];
public ExampleBase(params string[] args)
{
this.args = args;
}
public int Index { get; protected set; }
public bool Enable { get; protected set; } = true;
public abstract void Execute();
}
}