Exemplo n.º 1
0
        private static void Compare(BethesdaRecord first, BethesdaRecord second, StringBuilder sb, int indentLevel)
        {
            if (Compare(first.RawData, second.RawData) == 0)
            {
                return;
            }

            sb.Append(Indent(indentLevel++)).AppendLine(first.ToString());

            string indent = Indent(indentLevel);

            CompareHeaders(new ArraySegment <byte>(first.Start.Array, first.Start.Offset, 24), new ArraySegment <byte>(second.Start.Array, second.Start.Offset, 24), sb, indentLevel);

            // stable sort is probably important enough to be worth a speed cost.
            List <BethesdaField> firstFields  = first.Fields.OrderBy(f => f.FieldType).ThenBy(f => f.Payload, PayloadComparer).ToList();
            List <BethesdaField> secondFields = second.Fields.OrderBy(f => f.FieldType).ThenBy(f => f.Payload, PayloadComparer).ToList();

            int i = 0, j = 0;

            while (i < firstFields.Count || j < secondFields.Count)
            {
                if (j == secondFields.Count || (i != firstFields.Count && firstFields[i].FieldType < secondFields[j].FieldType))
                {
                    sb.Append(indent).AppendLine("OnlyL: " + firstFields[i++]);
                }
                else if (i == firstFields.Count || (j != secondFields.Count && secondFields[j].FieldType < firstFields[i].FieldType))
                {
                    sb.Append(indent).AppendLine("OnlyR: " + secondFields[j++]);
                }
                else
                {
                    Compare(firstFields[i++], secondFields[j++], sb, indentLevel);
                }
            }
        }
Exemplo n.º 2
0
        private static int MetaCompare(BethesdaRecord r1, BethesdaRecord r2)
        {
            int cmp = r1.RecordType.CompareTo(r2.RecordType);

            return(cmp == 0
                ? r1.Id.CompareTo(r2.Id)
                : cmp);
        }