private static IJsonSchemaDefinition GetJsonSchemaInstance(Type jsonSchemaType) { //Create dataowner instance IJsonSchemaDefinition jsonSchemaInstance = (IJsonSchemaDefinition)Activator.CreateInstance(jsonSchemaType); return(jsonSchemaInstance); }
private static void LoadAllJsonSchemaBuildersAndWriteSchemasToFile(string jsonSchemaApplicationRoot) { if (Directory.Exists(jsonSchemaApplicationRoot)) { Directory.Delete(jsonSchemaApplicationRoot, true); } foreach (Type codeDefinedType in GetInterfaceTypes(typeof(IJsonSchemaDefinition))) { IJsonSchemaDefinition jsonSchema = GetJsonSchemaInstance(codeDefinedType); jsonSchema.WriteSchemaToFile(jsonSchemaApplicationRoot); } }
private static void LoadAllJsonSchemaBuildersAndGenerateCSharpCodeToFile(string applicationRoot, string jsonSchemaApplicationRoot) { if (Directory.Exists(applicationRoot)) { Directory.Delete(applicationRoot, true); } CodeGenerator codeGenerator = new CodeGenerator(applicationRoot, jsonSchemaApplicationRoot); foreach (Type codeDefinedType in GetInterfaceTypes(typeof(IJsonSchemaDefinition))) { IJsonSchemaDefinition jsonSchema = GetJsonSchemaInstance(codeDefinedType); codeGenerator.Register(jsonSchema); } codeGenerator.GenerateToFile(Code.CSharp); }
/// <summary> /// Register all the IJsonSchemaDefinition generated in one go to avoid ordering problems for references /// </summary> /// <param name="jsonSchema"></param> public void Register(IJsonSchemaDefinition jsonSchema) { RegisteredJsonSchemas.Add(jsonSchema.FileName, jsonSchema); }