Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        public override string ToString()
        {
            StringBuilder strBuilder = new StringBuilder();

            strBuilder.Append("   Field: ");
            strBuilder.Append(Name);
            strBuilder.Append(", ");
            strBuilder.Append(Type);
            strBuilder.Append(", ");
            strBuilder.Append(Unit.ToString());


            if (SubSchema != null)
            {
                strBuilder.Append(Environment.NewLine + "   " + SubSchema.ToString());
            }
            return(strBuilder.ToString());
        }