Ejemplo n.º 1
0
        public GroupOfSchedule PutToSubgroup(string subName, Regex filter, NodeType assignedType)
        {
            if (Subgroups == null)
            {
                Subgroups = new List <GroupOfSchedule>();
            }

            var currentGroup = Subgroups.FirstOrDefault(t => string.Equals(t.GroupName, subName, StringComparison.CurrentCultureIgnoreCase));

            if (currentGroup != null)
            {
                currentGroup.Schedules.AddRange(Schedules.Where(t => filter.IsMatch(t.Name) && t.GetNodeType() == assignedType));
            }
            else
            {
                currentGroup = new GroupOfSchedule(Schedules.Where(t => filter.IsMatch(t.Name) && t.GetNodeType() == assignedType))
                {
                    GroupName = subName
                };
                Subgroups.Add(currentGroup);
            }

            Schedules.RemoveAll(t => filter.IsMatch(t.Name) && t.GetNodeType() == assignedType);
            if (Schedules.Count == 0)
            {
                Schedules = null;
            }
            return(currentGroup);
        }
Ejemplo n.º 2
0
        private static void PutToSubgroups(GroupOfSchedule group, GroupFilter filters)
        {
            if (filters.Filter != null)
            {
                if (group.Schedules != null)
                {
                    if (group.Schedules.Any(t => filters.Filter.IsMatch(t.Name) && t.GetNodeType() == filters.AssignType))
                    {
                        group = group.PutToSubgroup(filters.GroupName, filters.Filter, filters.AssignType);
                    }
                }
            }

            if (filters.SubFilters != null)
            {
                foreach (var filtersSubFilter in filters.SubFilters)
                {
                    PutToSubgroups(group, filtersSubFilter);
                }
            }
        }