Example #1
0
        /// <summary>
        /// Verifies the branching properties (CloneOf, ContinuationOf, ReplaceWith), logging any problems it finds.
        /// </summary>
        ///
        /// <param name="extendedReporting">If <c>true</c>, do more extensive verification.</param>
        /// <param name="log">The log to append.</param>
        ///
        /// <returns>Returns <c>true</c> if problems found, otherwise <c>false</c>.</returns>
        internal bool VerifyBranchProperties(bool extendedReporting, ref StringBuilder log)
        {
            bool problems = false;

            if (CloneOf != 0u && ContinuationOf != 0u)
            {
                problems = true;
                log.Append("- Can be CloneOf or ContinuationOf, not both\n");
            }

            if (CloneOf != 0uL && IsCompatibleWith(CloneOf))
            {
                problems = true;
                log.AppendFormat(
                    "- Must be incompatible with CloneOf item: {0}uL\n",
                    CloneOf);
            }

            if (ContinuationOf != 0uL && IsCompatibleWith(ContinuationOf))
            {
                problems = true;
                log.AppendFormat(
                    "- Must be incompatible with ContinuationOf item: {0}uL\n",
                    ContinuationOf);
            }

            if (CloneOf == WorkshopId || ContinuationOf == WorkshopId)
            {
                problems = true;
                log.Append("- Must not be a CloneOf/ContinuationOf of itself!\n");
            }
            else if (CloneOf > WorkshopId || ContinuationOf > WorkshopId)
            {
                problems = true;
                log.Append("- Must not be CloneOf/ContinuationOf a newer item!\n");
            }

            if (ReplaceWith == WorkshopId)
            {
                problems = true;
                log.Append("- Must not ReplaceWith itself!\n");
            }
            else if (ReplaceWith != 0u)
            {
                if (extendedReporting && IsCompatibleWith(ReplaceWith))
                {
                    problems = true;
                    log.AppendFormat(
                        "- Should (usually) be incompatible with replacement item: {0}uL\n",
                        ReplaceWith);
                }
                else if (Compatibility != null && !Compatibility.ContainsKey(ReplaceWith))
                {
                    problems = true;
                    log.AppendFormat(
                        "- Must specify (in)compatibility with replacement item: {0}uL\n",
                        ReplaceWith);
                }
            }
            else if (HasFlag(ItemFlags.ForceMigration))
            {
                problems = true;
                log.Append("- ReplaceWith missing\n");
            }

            return(problems);
        }