internal static TemplateToken Read( TemplateContext context, String type, IObjectReader objectReader, Int32?fileId, TemplateSchema schema, out Int32 bytes) { TemplateToken result = null; var reader = new TemplateReader(context, schema, objectReader, fileId); var originalBytes = context.Memory.CurrentBytes; try { objectReader.ValidateStart(); var definition = new DefinitionInfo(schema, type); result = reader.ReadValue(definition); objectReader.ValidateEnd(); } catch (Exception ex) { context.Error(fileId, null, null, ex); } finally { bytes = context.Memory.CurrentBytes - originalBytes; } return(result); }