Esempio n. 1
0
    public override T Remove()
    {
        if (Collection.Count == 0)
        {
            throw new InvalidOperationException("The list is empty");
        }
        T element = Collection[0];

        Collection.RemoveAt(0);
        Removes.Add(element);
        return(element);
    }
Esempio n. 2
0
        private void DeletedNodes(XmlNode node, XmlNamespaceManager nsmgr)
        {
            foreach (XmlNode n in node.ChildNodes)
            {
                if (n.NodeType != XmlNodeType.Element)
                {
                    continue;
                }
                DeletedNodes(n, nsmgr);
            }
            if (node.NodeType != XmlNodeType.Element)
            {
                return;
            }

            int matchIndex   = -1;
            int leftoverAttr = 0;
            var parentXp     = new List <string>();

            if (node.Attributes != null && node.Attributes.Count > 0)
            {
                foreach (XmlAttribute a in node.Attributes)
                {
                    matchIndex = MatchedNodes.IndexOf(a);
                    if (matchIndex != -1)
                    {
                        MatchedNodes.RemoveAt(matchIndex); continue;
                    }
                    leftoverAttr++;
                    if (Identifiers.Contains(a.Name))
                    {
                        string xp = GetXPath(a.OwnerElement);
                        parentXp.Add(xp);
                        for (int i = Removes.Count - 1; i >= 0; i--)
                        {
                            var d = Removes[i];
                            if (d.XPath.StartsWith(xp))
                            {
                                Removes.RemoveAt(i);
                            }
                        }
                        Removes.Add(new Diff(GetXPath(a.OwnerElement), null, null));
                    }
                    else
                    {
                        string xp = GetXPath(a);
                        if (parentXp.FirstOrDefault(p => xp.StartsWith(p)) != null)
                        {
                            continue;
                        }
                        Removes.Add(new Diff(xp, null, a.Value));
                    }
                }
            }
            matchIndex = MatchedNodes.IndexOf(node);
            if (matchIndex != -1)
            {
                MatchedNodes.RemoveAt(matchIndex);
            }
            if (leftoverAttr > 0 || node.HasChildNodes || node.ParentNode.HasChildNodes)
            {
                return;
            }
            string xpn = GetXPath(node);

            if (parentXp.FirstOrDefault(p => xpn.StartsWith(p)) != null)
            {
                return;
            }
            Removes.Add(new Diff(xpn, null, node.GetValue()));
        }
Esempio n. 3
0
 public void Remove(ParticleBase particle)
 {
     Removes.Add(particle);
 }