コード例 #1
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));
            }

            SchemaNodeShortArray shortarray = schema as SchemaNodeShortArray;

            if (shortarray != null)
            {
                return(VerifyShortArray(tag, shortarray));
            }

            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)));
        }
コード例 #2
0
        private bool VerifyShortArray(TagNode tag, SchemaNodeShortArray schema)
        {
            TagNodeShortArray atag = tag as TagNodeShortArray;

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

            return(true);
        }
コード例 #3
0
ファイル: NbtVerifier.cs プロジェクト: tofurama3000/Substrate
        private bool VerifyShortArray (TagNode tag, SchemaNodeShortArray schema)
        {
            TagNodeShortArray atag = tag as TagNodeShortArray;
            if (atag == null) {
                if (!OnInvalidTagType(new TagEventArgs(schema, tag))) {
                    return false;
                }
            }
            if (schema.Length > 0 && atag.Length != schema.Length) {
                if (!OnInvalidTagValue(new TagEventArgs(schema, tag))) {
                    return false;
                }
            }

            return true;
        }