remove unneeded reflection schema stuff (for now)

This commit is contained in:
Collin M. Barrett 2017-10-24 16:02:50 -05:00
parent 27f486bb78
commit 5b41465266

View file

@ -1,8 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using FilterLists.Data.Models.Implementations;
using Newtonsoft.Json.Schema.Generation;
@ -12,24 +9,14 @@ public static class JsonSchemaGenerator
{
public static void WriteSchemaToFiles()
{
foreach (var type in GetTypesInNamespace(Assembly.GetExecutingAssembly(),
"FilterLists.Data.Models.Implementations"))
{
if (type != typeof(List)) continue; //TEMP: only document List schema for now
WriteSchemaToFile(type);
}
WriteSchemaToFile(typeof(List));
}
private static void WriteSchemaToFile(Type type)
{
File.WriteAllText(
Path.GetFullPath(Path.Combine(AppContext.BaseDirectory + @"\", @"..\..\..\..\..\data\")) +
type.Name + "Schema.json", new JSchemaGenerator().Generate(type).ToString());
}
private static IEnumerable<Type> GetTypesInNamespace(Assembly assembly, string @namespace)
{
return assembly.GetTypes().Where(t => string.Equals(t.Namespace, @namespace, StringComparison.Ordinal));
Path.GetFullPath(Path.Combine(AppContext.BaseDirectory + @"\", @"..\..\..\..\..\data\")) + type.Name +
"Schema.json", new JSchemaGenerator().Generate(type).ToString());
}
}
}