Method ReadSchema
- Namespace
- YndigoBlue.Velocity.Engine
- Assembly
- YndigoBlue.Velocity.dll
ReadSchema(string, ConfigType)
Reads a schema definition from a string and returns an in-memory Schema object.
public Schema ReadSchema(string contents, ConfigType configType)
Parameters
contentsstringA string containing a Velocity schema definition in the specified format.
configTypeConfigTypeThe format of the configuration (XML, JSON, or YAML).
Returns
Examples
string schemaXml = @"<schema name='myschema'>
<table name='users'>
<column name='id' type='Integer' primaryKey='true' />
<column name='name' type='VarChar' size='100' />
</table>
</schema>";
using (var m = new Manager())
{
var schema = m.ReadSchema(schemaXml, ConfigType.Xml);
Console.WriteLine($"Schema '{schema.Name}' has {schema.Tables.Count} table(s)");
}
Exceptions
- CustomViewCodeCompilationException
Thrown when a custom code-based view does not compile properly.
- ColumnNotFoundException
Thrown if any referenced columns do not exist in tables.
ReadSchema(Stream, ConfigType)
Reads a schema definition from a stream and returns an in-memory Schema object.
public Schema ReadSchema(Stream stream, ConfigType configType)
Parameters
streamStreamA readable stream containing the schema definition.
configTypeConfigTypeThe format of the configuration (XML, JSON, or YAML).
Returns
Examples
using (var fileStream = File.OpenRead("schema.json"))
using (var m = new Manager())
{
var schema = m.ReadSchema(fileStream, ConfigType.Json);
Console.WriteLine($"Loaded schema: {schema.Name}");
}
Exceptions
- CustomViewCodeCompilationException
Thrown when a custom code-based view does not compile properly.
- ColumnNotFoundException
Thrown if any referenced columns do not exist in tables.