-
-
Notifications
You must be signed in to change notification settings - Fork 39
Modifications List
Luke edited this page May 29, 2017
·
6 revisions
| Info | Count |
|---|---|
| Total modifications in OTAPI v2 | 137 |
void Main()
{
var patcher = new CustomPatcher();
var modifications = patcher.ModificationAssemblies
.Select(x => new { AssemblyPath = x, Assembly = Assembly.LoadFile(x), CommentsPath = Path.ChangeExtension(x, "xml") })
.Select(x => new
{
Assembly = x.Assembly,
Reader = File.Exists(x.CommentsPath) ? new XmlDocCommentReader(Path.ChangeExtension(x.AssemblyPath, "xml")) : null,
Modifications = GetTypesLoaded(x.Assembly).Where(t => typeof(OTAPI.Patcher.Engine.Modification.ModificationBase).IsAssignableFrom(t))
});
(
"## Modification\n" +
"Modification | Description\n" +
"---- | -----------\n" +
String.Join("\n", modifications
.SelectMany(x => x.Modifications.Select(y => new {
Assembly = x.Assembly.GetName().Name,
Modification = y,
Reader = x.Reader
}))
.OrderBy(x => x.Assembly + '/' + x.Modification.Name)
.Select(x => $"[{x.Assembly + '/' + x.Modification.Name}](https://github.com/DeathCradle/Open-Terraria-API/tree/master/OTAPI.Modifications/{x.Assembly})" + " | " + String.Join("<br/>", x.Reader?
.GetComments(x.Modification)?
.Value?
.Trim()
.Split(new [] {'\n'}, StringSplitOptions.RemoveEmptyEntries)
.Select(l => l.Trim())
?? new string[] {}
)
)
.Distinct()
)
+ "\n\n## Stats\n" +
(
"Info | Count\n" +
"---- | -----------\n" +
"Total modifications in OTAPI v2 | " + modifications.Count()
)
+ "\n\n### Page generated using LINQPad 5 + Jolt + App.Config\n```C#\n```"
)
.Dump()
;
}
public static Type[] GetTypesLoaded(System.Reflection.Assembly assembly)
{
try
{
return assembly.GetTypes();
}
catch (System.Reflection.ReflectionTypeLoadException e)
{
return e.Types.Where(t => t != null).ToArray();
}
}
class CustomPatcher : OTAPI.Patcher.Engine.Patcher
{
const String OTAPI_BASE = "C:/Backup/Git/Open-Terraria-API/";
public CustomPatcher()
: base(
$"{OTAPI_BASE}wrap/TerrariaServer/TerrariaServer.exe",
new[] {$"{OTAPI_BASE}OTAPI.Modifications/OTAPI.**/bin/Debug/OTAPI.Modification**.dll"},
$"{OTAPI_BASE}OTAPI.dll"
)
{
Assembly.LoadFile(this.SourceAssemblyPath);
}
public IEnumerable<string> ModificationAssemblies => this.GlobModificationAssemblies();
}