public void BasicOperationTest() { var r = new JsonSchemaRegistory(); Assert.Null(r.Resolve("=TEST=")); Assert.That(r.GetRegisteredIDs(), Is.EquivalentTo(new string[] { })); var s = new JsonSchemaAttribute(); r.Register("a", s); Assert.That(r.Resolve("a"), Is.EqualTo(s)); Assert.That(r.GetRegisteredIDs(), Is.EquivalentTo(new string[] { "a" })); }
static void Main(string[] args) { VVrm.ExtensionRegistrator.Register(); // Create all JsonSchemas related to VRM from the root class. var reg = new JsonSchemaRegistory(); var _schama = JsonSchemaAttribute.CreateFromClass <VVrm.V0_x.Types.Vrm>(reg); if (args.Length != 1) { Console.Error.WriteLine("Error: Not enough arguments."); ShowUsage(); System.Environment.Exit(1); } var outDir = args[0]; if (!Directory.Exists(outDir)) { Console.Error.WriteLine("Error: Directory not exists: Path = " + outDir); ShowUsage(); System.Environment.Exit(1); } var indent = 4; var s = new JsonSerializer(typeof(JsonSchemaAttribute)); foreach (var id in reg.GetRegisteredIDs()) { var schema = reg.Resolve(id); if (string.IsNullOrEmpty(schema.Title)) { Console.Error.WriteLine("Schemas of VRM must have title: Id = " + id); continue; } var fileName = string.Format("{0}.schema.json", schema.Title); var path = Path.Combine(outDir, fileName); using (var fs = new FileStream(path, FileMode.Create, FileAccess.Write)) { s.Serialize(fs, schema, indent); } } }