System.Xml.Schema.NamespaceList.CompareSetToOther C# (CSharp) Méthode

CompareSetToOther() private méthode

private CompareSetToOther ( NamespaceList other ) : NamespaceList
other NamespaceList
Résultat NamespaceList
        private NamespaceList CompareSetToOther(NamespaceList other) {
            //clause 5.1
            NamespaceList nslist = null;
            if (this.set.Contains(other.targetNamespace)) { //S contains negated ns
                if (this.set.Contains(string.Empty)) { // AND S contains absent
                    nslist = new NamespaceList(); //any is the result
                }
                else { //clause 5.2
                    nslist = new NamespaceList("##other", string.Empty);
                }
            }
            else if (this.set.Contains(string.Empty)) { //clause 5.3 - Not expressible
                nslist = null;
            }
            else { //clause 5.4 - Set S does not contain negated ns or absent 
                nslist = other.Clone();
            }
            return nslist;    
        }

Usage Example

Exemple #1
0
        public static NamespaceList Union(NamespaceList o1, NamespaceList o2, bool v1Compat)
        {
            NamespaceList nslist = null;

            Debug.Assert(o1 != o2);
            if (o1.type == ListType.Any)   //clause 2 - o1 is Any
            {
                nslist = new NamespaceList();
            }
            else if (o2.type == ListType.Any)   //clause 2 - o2 is Any
            {
                nslist = new NamespaceList();
            }
            else if (o1.type == ListType.Set && o2.type == ListType.Set)   //clause 3 , both are sets
            {
                nslist = o1.Clone();
                foreach (string ns in o2.set.Keys)
                {
                    nslist.set[ns] = ns;
                }
            }
            else if (o1.type == ListType.Other && o2.type == ListType.Other) //clause 4, both are negations
            {
                if (o1.targetNamespace == o2.targetNamespace)                //negation of same value
                {
                    nslist = o1.Clone();
                }
                else                                                     //Not a breaking change, going from not expressible to not(absent)
                {
                    nslist = new NamespaceList("##other", string.Empty); //clause 4, negations of different values, result is not(absent)
                }
            }
            else if (o1.type == ListType.Set && o2.type == ListType.Other)
            {
                if (v1Compat)
                {
                    if (o1.set.Contains(o2.targetNamespace))
                    {
                        nslist = new NamespaceList();
                    }
                    else   //This was not there originally in V1, added for consistency since its not breaking
                    {
                        nslist = o2.Clone();
                    }
                }
                else
                {
                    if (o2.targetNamespace != string.Empty)   //clause 5, o1 is set S, o2 is not(tns)
                    {
                        nslist = o1.CompareSetToOther(o2);
                    }
                    else if (o1.set.Contains(string.Empty))   //clause 6.1 - set S includes absent, o2 is not(absent)
                    {
                        nslist = new NamespaceList();
                    }
                    else   //clause 6.2 - set S does not include absent, result is not(absent)
                    {
                        nslist = new NamespaceList("##other", string.Empty);
                    }
                }
            }
            else if (o2.type == ListType.Set && o1.type == ListType.Other)
            {
                if (v1Compat)
                {
                    if (o2.set.Contains(o2.targetNamespace))
                    {
                        nslist = new NamespaceList();
                    }
                    else
                    {
                        nslist = o1.Clone();
                    }
                }
                else                                        //New rules
                {
                    if (o1.targetNamespace != string.Empty) //clause 5, o1 is set S, o2 is not(tns)
                    {
                        nslist = o2.CompareSetToOther(o1);
                    }
                    else if (o2.set.Contains(string.Empty))   //clause 6.1 - set S includes absent, o2 is not(absent)
                    {
                        nslist = new NamespaceList();
                    }
                    else   //clause 6.2 - set S does not include absent, result is not(absent)
                    {
                        nslist = new NamespaceList("##other", string.Empty);
                    }
                }
            }
            return(nslist);
        }
All Usage Examples Of System.Xml.Schema.NamespaceList::CompareSetToOther