Пример #1
0
        public override bool Verify(NbtVerifier verifier, TagNode tag)
        {
            TagNodeString stag = tag as TagNodeString;

            if (stag == null)
            {
                if (!verifier.OnInvalidTagType(new TagEventArgs(this, tag)))
                {
                    return(false);
                }
            }
            if (Length > 0 && stag.Length > Length)
            {
                if (!verifier.OnInvalidTagValue(new TagEventArgs(this, tag)))
                {
                    return(false);
                }
            }
            if (Value != null && stag.Data != Value)
            {
                if (!verifier.OnInvalidTagValue(new TagEventArgs(this, tag)))
                {
                    return(false);
                }
            }

            return(true);
        }
Пример #2
0
        public override bool Verify(NbtVerifier verifier, TagNode tag)
        {
            if (!tag.IsCastableTo(Type))
            {
                if (!verifier.OnInvalidTagType(new TagEventArgs(Name, tag)))
                {
                    return(false);
                }
            }

            return(true);
        }
Пример #3
0
        public override bool Verify(NbtVerifier verifier, TagNode tag)
        {
            TagNodeCompound ctag = tag as TagNodeCompound;

            if (ctag == null)
            {
                if (!verifier.OnInvalidTagType(new TagEventArgs(this, tag)))
                {
                    return(false);
                }
            }

            bool pass = true;

            Dictionary <string, TagNode> _scratch = new Dictionary <string, TagNode>();

            foreach (SchemaNode node in this)
            {
                TagNode value;
                ctag.TryGetValue(node.Name, out value);

                if (value == null)
                {
                    if ((node.Options & SchemaOptions.CREATE_ON_MISSING) == SchemaOptions.CREATE_ON_MISSING)
                    {
                        _scratch[node.Name] = node.BuildDefaultTree();
                        continue;
                    }
                    else if ((node.Options & SchemaOptions.OPTIONAL) == SchemaOptions.OPTIONAL)
                    {
                        continue;
                    }
                }

                pass = node.Verify(verifier, value) && pass;
            }

            foreach (KeyValuePair <string, TagNode> item in _scratch)
            {
                ctag[item.Key] = item.Value;
            }

            _scratch.Clear();

            return(pass);
        }
Пример #4
0
        public override bool Verify(NbtVerifier verifier, TagNode tag)
        {
            TagNodeList ltag = tag as TagNodeList;

            if (ltag == null)
            {
                if (!verifier.OnInvalidTagType(new TagEventArgs(this, tag)))
                {
                    return(false);
                }
            }
            if (ltag.Count > 0 && ltag.ValueType != Type)
            {
                if (!verifier.OnInvalidTagValue(new TagEventArgs(this, tag)))
                {
                    return(false);
                }
            }
            if (Length > 0 && ltag.Count != Length)
            {
                if (!verifier.OnInvalidTagValue(new TagEventArgs(this, tag)))
                {
                    return(false);
                }
            }

            // Patch up empty lists
            //if (schema.Length == 0) {
            //    tag = new NBT_List(schema.Type);
            //}

            bool pass = true;

            // If a subschema is set, test all items in list against it

            if (SubSchema != null)
            {
                foreach (TagNode v in ltag)
                {
                    pass = SubSchema.Verify(verifier, v) && pass;
                }
            }

            return(pass);
        }
Пример #5
0
        public override bool Verify(NbtVerifier verifier, TagNode tag)
        {
            TagNodeShortArray atag = tag as TagNodeShortArray;

            if (atag == null)
            {
                if (!verifier.OnInvalidTagType(new TagEventArgs(this, tag)))
                {
                    return(false);
                }
            }
            if (Length > 0 && atag.Length != Length)
            {
                if (!verifier.OnInvalidTagValue(new TagEventArgs(this, tag)))
                {
                    return(false);
                }
            }

            return(true);
        }
Пример #6
0
 public virtual bool Verify(NbtVerifier verifier, TagNode tag)
 {
     return(verifier.OnInvalidTagType(new TagEventArgs(Name, tag)));
 }