Esempio n. 1
0
        private List <SearchableXMLItem> GetRecursiveXMLSearchItems(Policy ParentPol,
                                                                    String Type,
                                                                    String Root,
                                                                    String Path,
                                                                    String ResolvedPath,
                                                                    PolReaderXMLNode PolNode)
        {
            List <SearchableXMLItem> SpItems = new List <SearchableXMLItem>();

            string Name       = "";
            bool   CLSIDfound = false;

            foreach (PolReaderXMLProperty prop in PolNode.Properties)
            {
                if (prop.Name.Equals("name", StringComparison.CurrentCultureIgnoreCase))
                {
                    Name = "\\" + prop.Value;
                }
                else if (prop.Name.Equals("clsid", StringComparison.CurrentCultureIgnoreCase))
                {
                    CLSIDfound = true;
                }
            }

            if (!CLSIDfound)
            {
                Name = "";
            }

            foreach (PolReaderXMLProperty prop in PolNode.Properties)
            {
                if (!(prop.Name.Equals("name", StringComparison.CurrentCultureIgnoreCase) ||
                      (prop.Name.Equals("clsid", StringComparison.CurrentCultureIgnoreCase))))
                {
                    SearchableXMLItem xmlNode = new SearchableXMLItem();

                    xmlNode.ParentPolicy = ParentPol;
                    xmlNode.Linkage      = -1;
                    xmlNode.Name         = prop.Name;
                    xmlNode.Value        = prop.Value;
                    xmlNode.Root         = Root;
                    xmlNode.ResolvedPath = ResolvedPath + Name;
                    xmlNode.Path         = Path;
                    xmlNode.Type         = Type;

                    SpItems.Add(xmlNode);
                }
            }

            foreach (PolReaderXMLNode node in PolNode.Children)
            {
                SpItems.AddRange(GetRecursiveXMLSearchItems(ParentPol, Type, Root, Path + "\\" + node.Name, ResolvedPath + Name, node));
            }

            return(SpItems);
        }
Esempio n. 2
0
        public void LoadNodeInfo(XmlElement NodeItem)
        {
            //Type = NodeItem.Name;
            Name = NodeItem.Name;
            foreach (XmlAttribute item in NodeItem.Attributes)
            {
                PolReaderXMLProperty prop = new PolReaderXMLProperty();

                prop.Name  = item.Name;
                prop.Value = item.Value;
                Properties.Add(prop);
            }

            foreach (XmlNode child in NodeItem.ChildNodes)
            {
                if (child is XmlElement)
                {
                    PolReaderXMLNode pxmlitem = new PolReaderXMLNode();
                    pxmlitem.LoadNodeInfo((XmlElement)child);
                    Children.Add(pxmlitem);
                }
            }
        }
Esempio n. 3
0
        public XmlNodeDiffInfo Compare(PolReaderXMLNode oldXMLNodeInfo)
        {
            XmlNodeDiffInfo returnValue = new XmlNodeDiffInfo();

            if (PropertyExists("Name"))
            {
                returnValue.Name = Name + " : " + getPropertyValue("Name");
            }
            else
            {
                returnValue.Name = Name;
            }

            foreach (PolReaderXMLProperty prop in Properties)
            {
                bool found = false;

                foreach (PolReaderXMLProperty oldProp in oldXMLNodeInfo.Properties)
                {
                    if (prop.Name.Equals(oldProp.Name))
                    {
                        if (!prop.Value.Equals(oldProp.Value))
                        {
                            XmlPropertyDiffInfo DiffItem = new XmlPropertyDiffInfo();
                            DiffItem.Type    = XmlPropertyDiffInfo.UPDATED_POLICY_ITEM;
                            DiffItem.OldItem = oldProp;
                            DiffItem.NewItem = prop;
                            returnValue.propItems.Add(DiffItem);
                        }

                        found = true;
                        break;
                    }
                }

                if (!found)
                {
                    XmlPropertyDiffInfo DiffItem = new XmlPropertyDiffInfo();
                    DiffItem.Type    = XmlPropertyDiffInfo.NEW_POLICY_ITEM;
                    DiffItem.NewItem = prop;
                    returnValue.propItems.Add(DiffItem);
                }
            }

            foreach (PolReaderXMLProperty oldProp in oldXMLNodeInfo.Properties)
            {
                bool found = false;

                foreach (PolReaderXMLProperty prop in Properties)
                {
                    if (prop.Name.Equals(oldProp.Name))
                    {
                        found = true;
                    }
                }

                if (!found)
                {
                    XmlPropertyDiffInfo DiffItem = new XmlPropertyDiffInfo();
                    DiffItem.Type    = XmlPropertyDiffInfo.DELETED_POLICY_ITEM;
                    DiffItem.OldItem = oldProp;
                    DiffItem.DBID    = oldProp.DBID;
                    returnValue.propItems.Add(DiffItem);
                }
            }

            foreach (PolReaderXMLNode node in Children)
            {
                bool found = false;

                foreach (PolReaderXMLNode oldNode in oldXMLNodeInfo.Children)
                {
                    if (node.EqualsItem(oldNode))
                    {
                        XmlNodeDiffInfo diffItem = node.Compare(oldNode);

                        if (diffItem.propItems.Count > 0 || diffItem.nodeItems.Count > 0)
                        {
                            diffItem.Type = XmlNodeDiffInfo.UPDATED_POLICY;
                            returnValue.nodeItems.Add(diffItem);
                        }

                        found = true;
                        break;
                    }
                }

                if (!found)
                {
                    XmlNodeDiffInfo DiffItem = node.Compare(new PolReaderXMLNode());
                    DiffItem.Type = XmlNodeDiffInfo.NEW_POLICY;
                    returnValue.nodeItems.Add(DiffItem);
                }
            }

            foreach (PolReaderXMLNode oldNode in oldXMLNodeInfo.Children)
            {
                bool found = false;

                foreach (PolReaderXMLNode node in Children)
                {
                    if (node.EqualsItem(oldNode))
                    {
                        found = true;
                        break;
                    }
                }

                if (!found)
                {
                    XmlNodeDiffInfo DiffItem = new PolReaderXMLNode().Compare(oldNode);
                    DiffItem.Name = oldNode.Name;
                    DiffItem.Type = XmlNodeDiffInfo.DELETED_POLICY;
                    DiffItem.DBID = oldNode.DBID;
                    returnValue.nodeItems.Add(DiffItem);
                }
            }

            return(returnValue);
        }
Esempio n. 4
0
        public bool EqualsItem(PolReaderXMLNode CompareItem)
        {
            bool ReturnValue = false;

            if (Name.Equals(CompareItem.Name))
            {
                if (PropertyExists("UID"))
                {
                    ReturnValue = getPropertyValue("UID").Equals(CompareItem.getPropertyValue("UID"));
                }
                else if (PropertyExists("NameUID"))
                {
                    ReturnValue = getPropertyValue("NameUID").Equals(CompareItem.getPropertyValue("NameUID"));
                }
                else if (PropertyExists("Name"))
                {
                    ReturnValue = getPropertyValue("Name").Equals(CompareItem.getPropertyValue("Name"));
                }
                else
                {
                    int FoundCount = 0;

                    if (Name.Equals("FilterCollection", StringComparison.CurrentCultureIgnoreCase))
                    {
                        if (Children.Count > 0 && CompareItem.Children.Count > 0 &&
                            Children[0].Name.Equals(CompareItem.Children[0].Name))
                        {
                            foreach (PolReaderXMLProperty prop in Properties)
                            {
                                bool found = false;

                                foreach (PolReaderXMLProperty compProp in CompareItem.Properties)
                                {
                                    if (prop.Name.Equals(compProp.Name) && prop.Value.Equals(compProp.Value))
                                    {
                                        found = true;
                                        break;
                                    }
                                }

                                if (!found)
                                {
                                    ReturnValue = false;
                                    break;
                                }
                                else
                                {
                                    FoundCount++;
                                }
                            }
                        }
                        else
                        {
                            FoundCount = -1;
                        }
                    }
                    else
                    {
                        foreach (PolReaderXMLProperty prop in Properties)
                        {
                            bool found = false;

                            foreach (PolReaderXMLProperty compProp in CompareItem.Properties)
                            {
                                if (prop.Name.Equals(compProp.Name) && prop.Value.Equals(compProp.Value))
                                {
                                    found = true;
                                    break;
                                }
                            }

                            if (!found)
                            {
                                ReturnValue = false;
                                break;
                            }
                            else
                            {
                                FoundCount++;
                            }
                        }
                    }

                    ReturnValue = (FoundCount == Properties.Count);
                }
            }

            return(ReturnValue);
        }
Esempio n. 5
0
        public DiffPolicyInfo Compare(Policy OldPolicy)
        {
            DiffPolicyInfo returnValue = new DiffPolicyInfo();

            returnValue.PolicyGuid = GUID;
            returnValue.Name       = Name;


            if (MachinePreferencesFiles != null && OldPolicy.MachinePreferencesFiles != null)
            {
                if (OldPolicy.MachinePreferencesFiles.Count > 0)
                {
                    returnValue.Name = Name;
                }

                foreach (PolReaderXMLNode PrefNode in MachinePreferencesFiles)
                {
                    bool found = false;

                    foreach (PolReaderXMLNode oldPrefNode in OldPolicy.MachinePreferencesFiles)
                    {
                        if (PrefNode.Name.Equals(oldPrefNode.Name))
                        {
                            XmlNodeDiffInfo DiffItems = PrefNode.Compare(oldPrefNode);

                            if (DiffItems.nodeItems.Count > 0 || DiffItems.propItems.Count > 0)
                            {
                                returnValue.MachinePreferenceDifferenceInfo.Name = "Machine Preferences";
                                returnValue.MachinePreferenceDifferenceInfo.Type = XmlNodeDiffInfo.UPDATED_POLICY;
                                DiffItems.Type = XmlNodeDiffInfo.UPDATED_POLICY;
                                returnValue.MachinePreferenceDifferenceInfo.nodeItems.Add(DiffItems);
                            }

                            found = true;
                            break;
                        }
                    }

                    if (!found)
                    {
                        returnValue.MachinePreferenceDifferenceInfo.Name = "Machine Preferences";
                        returnValue.MachinePreferenceDifferenceInfo.Type = XmlNodeDiffInfo.NEW_POLICY;

                        XmlNodeDiffInfo DiffItem = PrefNode.Compare(new PolReaderXMLNode());
                        DiffItem.Type = XmlNodeDiffInfo.NEW_POLICY;
                        returnValue.MachinePreferenceDifferenceInfo.nodeItems.Add(DiffItem);
                    }
                }

                foreach (PolReaderXMLNode oldPrefNode in OldPolicy.MachinePreferencesFiles)
                {
                    bool found = false;

                    foreach (PolReaderXMLNode PrefNode in MachinePreferencesFiles)
                    {
                        if (PrefNode.Name.Equals(oldPrefNode.Name))
                        {
                            found = true;
                            break;
                        }
                    }

                    if (!found)
                    {
                        returnValue.MachinePreferenceDifferenceInfo.Name = "Machine Preferences";
                        returnValue.MachinePreferenceDifferenceInfo.Type = XmlNodeDiffInfo.UPDATED_POLICY;
                        XmlNodeDiffInfo DiffItem = new PolReaderXMLNode().Compare(oldPrefNode);

                        DiffItem.DBID = oldPrefNode.DBID;
                        DiffItem.Type = XmlNodeDiffInfo.DELETED_POLICY;
                        DiffItem.Name = oldPrefNode.Name;
                        returnValue.MachinePreferenceDifferenceInfo.nodeItems.Add(DiffItem);
                    }
                }
            }

            if (PreferencesFiles != null && OldPolicy.PreferencesFiles != null)
            {
                if (OldPolicy.MachinePreferencesFiles.Count > 0)
                {
                    returnValue.Name = Name;
                }

                foreach (PolReaderXMLNode PrefNode in PreferencesFiles)
                {
                    bool found = false;

                    foreach (PolReaderXMLNode oldPrefNode in OldPolicy.PreferencesFiles)
                    {
                        if (PrefNode.Name.Equals(oldPrefNode.Name))
                        {
                            XmlNodeDiffInfo DiffItems = PrefNode.Compare(oldPrefNode);

                            if (DiffItems.nodeItems.Count > 0 || DiffItems.propItems.Count > 0)
                            {
                                returnValue.PreferenceDifferenceInfo.Name = "User Preferences";
                                returnValue.PreferenceDifferenceInfo.Type = XmlNodeDiffInfo.UPDATED_POLICY;
                                DiffItems.Type = XmlNodeDiffInfo.UPDATED_POLICY;
                                returnValue.PreferenceDifferenceInfo.nodeItems.Add(DiffItems);
                            }

                            found = true;
                            break;
                        }
                    }

                    if (!found)
                    {
                        returnValue.PreferenceDifferenceInfo.Name = "User Preferences";
                        returnValue.PreferenceDifferenceInfo.Type = XmlNodeDiffInfo.NEW_POLICY;

                        XmlNodeDiffInfo DiffItem = PrefNode.Compare(new PolReaderXMLNode());
                        DiffItem.Type = XmlNodeDiffInfo.NEW_POLICY;
                        returnValue.PreferenceDifferenceInfo.nodeItems.Add(DiffItem);
                    }
                }

                foreach (PolReaderXMLNode oldPrefNode in OldPolicy.PreferencesFiles)
                {
                    bool found = false;

                    foreach (PolReaderXMLNode PrefNode in PreferencesFiles)
                    {
                        if (PrefNode.Name.Equals(oldPrefNode.Name))
                        {
                            found = true;
                            break;
                        }
                    }

                    if (!found)
                    {
                        returnValue.PreferenceDifferenceInfo.Name = "User Preferences";
                        returnValue.PreferenceDifferenceInfo.Type = XmlNodeDiffInfo.UPDATED_POLICY;
                        XmlNodeDiffInfo DiffItem = new PolReaderXMLNode().Compare(oldPrefNode);
                        DiffItem.Type = XmlNodeDiffInfo.DELETED_POLICY;
                        DiffItem.DBID = oldPrefNode.DBID;
                        DiffItem.Name = oldPrefNode.Name;
                        returnValue.PreferenceDifferenceInfo.nodeItems.Add(DiffItem);
                    }
                }
            }

            if (SecEditFileData != null && SecEditFileData.Sections != null &&
                OldPolicy.SecEditFileData != null && OldPolicy.SecEditFileData.Sections != null)
            {
                foreach (SecEditSection Section in SecEditFileData.Sections)
                {
                    bool found = false;

                    foreach (SecEditSection oldSection in OldPolicy.SecEditFileData.Sections)
                    {
                        if (oldSection.Name.Equals(Section.Name))
                        {
                            List <SecEditDiffValueInfo> Items = Section.Compare(oldSection);

                            if (Items.Count > 0)
                            {
                                returnValue.SecEditDifferenceInfo.Type = SecEditDiffInfo.UPDATED_POLICY_ITEM;
                                SecEditDiffSectionInfo secEditDiffInfo = new SecEditDiffSectionInfo();

                                secEditDiffInfo.Name   = Section.Name;
                                secEditDiffInfo.Type   = SecEditDiffSectionInfo.UPDATED_POLICY_ITEM;
                                secEditDiffInfo.Values = Items;

                                returnValue.SecEditDifferenceInfo.Sections.Add(secEditDiffInfo);
                            }

                            found = true;
                            break;
                        }
                    }

                    if (!found && Section.Entries.Count > 0)
                    {
                        returnValue.SecEditDifferenceInfo.Type = SecEditDiffInfo.UPDATED_POLICY_ITEM;
                        SecEditDiffSectionInfo secEditDiffInfo = new SecEditDiffSectionInfo();

                        secEditDiffInfo.Name   = Section.Name;
                        secEditDiffInfo.Type   = SecEditDiffSectionInfo.NEW_POLICY_ITEM;
                        secEditDiffInfo.Values = Section.Compare(new SecEditSection());

                        returnValue.SecEditDifferenceInfo.Sections.Add(secEditDiffInfo);
                    }
                }

                foreach (SecEditSection oldSection in OldPolicy.SecEditFileData.Sections)
                {
                    bool found = false;

                    foreach (SecEditSection Section in SecEditFileData.Sections)
                    {
                        if (oldSection.Name.Equals(Section.Name))
                        {
                            found = true;
                            break;
                        }
                    }

                    if (!found && oldSection.Entries.Count > 0)
                    {
                        returnValue.SecEditDifferenceInfo.Type = SecEditDiffInfo.UPDATED_POLICY_ITEM;
                        SecEditDiffSectionInfo secEditDiffInfo = new SecEditDiffSectionInfo();

                        secEditDiffInfo.Name   = oldSection.Name;
                        secEditDiffInfo.Type   = SecEditDiffSectionInfo.DELETED_POLICY_ITEM;
                        secEditDiffInfo.Values = new SecEditSection().Compare(oldSection);

                        returnValue.SecEditDifferenceInfo.Sections.Add(secEditDiffInfo);
                    }
                }
            }

            if (IEAKFileData != null && IEAKFileData.Sections != null &&
                OldPolicy.IEAKFileData != null && OldPolicy.IEAKFileData.Sections != null)
            {
                foreach (SecEditSection Section in IEAKFileData.Sections)
                {
                    bool found = false;

                    foreach (SecEditSection oldSection in OldPolicy.IEAKFileData.Sections)
                    {
                        if (oldSection.Name.Equals(Section.Name))
                        {
                            List <SecEditDiffValueInfo> Items = Section.Compare(oldSection);

                            if (Items.Count > 0)
                            {
                                returnValue.IEAKDifferenceInfo.Type = SecEditDiffInfo.UPDATED_POLICY_ITEM;
                                SecEditDiffSectionInfo secEditDiffInfo = new SecEditDiffSectionInfo();

                                secEditDiffInfo.Name   = Section.Name;
                                secEditDiffInfo.Type   = SecEditDiffSectionInfo.UPDATED_POLICY_ITEM;
                                secEditDiffInfo.Values = Items;

                                returnValue.IEAKDifferenceInfo.Sections.Add(secEditDiffInfo);
                            }

                            found = true;
                            break;
                        }
                    }

                    if (!found && Section.Entries.Count > 0)
                    {
                        returnValue.IEAKDifferenceInfo.Type = SecEditDiffInfo.UPDATED_POLICY_ITEM;
                        SecEditDiffSectionInfo secEditDiffInfo = new SecEditDiffSectionInfo();

                        secEditDiffInfo.Name   = Section.Name;
                        secEditDiffInfo.Type   = SecEditDiffSectionInfo.NEW_POLICY_ITEM;
                        secEditDiffInfo.Values = Section.Compare(new SecEditSection());

                        returnValue.IEAKDifferenceInfo.Sections.Add(secEditDiffInfo);
                    }
                }

                foreach (SecEditSection oldSection in OldPolicy.IEAKFileData.Sections)
                {
                    bool found = false;

                    foreach (SecEditSection Section in IEAKFileData.Sections)
                    {
                        if (oldSection.Name.Equals(Section.Name))
                        {
                            found = true;
                            break;
                        }
                    }

                    if (!found && oldSection.Entries.Count > 0)
                    {
                        returnValue.IEAKDifferenceInfo.Type = SecEditDiffInfo.UPDATED_POLICY_ITEM;
                        SecEditDiffSectionInfo secEditDiffInfo = new SecEditDiffSectionInfo();

                        secEditDiffInfo.Name   = oldSection.Name;
                        secEditDiffInfo.Type   = SecEditDiffSectionInfo.DELETED_POLICY_ITEM;
                        secEditDiffInfo.Values = new SecEditSection().Compare(oldSection);

                        returnValue.IEAKDifferenceInfo.Sections.Add(secEditDiffInfo);
                    }
                }
            }

            if (IEAKMachineFileData != null && IEAKMachineFileData.Sections != null &&
                OldPolicy.IEAKMachineFileData != null && OldPolicy.IEAKMachineFileData.Sections != null)
            {
                foreach (SecEditSection Section in IEAKMachineFileData.Sections)
                {
                    bool found = false;

                    foreach (SecEditSection oldSection in OldPolicy.IEAKMachineFileData.Sections)
                    {
                        if (oldSection.Name.Equals(Section.Name))
                        {
                            List <SecEditDiffValueInfo> Items = Section.Compare(oldSection);

                            if (Items.Count > 0)
                            {
                                returnValue.IEAKDifferenceInfo.Type = SecEditDiffInfo.UPDATED_POLICY_ITEM;
                                SecEditDiffSectionInfo secEditDiffInfo = new SecEditDiffSectionInfo();

                                secEditDiffInfo.Name   = Section.Name;
                                secEditDiffInfo.Type   = SecEditDiffSectionInfo.UPDATED_POLICY_ITEM;
                                secEditDiffInfo.Values = Items;

                                returnValue.IEAKDifferenceInfo.Sections.Add(secEditDiffInfo);
                            }

                            found = true;
                            break;
                        }
                    }

                    if (!found && Section.Entries.Count > 0)
                    {
                        returnValue.IEAKDifferenceInfo.Type = SecEditDiffInfo.UPDATED_POLICY_ITEM;
                        SecEditDiffSectionInfo secEditDiffInfo = new SecEditDiffSectionInfo();

                        secEditDiffInfo.Name   = Section.Name;
                        secEditDiffInfo.Type   = SecEditDiffSectionInfo.NEW_POLICY_ITEM;
                        secEditDiffInfo.Values = Section.Compare(new SecEditSection());

                        returnValue.IEAKDifferenceInfo.Sections.Add(secEditDiffInfo);
                    }
                }

                foreach (SecEditSection oldSection in OldPolicy.IEAKMachineFileData.Sections)
                {
                    bool found = false;

                    foreach (SecEditSection Section in IEAKMachineFileData.Sections)
                    {
                        if (oldSection.Name.Equals(Section.Name))
                        {
                            found = true;
                            break;
                        }
                    }

                    if (!found && oldSection.Entries.Count > 0)
                    {
                        returnValue.IEAKDifferenceInfo.Type = SecEditDiffInfo.UPDATED_POLICY_ITEM;
                        SecEditDiffSectionInfo secEditDiffInfo = new SecEditDiffSectionInfo();

                        secEditDiffInfo.Name   = oldSection.Name;
                        secEditDiffInfo.Type   = SecEditDiffSectionInfo.DELETED_POLICY_ITEM;
                        secEditDiffInfo.Values = new SecEditSection().Compare(oldSection);

                        returnValue.IEAKDifferenceInfo.Sections.Add(secEditDiffInfo);
                    }
                }
            }

            foreach (WMIItem WmiFilter in WMIFilters)
            {
                bool found = false;

                foreach (WMIItem oldWmiFilter in OldPolicy.WMIFilters)
                {
                    if (oldWmiFilter.WMIFilter.Equals(WmiFilter.WMIFilter))
                    {
                        found = true;
                        break;
                    }
                }

                if (!found)
                {
                    returnValue.WMIDifferenceInfo.Type = WMIDiffInfo.UPDATED_POLICY_ITEM;

                    WMIDiffInfoItem wmiItem = new WMIDiffInfoItem();
                    wmiItem.WMIQuery = WmiFilter.WMIFilter;
                    wmiItem.Type     = SecEditDiffSectionInfo.NEW_POLICY_ITEM;

                    returnValue.WMIDifferenceInfo.WMIItems.Add(wmiItem);
                }
            }

            foreach (WMIItem oldWmiFilter in OldPolicy.WMIFilters)
            {
                bool found = false;

                foreach (WMIItem WmiFilter in WMIFilters)
                {
                    if (oldWmiFilter.WMIFilter.Equals(WmiFilter.WMIFilter))
                    {
                        found = true;
                        break;
                    }
                }

                if (!found)
                {
                    returnValue.WMIDifferenceInfo.Type = WMIDiffInfo.UPDATED_POLICY_ITEM;

                    WMIDiffInfoItem wmiItem = new WMIDiffInfoItem();
                    wmiItem.WMIQuery = oldWmiFilter.WMIFilter;
                    wmiItem.Type     = SecEditDiffSectionInfo.DELETED_POLICY_ITEM;

                    returnValue.WMIDifferenceInfo.WMIItems.Add(wmiItem);
                }
            }



            foreach (AssignmentItem Assignment in AppliedTo)
            {
                bool found = false;

                foreach (AssignmentItem oldAssignment in OldPolicy.AppliedTo)
                {
                    if (oldAssignment.Assignment.Equals(Assignment.Assignment))
                    {
                        found = true;
                        break;
                    }
                }

                if (!found)
                {
                    returnValue.AssignmentsDifferenceInfo.Type = AssignmentsDiffInfo.UPDATED_POLICY_ITEM;

                    AssignmentsDiffInfoItem assignItem = new AssignmentsDiffInfoItem();
                    assignItem.Name = Assignment.Assignment;
                    assignItem.Type = AssignmentsDiffInfoItem.NEW_POLICY_ITEM;

                    returnValue.AssignmentsDifferenceInfo.Assignmments.Add(assignItem);
                }
            }

            foreach (AssignmentItem oldAssignment in OldPolicy.AppliedTo)
            {
                bool found = false;

                foreach (AssignmentItem Assignment in AppliedTo)
                {
                    if (oldAssignment.Assignment.Equals(Assignment.Assignment))
                    {
                        found = true;
                        break;
                    }
                }

                if (!found)
                {
                    returnValue.AssignmentsDifferenceInfo.Type = AssignmentsDiffInfo.UPDATED_POLICY_ITEM;

                    AssignmentsDiffInfoItem assignItem = new AssignmentsDiffInfoItem();
                    assignItem.Name = oldAssignment.Assignment;
                    assignItem.Type = AssignmentsDiffInfoItem.DELETED_POLICY_ITEM;

                    returnValue.AssignmentsDifferenceInfo.Assignmments.Add(assignItem);
                }
            }

            foreach (LinkageItem Linkage in LinkedTo)
            {
                bool found = false;

                foreach (LinkageItem oldLinkage in OldPolicy.LinkedTo)
                {
                    if (oldLinkage.Linkage.Equals(Linkage.Linkage))
                    {
                        found = true;
                        break;
                    }
                }

                if (!found)
                {
                    returnValue.LinkageDifferenceInfo.Type = LinkageDiffInfo.UPDATED_POLICY_ITEM;

                    LinkageDiffInfoItem linkItem = new LinkageDiffInfoItem();
                    linkItem.Name = Linkage.Linkage;
                    linkItem.Type = LinkageDiffInfoItem.NEW_POLICY_ITEM;

                    returnValue.LinkageDifferenceInfo.Linkages.Add(linkItem);
                }
            }

            foreach (LinkageItem oldLinkage in OldPolicy.LinkedTo)
            {
                bool found = false;

                foreach (LinkageItem Linkage in LinkedTo)
                {
                    if (oldLinkage.Linkage.Equals(Linkage.Linkage))
                    {
                        found = true;
                        break;
                    }
                }

                if (!found)
                {
                    returnValue.LinkageDifferenceInfo.Type = LinkageDiffInfo.UPDATED_POLICY_ITEM;

                    LinkageDiffInfoItem linkItem = new LinkageDiffInfoItem();
                    linkItem.Name = oldLinkage.Linkage;
                    linkItem.Type = LinkageDiffInfoItem.DELETED_POLICY_ITEM;

                    returnValue.LinkageDifferenceInfo.Linkages.Add(linkItem);
                }
            }

            foreach (PolicyFile polFile in PolicyFiles)
            {
                bool found = false;

                foreach (PolicyFile oldPolFile in OldPolicy.PolicyFiles)
                {
                    if (polFile.Type == oldPolFile.Type)
                    {
                        List <RegDiffItemInfo> DiffItems = polFile.Compare(oldPolFile);

                        if (DiffItems.Count > 0)
                        {
                            if (polFile.Type == PolicyFile.POLICY_FILE_TYPE_MACHINE)
                            {
                                returnValue.MachineRegDifferenceInfo.Type  = RegDiffInfo.UPDATED_POLICY_ITEM;
                                returnValue.MachineRegDifferenceInfo.Items = polFile.Compare(oldPolFile);
                            }
                            else if (polFile.Type == PolicyFile.POLICY_FILE_TYPE_USER)
                            {
                                returnValue.UserRegDifferenceInfo.Type  = RegDiffInfo.UPDATED_POLICY_ITEM;
                                returnValue.UserRegDifferenceInfo.Items = polFile.Compare(oldPolFile);
                            }
                        }

                        found = true;
                        break;
                    }
                }

                if (!found)
                {
                    if (polFile.Type == PolicyFile.POLICY_FILE_TYPE_MACHINE && polFile.PolicyItems.Count > 0)
                    {
                        returnValue.MachineRegDifferenceInfo.Type  = RegDiffInfo.NEW_POLICY_ITEM;
                        returnValue.MachineRegDifferenceInfo.Items = polFile.Compare(new PolicyFile());
                    }
                    else if (polFile.Type == PolicyFile.POLICY_FILE_TYPE_USER && polFile.PolicyItems.Count > 0)
                    {
                        returnValue.UserRegDifferenceInfo.Type  = RegDiffInfo.NEW_POLICY_ITEM;
                        returnValue.UserRegDifferenceInfo.Items = polFile.Compare(new PolicyFile());
                    }
                }
            }

            foreach (PolicyFile oldPolFile in OldPolicy.PolicyFiles)
            {
                bool found = false;

                foreach (PolicyFile polFile in PolicyFiles)
                {
                    if (polFile.Type == oldPolFile.Type)
                    {
                        found = true;
                    }
                }

                if (!found)
                {
                    if (oldPolFile.Type == PolicyFile.POLICY_FILE_TYPE_MACHINE && oldPolFile.PolicyItems.Count > 0)
                    {
                        returnValue.MachineRegDifferenceInfo.Type  = RegDiffInfo.DELETED_POLICY_ITEM;
                        returnValue.MachineRegDifferenceInfo.Items = new PolicyFile().Compare(oldPolFile);
                    }
                    else if (oldPolFile.Type == PolicyFile.POLICY_FILE_TYPE_USER && oldPolFile.PolicyItems.Count > 0)
                    {
                        returnValue.UserRegDifferenceInfo.Type  = RegDiffInfo.DELETED_POLICY_ITEM;
                        returnValue.UserRegDifferenceInfo.Items = new PolicyFile().Compare(oldPolFile);
                    }
                }
            }

            return(returnValue);
        }