示例#1
0
        private static IJsonSchemaDefinition GetJsonSchemaInstance(Type jsonSchemaType)
        {
            //Create dataowner instance
            IJsonSchemaDefinition jsonSchemaInstance = (IJsonSchemaDefinition)Activator.CreateInstance(jsonSchemaType);

            return(jsonSchemaInstance);
        }
示例#2
0
 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);
     }
 }
示例#3
0
        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);
        }
示例#4
0
 /// <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);
 }