/// <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) { string aqTypeName = problem.GetAssemblyQualifiedTypeName(); switch (problem.ProblemType) { case ChangeProblemType.DeletionNeeded: // copy the deleted type to the new schema TypeProperties.Add(aqTypeName, oldSchema.TypeProperties[aqTypeName]); break; case ChangeProblemType.PropertyDropped: // copy the dropped property to the new schema TypeProperties[aqTypeName].Add(problem.PropertyName, oldSchema.TypeProperties[aqTypeName][problem.PropertyName]); break; case ChangeProblemType.PropertyDroppedFromSummary: Type contentType = ContentTypeHierarchy.GetContentType(problem.TypeName); string aqSummaryTypeName = ContentTypeHierarchy.SummaryTypes[contentType].AssemblyQualifiedName; TypeProperties[aqTypeName].Add(problem.PropertyName, oldSchema.TypeProperties[aqTypeName][problem.PropertyName]); TypeProperties[aqSummaryTypeName].Add(problem.PropertyName, oldSchema.TypeProperties[aqSummaryTypeName][problem.PropertyName]); break; // Problems not requiring data modification case ChangeProblemType.NullObjectValue: break; } }
/// <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) { string aqTypeName = problem.GetAssemblyQualifiedTypeName(); switch (problem.ProblemType) { case ChangeProblemType.DeletionNeeded: // Remove the problem for which deletion was needed TypeProperties.Remove(aqTypeName); break; case ChangeProblemType.PropertyDropped: case ChangeProblemType.PropertyDroppedFromSummary: // Remove the property which was dropped TypeProperties[aqTypeName].Remove(problem.PropertyName); break; // Problems not requiring data modification case ChangeProblemType.NullObjectValue: break; } }