in src/Json.Schema.ToDotNet.Cli/Program.cs [27:98]
private static int Run(Options options)
{
int exitCode = 1;
try
{
string jsonText = File.ReadAllText(options.SchemaFilePath);
JsonSchema schema = SchemaReader.ReadSchema(jsonText, options.SchemaFilePath);
HintDictionary hintDictionary = null;
if (options.CodeGenHintsPath != null)
{
if (!File.Exists(options.CodeGenHintsPath))
{
throw new ArgumentException(
string.Format(
CultureInfo.CurrentCulture,
Resources.ErrorHintsFileNotFound,
options.CodeGenHintsPath));
}
string hintDictionaryText = File.ReadAllText(options.CodeGenHintsPath);
hintDictionary = new HintDictionary(hintDictionaryText, options.TypeNameSuffix);
}
string copyrightNotice = null;
if (options.CopyrightFilePath != null)
{
if (!File.Exists(options.CopyrightFilePath))
{
throw new ArgumentException(
string.Format(
CultureInfo.CurrentCulture,
Resources.ErrorCopyrightFileNotFound,
options.CopyrightFilePath));
}
copyrightNotice = File.ReadAllText(options.CopyrightFilePath);
}
DataModelGeneratorSettings settings = new DataModelGeneratorSettings
{
OutputDirectory = options.OutputDirectory,
TypeNameSuffix = options.TypeNameSuffix,
ForceOverwrite = options.ForceOverwrite,
NamespaceName = options.NamespaceName,
RootClassName = options.RootClassName,
SchemaName = options.SchemaName,
CopyrightNotice = copyrightNotice,
HintDictionary = hintDictionary,
GenerateEqualityComparers = options.GenerateEqualityComparers,
GenerateCloningCode = options.GenerateCloningCode,
SealClasses = options.SealClasses,
VirtualMembers = options.VirtualMembers,
ProtectedInitMethods = options.ProtectedInitMethods
};
new DataModelGenerator(settings).Generate(schema);
exitCode = 0;
}
catch (Exception ex)
{
Console.Error.WriteLine(
string.Format(
CultureInfo.CurrentCulture,
Resources.Error,
ex.Message));
}
return exitCode;
}