예제 #1
0
        /// <summary>Indicates whether the current object is equal to another object of the same type.</summary>
        /// <param name="other">An object to compare with this object.</param>
        /// <returns>
        ///     <see langword="true" /> if the current object is equal to the <paramref name="other" /> parameter; otherwise,
        ///     <see langword="false" />.
        /// </returns>
        public bool Equals(PartAddress other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            if (other._lst.Count != _lst.Count)
            {
                return(false);
            }

            for (var i = 0; i < _lst.Count; i++)
            {
                if (_lst[i] != other[i])
                {
                    return(false);
                }
            }

            return(true);
        }
예제 #2
0
        public static BodyPartRecord GetRecordAt([NotNull] this BodyDef bodyDef, [NotNull] PartAddress address)
        {
            if (bodyDef == null)
            {
                throw new ArgumentNullException(nameof(bodyDef));
            }
            if (address == null)
            {
                throw new ArgumentNullException(nameof(address));
            }

            if (address.Count == 0)
            {
                return(null);
            }
            BodyPartRecord curRecord = bodyDef.corePart;

            if (curRecord.Label != address[0])
            {
                return(null);
            }

            for (var i = 1; i < address.Count; i++)
            {
                curRecord = curRecord.parts.MakeSafe().FirstOrDefault(p => p.Label == address[i]);
                if (curRecord == null)
                {
                    break;
                }
            }

            return(curRecord);
        }
예제 #3
0
        public static PartAddress Parse(string str)
        {
            if (_internDict.TryGetValue(str, out PartAddress addr))
            {
                return(addr);
            }

            addr             = new PartAddress(str.Split('.'));
            _internDict[str] = addr;
            return(addr);
        }