Beispiel #1
0
        private void MakeItems()
        {
            List <SmartGroupsJsonData> source;

            switch (dataSourceMode)
            {
            case SmartDataSourceMode.SD_SOURCE_EVENTS:
                source = smartDataProvider.GetEventsGroups().ToList();
                break;

            case SmartDataSourceMode.SD_SOURCE_ACTIONS:
                source = smartDataProvider.GetActionsGroups().ToList();
                break;

            case SmartDataSourceMode.SD_SOURCE_TARGETS:
                source = smartDataProvider.GetTargetsGroups().ToList();
                break;

            default:
                source = smartDataProvider.GetEventsGroups().ToList();
                break;
            }

            foreach (var item in source)
            {
                SourceItems.Add(new SmartDataGroupsEditorData(in item));
            }
        }
        public SmartDataProvider(ISmartRawDataProvider smartRawDataProvider,
                                 ICurrentCoreVersion coreVersion)
        {
            this.coreVersion = coreVersion;

            actions = smartRawDataProvider.GetActions().Where(IsSmartValidForCore).ToList();
            events  = smartRawDataProvider.GetEvents().Where(IsSmartValidForCore).ToList();
            targets = smartRawDataProvider.GetTargets().Where(IsSmartValidForCore).ToList();

            var actionKeys = actions.Select(g => g.Name).ToHashSet();
            var eventKeys  = events.Select(g => g.Name).ToHashSet();
            var targetKeys = targets.Select(g => g.Name).ToHashSet();

            eventsGroups = smartRawDataProvider.GetEventsGroups().Select(group =>
                                                                         new SmartGroupsJsonData()
            {
                Name    = group.Name,
                Members = group.Members.Where(name => eventKeys.Contains(name)).ToList()
            })
                           .ToList();

            actionsGroups = smartRawDataProvider.GetActionsGroups().Select(group =>
                                                                           new SmartGroupsJsonData()
            {
                Name    = group.Name,
                Members = group.Members.Where(name => actionKeys.Contains(name)).ToList()
            })
                            .ToList();

            targetsGroups = smartRawDataProvider.GetTargetsGroups().Select(group =>
                                                                           new SmartGroupsJsonData()
            {
                Name    = group.Name,
                Members = group.Members.Where(name => targetKeys.Contains(name)).ToList()
            })
                            .ToList();
        }