private static DiscoveryResultBase FilterByPriority(
            DiscoveryResultBase result,
            TechnologyManager mgr,
            bool onlyMandatory)
        {
            if (result == null)
            {
                throw new ArgumentNullException(nameof(result));
            }
            if (mgr == null)
            {
                throw new ArgumentNullException(nameof(mgr));
            }
            ILookup <string, ITechnologyPolling> lookup = mgr.TechnologyPollingFactory.Items().ToLookup <ITechnologyPolling, string>((Func <ITechnologyPolling, string>)(tp => tp.get_TechnologyPollingID()), (IEqualityComparer <string>)StringComparer.Ordinal);
            List <IDiscoveredObject>             idiscoveredObjectList = new List <IDiscoveredObject>();

            using (IEnumerator <DiscoveryPluginResultBase> enumerator = result.get_PluginResults().GetEnumerator())
            {
                while (((IEnumerator)enumerator).MoveNext())
                {
                    IEnumerable <IDiscoveredObject> discoveredObjects = enumerator.Current.GetDiscoveredObjects();
                    idiscoveredObjectList.AddRange(discoveredObjects);
                }
            }
            List <IDiscoveredObjectWithTechnology> list1 = ((IEnumerable)idiscoveredObjectList).OfType <IDiscoveredObjectWithTechnology>().ToList <IDiscoveredObjectWithTechnology>();

            using (IEnumerator <TechnologyDiscoveryGroup> enumerator1 = DiscoveryFilterResultByTechnology.GetDiscoveryGroupsInternal(mgr).GetEnumerator())
            {
                while (((IEnumerator)enumerator1).MoveNext())
                {
                    TechnologyDiscoveryGroup group = enumerator1.Current;
                    if (!onlyMandatory || group.get_SelectionDisabled())
                    {
                        IEnumerable <IDiscoveredObjectWithTechnology>  list2 = (IEnumerable <IDiscoveredObjectWithTechnology>)((IEnumerable <IDiscoveredObjectWithTechnology>)list1).Where <IDiscoveredObjectWithTechnology>((Func <IDiscoveredObjectWithTechnology, bool>)(n => group.IsMyGroupedObjectType((IDiscoveredObject)n))).ToList <IDiscoveredObjectWithTechnology>();
                        List <List <IDiscoveredObjectWithTechnology> > objectWithTechnologyListList = new List <List <IDiscoveredObjectWithTechnology> >();
                        using (List <IDiscoveredObject> .Enumerator enumerator2 = idiscoveredObjectList.GetEnumerator())
                        {
                            while (enumerator2.MoveNext())
                            {
                                IDiscoveredObject current1 = enumerator2.Current;
                                if (((DiscoveredObjectBase)group).IsChildOf(current1))
                                {
                                    List <IDiscoveredObjectWithTechnology> objectWithTechnologyList = new List <IDiscoveredObjectWithTechnology>();
                                    using (IEnumerator <IDiscoveredObjectWithTechnology> enumerator3 = list2.GetEnumerator())
                                    {
                                        while (((IEnumerator)enumerator3).MoveNext())
                                        {
                                            IDiscoveredObjectWithTechnology current2 = enumerator3.Current;
                                            if (((IDiscoveredObject)current2).IsChildOf(current1))
                                            {
                                                objectWithTechnologyList.Add(current2);
                                            }
                                        }
                                    }
                                    objectWithTechnologyListList.Add(objectWithTechnologyList);
                                }
                            }
                        }
                        using (List <List <IDiscoveredObjectWithTechnology> > .Enumerator enumerator2 = objectWithTechnologyListList.GetEnumerator())
                        {
                            while (enumerator2.MoveNext())
                            {
                                List <IDiscoveredObjectWithTechnology> current = enumerator2.Current;
                                if (onlyMandatory)
                                {
                                    if (((IEnumerable <IDiscoveredObjectWithTechnology>)current).Any <IDiscoveredObjectWithTechnology>((Func <IDiscoveredObjectWithTechnology, bool>)(to => ((IDiscoveredObject)to).get_IsSelected())))
                                    {
                                        continue;
                                    }
                                }
                                else
                                {
                                    current.ForEach((Action <IDiscoveredObjectWithTechnology>)(to => ((IDiscoveredObject)to).set_IsSelected(false)));
                                }
                                DiscoveryFilterResultByTechnology.SelectObjectWithHigherPriority((IEnumerable <IDiscoveredObjectWithTechnology>)current, lookup);
                            }
                        }
                    }
                }
            }
            return(result);
        }
        public static Action AuditTechnologiesChanges(
            IEnumerable <IDiscoveredObject> discoveredObjects,
            int nodeId)
        {
            if (!BusinessLayerSettings.Instance.EnableTechnologyPollingAssignmentsChangesAuditing)
            {
                return((Action)(() => {}));
            }
            Dictionary <string, ITechnology> technologies = TechnologyManager.Instance.TechnologyFactory.Items().ToDictionary <ITechnology, string, ITechnology>((Func <ITechnology, string>)(k => k.get_TechnologyID()), (Func <ITechnology, ITechnology>)(v => v), (IEqualityComparer <string>)StringComparer.Ordinal);
            Dictionary <string, string>      dictionary1  = TechnologyManager.Instance.TechnologyPollingFactory.Items().Where <ITechnologyPolling>((Func <ITechnologyPolling, bool>)(tp => technologies.ContainsKey(tp.get_TechnologyID()))).ToDictionary <ITechnologyPolling, string, string>((Func <ITechnologyPolling, string>)(k => k.get_TechnologyPollingID()), (Func <ITechnologyPolling, string>)(v => technologies[v.get_TechnologyID()].get_TargetEntity()), (IEqualityComparer <string>)StringComparer.Ordinal);
            IEnumerable <IDiscoveredObjectWithTechnology> objectWithTechnologies = ((IEnumerable)discoveredObjects).OfType <IDiscoveredObjectWithTechnology>();
            List <TechnologyPollingAssignment>            changedAssignments     = new List <TechnologyPollingAssignment>();

            using (IEnumerator <IDiscoveredObjectWithTechnology> enumerator = objectWithTechnologies.GetEnumerator())
            {
                while (((IEnumerator)enumerator).MoveNext())
                {
                    IDiscoveredObjectWithTechnology current = enumerator.Current;
                    if (dictionary1.ContainsKey(current.get_TechnologyPollingID()) && "Orion.Nodes".Equals(dictionary1[current.get_TechnologyPollingID()], StringComparison.Ordinal))
                    {
                        int num1 = nodeId;
                        TechnologyPollingAssignment pollingAssignment1 = TechnologyManager.Instance.TechnologyPollingFactory.GetAssignments(current.get_TechnologyPollingID(), new int[1]
                        {
                            num1
                        }).FirstOrDefault <TechnologyPollingAssignment>();
                        int  num2       = pollingAssignment1 == null ? 0 : (pollingAssignment1.get_Enabled() ? 1 : 0);
                        bool isSelected = ((IDiscoveredObject)current).get_IsSelected();
                        int  num3       = isSelected ? 1 : 0;
                        if (num2 != num3)
                        {
                            List <TechnologyPollingAssignment> pollingAssignmentList = changedAssignments;
                            TechnologyPollingAssignment        pollingAssignment2    = new TechnologyPollingAssignment();
                            pollingAssignment2.set_TechnologyPollingID(current.get_TechnologyPollingID());
                            pollingAssignment2.set_NetObjectID(num1);
                            pollingAssignment2.set_Enabled(isSelected);
                            pollingAssignmentList.Add(pollingAssignment2);
                        }
                    }
                }
            }
            return((Action)(() =>
            {
                if (changedAssignments.Count == 0)
                {
                    return;
                }
                Dictionary <string, ITechnologyPolling> dictionary2 = TechnologyManager.Instance.TechnologyPollingFactory.Items().ToDictionary <ITechnologyPolling, string, ITechnologyPolling>((Func <ITechnologyPolling, string>)(k => k.get_TechnologyPollingID()), (Func <ITechnologyPolling, ITechnologyPolling>)(v => v), (IEqualityComparer <string>)StringComparer.Ordinal);
                TechnologyPollingIndicator pollingIndicator = new TechnologyPollingIndicator();
                using (List <TechnologyPollingAssignment> .Enumerator enumerator = changedAssignments.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        TechnologyPollingAssignment current = enumerator.Current;
                        pollingIndicator.ReportTechnologyPollingAssignmentIndication(dictionary2[current.get_TechnologyPollingID()], new int[1]
                        {
                            current.get_NetObjectID()
                        }, (current.get_Enabled() ? 1 : 0) != 0);
                    }
                }
            }));
        }