예제 #1
0
        /// <summary>
        /// Updates this schema so it can no longer generate a given problem when compared to another schema.
        /// </summary>
        /// <param name="problem">The change problem</param>
        public void ResolveProblem(ChangeProblem problem)
        {
            switch (problem.ProblemType)
            {
                case ChangeProblemType.DeletionNeeded:
                    // Remove the problem for which deletion was needed
                    TypeProperties.Remove(problem.TypeName);
                    break;
                case ChangeProblemType.PropertyDropped:
                case ChangeProblemType.PropertyDroppedFromSummary:
                    // Remove the property which was dropped
                    TypeProperties[problem.TypeName].Remove(problem.PropertyName);
                    break;

                // Problems not requiring data modification
                case ChangeProblemType.NotBinarySerializable:
                case ChangeProblemType.NullObjectValue:
                    break;
            }
        }
예제 #2
0
        /// <summary>
        /// Reverts part of the schema relevant to a problem to the state which when compared to its current
        /// state, regenerates the problem. The inverse of ResolveProblem.
        /// </summary>
        /// <param name="oldSchema">the old schema which generated the problem when compared to the current schema</param>
        /// <param name="problem">the problem it generated</param>
        public void ApplyProblem(ContentModelSchema oldSchema, ChangeProblem problem)
        {
            switch (problem.ProblemType)
            {
                case ChangeProblemType.DeletionNeeded:
                    // copy the deleted type to the new schema
                    TypeProperties.Add(problem.TypeName, oldSchema.TypeProperties[problem.TypeName]);
                    break;
                case ChangeProblemType.PropertyDropped:
                case ChangeProblemType.PropertyDroppedFromSummary:
                    // copy the dropped property to the new schema
                    TypeProperties[problem.TypeName].Add(problem.PropertyName, oldSchema.TypeProperties[problem.TypeName][problem.PropertyName]);
                    break;

                // Problems not requiring data modification
                case ChangeProblemType.NotBinarySerializable:
                case ChangeProblemType.NullObjectValue:
                    break;
            }
        }