GetRequiredInteger() public static method

public static GetRequiredInteger ( JToken j, string field ) : int
j JToken
field string
return int
Beispiel #1
0
        /// <summary>
        /// Static function to return new instance of the fixed schema class
        /// </summary>
        /// <param name="jtok">JSON object for the fixed schema</param>
        /// <param name="names">list of named schema already parsed in</param>
        /// <param name="encspace">enclosing namespace of the fixed schema</param>
        /// <returns></returns>
        internal static FixedSchema NewInstance(JToken jtok, PropertyMap props, SchemaNames names, string encspace)
        {
            SchemaName name    = NamedSchema.GetName(jtok, encspace);
            var        aliases = NamedSchema.GetAliases(jtok, name.Space, name.EncSpace);

            return(new FixedSchema(name, aliases, JsonHelper.GetRequiredInteger(jtok, "size"), props, names));
        }
Beispiel #2
0
        /// <summary>
        /// Static function to return new instance of the fixed schema class
        /// </summary>
        /// <param name="jtok">JSON object for the fixed schema</param>
        /// <param name="props">dictionary that provides access to custom properties</param>
        /// <param name="names">list of named schema already parsed in</param>
        /// <param name="encspace">enclosing namespace of the fixed schema</param>
        /// <returns></returns>
        internal static FixedSchema NewInstance(JToken jtok, PropertyMap props, SchemaNames names, string encspace)
        {
            SchemaName name    = NamedSchema.GetName(jtok, encspace);
            var        aliases = NamedSchema.GetAliases(jtok, name.Space, name.EncSpace);

            try
            {
                return(new FixedSchema(name, aliases, JsonHelper.GetRequiredInteger(jtok, "size"), props, names,
                                       JsonHelper.GetOptionalString(jtok, "doc")));
            }
            catch (Exception e)
            {
                throw new SchemaParseException($"{e.Message} at '{jtok.Path}'", e);
            }
        }