Avro.NamedSchema.GetName C# (CSharp) Method

GetName() protected static method

protected static GetName ( JToken j ) : Name
j JToken
return Name
        protected static Name GetName(JToken j)
        {
            String n = JsonHelper.GetRequiredString(j, "name");
            String ns = JsonHelper.GetOptionalString(j, "namespace");
            return new Name(n, ns);
        }

Same methods

NamedSchema::GetName ( ) : string

Usage Example

Example #1
0
        /// <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")));
        }
All Usage Examples Of Avro.NamedSchema::GetName