/// <summary>
/// Static function to return new instance of EnumSchema
/// </summary>
/// <param name="jtok">JSON object for enum schema</param>
/// <param name="names">list of named schema already parsed in</param>
/// <param name="encspace">enclosing namespace for the enum schema</param>
/// <returns>new instance of enum schema</returns>
internal static EnumSchema NewInstance(JToken jtok, PropertyMap props, SchemaNames names, string encspace)
{
SchemaName name = NamedSchema.GetName(jtok, encspace);
var aliases = NamedSchema.GetAliases(jtok, name.Space, name.EncSpace);
JArray jsymbols = jtok["symbols"] as JArray;
if (null == jsymbols)
{
throw new SchemaParseException("Enum has no symbols: " + name);
}
List <string> symbols = new List <string>();
IDictionary <string, int> symbolMap = new Dictionary <string, int>();
int i = 0;
foreach (JValue jsymbol in jsymbols)
{
string s = (string)jsymbol.Value;
if (symbolMap.ContainsKey(s))
{
throw new SchemaParseException("Duplicate symbol: " + s);
}
symbolMap[s] = i++;
symbols.Add(s);
}
return(new EnumSchema(name, aliases, symbols, symbolMap, props, names,
JsonHelper.GetOptionalString(jtok, "doc")));
}