本文整理汇总了C#中PurplePen.EventDB.RemoveSpecial方法的典型用法代码示例。如果您正苦于以下问题:C# EventDB.RemoveSpecial方法的具体用法?C# EventDB.RemoveSpecial怎么用?C# EventDB.RemoveSpecial使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PurplePen.EventDB
的用法示例。
在下文中一共展示了EventDB.RemoveSpecial方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateDescriptionCourses
// Check all descriptions other than the passed one, and remove any duplicate courses.
public static void UpdateDescriptionCourses(EventDB eventDB, Id<Special> descriptionId)
{
// Which courses to remove?
CourseDesignator[] coursesToRemove = QueryEvent.GetSpecialDisplayedCourses(eventDB, descriptionId);
// Find all descriptions to change.
List<Id<Special>> allDescriptionIds = new List<Id<Special>>();
foreach (Id<Special> specialId in eventDB.AllSpecialIds) {
if (eventDB.GetSpecial(specialId).kind == SpecialKind.Descriptions && specialId != descriptionId)
allDescriptionIds.Add(specialId);
}
foreach (Id<Special> descriptionToChange in allDescriptionIds) {
// Remove any courses that overlap with the courses the given description has..
bool changes = false; // track if any changes made.
List<CourseDesignator> courses = new List<CourseDesignator>(QueryEvent.GetSpecialDisplayedCourses(eventDB, descriptionToChange));
for (int courseIndex = 0; courseIndex < courses.Count; ++courseIndex) {
foreach (CourseDesignator courseToRemove in coursesToRemove) {
if (courseIndex >= 0 && courseIndex < courses.Count) {
if (courseToRemove == courses[courseIndex]) {
changes = true;
courses.RemoveAt(courseIndex--);
}
else if (courseToRemove.CourseId == courses[courseIndex].CourseId) {
changes = true;
if (!courseToRemove.AllParts && courses[courseIndex].AllParts) {
int removedPart = courseToRemove.Part;
courses.RemoveAt(courseIndex--);
for (int part = 0; part < QueryEvent.CountCourseParts(eventDB, courseToRemove.CourseId); ++part) {
if (part != removedPart)
courses.Add(new CourseDesignator(courseToRemove.CourseId, part));
}
}
else if (courseToRemove.AllParts) {
courses.RemoveAt(courseIndex--);
}
}
}
}
}
// Commit the removal to the event database.
if (changes) {
if (courses.Count == 0) {
// Remove the given description entire, since it has no displayed courses.
eventDB.RemoveSpecial(descriptionToChange);
}
else {
Special newDescription = (Special) eventDB.GetSpecial(descriptionToChange).Clone();
newDescription.allCourses = false;
newDescription.courses = courses.ToArray();
eventDB.ReplaceSpecial(descriptionToChange, newDescription);
}
}
}
}
示例2: DeleteSpecial
// Delete a special
public static void DeleteSpecial(EventDB eventDB, Id<Special> specialId)
{
eventDB.RemoveSpecial(specialId);
}