当前位置: 首页>>代码示例>>C#>>正文


C# EventDB.RemoveSpecial方法代码示例

本文整理汇总了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);
                    }
                }
            }
        }
开发者ID:petergolde,项目名称:PurplePen,代码行数:57,代码来源:ChangeEvent.cs

示例2: DeleteSpecial

 // Delete a special
 public static void DeleteSpecial(EventDB eventDB, Id<Special> specialId)
 {
     eventDB.RemoveSpecial(specialId);
 }
开发者ID:petergolde,项目名称:PurplePen,代码行数:5,代码来源:ChangeEvent.cs


注:本文中的PurplePen.EventDB.RemoveSpecial方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。