示例#1
0
 /// <summary>
 /// Constructs a new <see cref="NbtVerifier"/> object for a given NBT tree and schema.
 /// </summary>
 /// <param name="root">A <see cref="TagNode"/> representing the root of an NBT tree.</param>
 /// <param name="schema">A <see cref="SchemaNode"/> representing the root of a schema definition for the NBT tree.</param>
 public NbtVerifier(TagNode root, SchemaNode schema)
 {
     _root = root;
     _schema = schema;
 }
示例#2
0
 /// <summary>
 /// Constructs a new event argument set.
 /// </summary>
 /// <param name="schema">The <see cref="SchemaNode"/> corresponding to the <see cref="TagNode"/> involved in this event.</param>
 /// <param name="tag">The <see cref="TagNode"/> involved in this event.</param>
 public TagEventArgs(SchemaNode schema, TagNode tag)
     : base()
 {
     _tag = tag;
     _schema = schema;
 }
示例#3
0
        private bool Verify(TagNode parent, TagNode tag, SchemaNode schema)
        {
            if (tag == null) {
                return OnMissingTag(new TagEventArgs(schema.Name));
            }

            SchemaNodeScaler scaler = schema as SchemaNodeScaler;
            if (scaler != null) {
                return VerifyScaler(tag, scaler);
            }

            SchemaNodeString str = schema as SchemaNodeString;
            if (str != null) {
                return VerifyString(tag, str);
            }

            SchemaNodeArray array = schema as SchemaNodeArray;
            if (array != null) {
                return VerifyArray(tag, array);
            }

            SchemaNodeIntArray intarray = schema as SchemaNodeIntArray;
            if (intarray != null) {
                return VerifyIntArray(tag, intarray);
            }

            SchemaNodeList list = schema as SchemaNodeList;
            if (list != null) {
                return VerifyList(tag, list);
            }

            SchemaNodeCompound compound = schema as SchemaNodeCompound;
            if (compound != null) {
                return VerifyCompound(tag, compound);
            }

            return OnInvalidTagType(new TagEventArgs(schema.Name, tag));
        }
示例#4
0
 /// <summary>
 /// Constructs a new <see cref="SchemaNodeList"/> with additional options.
 /// </summary>
 /// <param name="name">The name of the corresponding <see cref="TagNodeList"/>.</param>
 /// <param name="type">The type of items contained in the corresponding <see cref="TagNodeList"/>.</param>
 /// <param name="subschema">A <see cref="SchemaNode"/> representing a schema to verify against items contained in the corresponding <see cref="TagNodeList"/>.</param>
 /// <param name="options">One or more option flags modifying the processing of this node.</param>
 public SchemaNodeList(string name, TagType type, SchemaNode subschema, SchemaOptions options)
     : base(name, options)
 {
     _type = type;
     _subschema = subschema;
 }
示例#5
0
 /// <summary>
 /// Constructs a new <see cref="SchemaNodeList"/> representing a <see cref="TagNodeList"/> named <paramref name="name"/> containing items of type <paramref name="type"/> matching the given schema.
 /// </summary>
 /// <param name="name">The name of the corresponding <see cref="TagNodeList"/>.</param>
 /// <param name="type">The type of items contained in the corresponding <see cref="TagNodeList"/>.</param>
 /// <param name="subschema">A <see cref="SchemaNode"/> representing a schema to verify against items contained in the corresponding <see cref="TagNodeList"/>.</param>
 public SchemaNodeList(string name, TagType type, SchemaNode subschema)
     : base(name)
 {
     _type = type;
     _subschema = subschema;
 }
示例#6
0
 /// <summary>
 /// Constructs a new <see cref="SchemaNodeList"/> representing a <see cref="TagNodeList"/> named <paramref name="name"/> containing <paramref name="length"/> items of type <paramref name="type"/> matching the given schema.
 /// </summary>
 /// <param name="name">The name of the corresponding <see cref="TagNodeList"/>.</param>
 /// <param name="type">The type of items contained in the corresponding <see cref="TagNodeList"/>.</param>
 /// <param name="length">The number of items contained in the corresponding <see cref="TagNodeList"/>.</param>
 /// <param name="subschema">A <see cref="SchemaNode"/> representing a schema to verify against items contained in the corresponding <see cref="TagNodeList"/>.</param>
 public SchemaNodeList(string name, TagType type, int length, SchemaNode subschema)
     : base(name)
 {
     _type = type;
     _length = length;
     _subschema = subschema;
 }