-
Notifications
You must be signed in to change notification settings - Fork 1
/
CSharpSampleFormatter.cs
53 lines (45 loc) · 1.28 KB
/
CSharpSampleFormatter.cs
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
namespace Fydar.Samples.Grammars.CSharp;
/*
public class CSharpSampleFormatter : ISampleFormatter
{
public async IAsyncEnumerable<Sample> FormatAsync(
SampleContent sampleContent,
CancellationToken cancellationToken = default)
{
using var sampleContentStream = sampleContent.Open();
using var streamReader = new StreamReader(sampleContentStream);
yield break;
// var codeBlocks = CSharpSyntax.ToCodeBlocks(sampleContent.Name, await streamReader.ReadToEndAsync());
//
// foreach (var codeBlock in codeBlocks)
// {
// yield return codeBlock;
// }
}
static CSharpSampleFormatter()
{
ForceLoadDependencies();
}
private static void ForceLoadDependencies()
{
var loadedAssemblies = AppDomain.CurrentDomain.GetAssemblies().ToList();
string[] alreadyLoadedPaths = loadedAssemblies.Select(a => a.Location).ToArray();
string[] assemblyPaths = Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory, "*.dll");
foreach (string assemblyPath in assemblyPaths)
{
if (alreadyLoadedPaths.Contains(assemblyPath, StringComparer.InvariantCultureIgnoreCase))
{
continue;
}
try
{
var loaddedAssembly = AppDomain.CurrentDomain.Load(AssemblyName.GetAssemblyName(assemblyPath));
loadedAssemblies.Add(loaddedAssembly);
}
catch
{
}
}
}
}
*/