CompareSetToOther() private method

private CompareSetToOther ( NamespaceList other ) : NamespaceList
other NamespaceList
return NamespaceList
Esempio n. 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);
        }
 public static NamespaceList Union(NamespaceList o1, NamespaceList o2, bool v1Compat)
 {
     NamespaceList list = null;
     if (o1.type == ListType.Any)
     {
         return new NamespaceList();
     }
     if (o2.type == ListType.Any)
     {
         return new NamespaceList();
     }
     if ((o1.type == ListType.Set) && (o2.type == ListType.Set))
     {
         list = o1.Clone();
         foreach (string str in o2.set.Keys)
         {
             list.set[str] = str;
         }
         return list;
     }
     if ((o1.type == ListType.Other) && (o2.type == ListType.Other))
     {
         if (o1.targetNamespace == o2.targetNamespace)
         {
             return o1.Clone();
         }
         return new NamespaceList("##other", string.Empty);
     }
     if ((o1.type == ListType.Set) && (o2.type == ListType.Other))
     {
         if (v1Compat)
         {
             if (o1.set.Contains(o2.targetNamespace))
             {
                 return new NamespaceList();
             }
             return o2.Clone();
         }
         if (o2.targetNamespace != string.Empty)
         {
             return o1.CompareSetToOther(o2);
         }
         if (o1.set.Contains(string.Empty))
         {
             return new NamespaceList();
         }
         return new NamespaceList("##other", string.Empty);
     }
     if ((o2.type != ListType.Set) || (o1.type != ListType.Other))
     {
         return list;
     }
     if (v1Compat)
     {
         if (o2.set.Contains(o2.targetNamespace))
         {
             return new NamespaceList();
         }
         return o1.Clone();
     }
     if (o1.targetNamespace != string.Empty)
     {
         return o2.CompareSetToOther(o1);
     }
     if (o2.set.Contains(string.Empty))
     {
         return new NamespaceList();
     }
     return new NamespaceList("##other", string.Empty);
 }
 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 {
             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;
 }
Esempio n. 4
0
        public static NamespaceList Union(NamespaceList o1, NamespaceList o2, bool v1Compat)
        {
            NamespaceList list = null;

            if (o1.type == ListType.Any)
            {
                return(new NamespaceList());
            }
            if (o2.type == ListType.Any)
            {
                return(new NamespaceList());
            }
            if ((o1.type == ListType.Set) && (o2.type == ListType.Set))
            {
                list = o1.Clone();
                foreach (string str in o2.set.Keys)
                {
                    list.set[str] = str;
                }
                return(list);
            }
            if ((o1.type == ListType.Other) && (o2.type == ListType.Other))
            {
                if (o1.targetNamespace == o2.targetNamespace)
                {
                    return(o1.Clone());
                }
                return(new NamespaceList("##other", string.Empty));
            }
            if ((o1.type == ListType.Set) && (o2.type == ListType.Other))
            {
                if (v1Compat)
                {
                    if (o1.set.Contains(o2.targetNamespace))
                    {
                        return(new NamespaceList());
                    }
                    return(o2.Clone());
                }
                if (o2.targetNamespace != string.Empty)
                {
                    return(o1.CompareSetToOther(o2));
                }
                if (o1.set.Contains(string.Empty))
                {
                    return(new NamespaceList());
                }
                return(new NamespaceList("##other", string.Empty));
            }
            if ((o2.type != ListType.Set) || (o1.type != ListType.Other))
            {
                return(list);
            }
            if (v1Compat)
            {
                if (o2.set.Contains(o2.targetNamespace))
                {
                    return(new NamespaceList());
                }
                return(o1.Clone());
            }
            if (o1.targetNamespace != string.Empty)
            {
                return(o2.CompareSetToOther(o1));
            }
            if (o2.set.Contains(string.Empty))
            {
                return(new NamespaceList());
            }
            return(new NamespaceList("##other", string.Empty));
        }