Beispiel #1
0
        private Tlv CreateTlv(BinaryReader reader, TlvType type, int identifier, int length)
        {
            Tlv result;

            byte[] value = reader.ReadBytes(length);

            if (type == TlvType.OBJECT_INSTANCE || type == TlvType.MULTIPLE_RESOURCE)
            {
                Tlv[] children = Parse(value);

                result = new Tlv(type, identifier, children, null);
            }
            else
            {
                result = new Tlv(type, identifier, null, value);
            }

            return(result);
        }
Beispiel #2
0
        public override bool Equals(object obj)
        {
            if (obj == null || GetType() != obj.GetType())
            {
                return(false);
            }

            Tlv tlv = (Tlv)obj;

            if (type != tlv.type || identifier != tlv.identifier)
            {
                return(false);
            }

            if (children != null)
            {
                if (children.Length != tlv.children.Length)
                {
                    return(false);
                }

                if (!Enumerable.SequenceEqual(children, tlv.children))
                {
                    return(false);
                }
            }

            if (value != null)
            {
                if (!value.SequenceEqual(tlv.value))
                {
                    return(false);
                }
            }

            return(true);
        }