示例#1
0
            public override int Compare(ComparePart other)
            {
                if (other == null)
                {
                    throw new ArgumentNullException(paramName: "other");
                }
                StringComparePart scp = other as StringComparePart;

                if (scp == null)
                {
                    return(Part.CompareTo(((IntComparePart)other).Part.ToString()));
                }
                else
                {
                    return(Part.CompareTo(scp.Part));
                }
            }
示例#2
0
        private List <ComparePart> GetCompareParts(string txt)
        {
            var parts = new List <ComparePart>();

            if (txt == null)
            {
                throw new ArgumentNullException(paramName: "txt");
            }
            if (txt == string.Empty)
            {
                parts.Add(new StringComparePart(""));
                return(parts);
            }

            var topArr = txt.ToArray();

            ComparePart fcp = new StringComparePart("");
            var         cp  = fcp.AddOrNewPart(topArr[0]);

            if (cp == null)
            {
                cp = fcp;
            }
            parts.Add(cp);

            for (int i = 1; i < topArr.Length; i++)
            {
                var cp2 = cp.AddOrNewPart(topArr[i]);
                if (cp2 != null)
                {
                    parts.Add(cp2);
                    cp = cp2;
                }
            }
            return(parts);
        }