Пример #1
0
        private XObjectsNamespaceList CompareSetToOther(XObjectsNamespaceList other)
        {
            //clause 5.1
            XObjectsNamespaceList nslist = null;

            if (this.set.Contains(other.targetNamespace))
            {
                //S contains negated ns
                if (this.set.Contains(string.Empty))
                {
                    // AND S contains absent
                    nslist = new XObjectsNamespaceList(); //any is the result
                }
                else
                {
                    //clause 5.2
                    nslist = new XObjectsNamespaceList("##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);
        }
        public static bool IsSubset(XObjectsNamespaceList sub, XObjectsNamespaceList super)
        {
            bool flag;

            if (super.type == XObjectsNamespaceList.ListType.Any)
            {
                flag = true;
            }
            else if (!(sub.type != XObjectsNamespaceList.ListType.Other ? true : super.type != XObjectsNamespaceList.ListType.Other))
            {
                flag = super.targetNamespace == sub.targetNamespace;
            }
            else if (sub.type != XObjectsNamespaceList.ListType.Set)
            {
                flag = false;
            }
            else if (super.type != XObjectsNamespaceList.ListType.Other)
            {
                Debug.Assert(super.type == XObjectsNamespaceList.ListType.Set);
                foreach (string ns in [email protected])
                {
                    if ([email protected](ns))
                    {
                        flag = false;
                        return(flag);
                    }
                }
                flag = true;
            }
            else
            {
                flag = [email protected](super.targetNamespace);
            }
            return(flag);
        }
Пример #3
0
        public static bool IsSubset(XObjectsNamespaceList sub, XObjectsNamespaceList super)
        {
            if (super.type == ListType.Any)
            {
                return(true);
            }
            else if (sub.type == ListType.Other && super.type == ListType.Other)
            {
                return(super.targetNamespace == sub.targetNamespace);
            }
            else if (sub.type == ListType.Set)
            {
                if (super.type == ListType.Other)
                {
                    return(!sub.set.Contains(super.targetNamespace));
                }
                else
                {
                    Debug.Assert(super.type == ListType.Set);
                    foreach (string ns in sub.set.Keys)
                    {
                        if (!super.set.Contains(ns))
                        {
                            return(false);
                        }
                    }

                    return(true);
                }
            }

            return(false);
        }
        public static XObjectsNamespaceList Union(XObjectsNamespaceList o1, XObjectsNamespaceList o2, bool v1Compat)
        {
            XObjectsNamespaceList nslist = null;

            Debug.Assert(o1 != o2);
            if (o1.type == XObjectsNamespaceList.ListType.Any)
            {
                nslist = new XObjectsNamespaceList();
            }
            else if (o2.type == XObjectsNamespaceList.ListType.Any)
            {
                nslist = new XObjectsNamespaceList();
            }
            else if (!(o1.type != XObjectsNamespaceList.ListType.Set ? true : o2.type != XObjectsNamespaceList.ListType.Set))
            {
                nslist = o1.Clone();
                foreach (string ns in [email protected])
                {
                    nslist.@set[ns] = ns;
                }
            }
            else if (!(o1.type != XObjectsNamespaceList.ListType.Other ? true : o2.type != XObjectsNamespaceList.ListType.Other))
            {
                nslist = (!(o1.targetNamespace == o2.targetNamespace) ? new XObjectsNamespaceList("##other", string.Empty) : o1.Clone());
            }
            else if ((o1.type != XObjectsNamespaceList.ListType.Set ? true : o2.type != XObjectsNamespaceList.ListType.Other))
            {
                if ((o2.type != XObjectsNamespaceList.ListType.Set ? false : o1.type == XObjectsNamespaceList.ListType.Other))
                {
                    if (v1Compat)
                    {
                        nslist = ([email protected](o2.targetNamespace) ? o1.Clone() : new XObjectsNamespaceList());
                    }
                    else if (!(o1.targetNamespace != string.Empty))
                    {
                        nslist = ([email protected](string.Empty) ? new XObjectsNamespaceList("##other", string.Empty) : new XObjectsNamespaceList());
                    }
                    else
                    {
                        nslist = o2.CompareSetToOther(o1);
                    }
                }
            }
            else if (v1Compat)
            {
                nslist = ([email protected](o2.targetNamespace) ? o2.Clone() : new XObjectsNamespaceList());
            }
            else if (!(o2.targetNamespace != string.Empty))
            {
                nslist = ([email protected](string.Empty) ? new XObjectsNamespaceList("##other", string.Empty) : new XObjectsNamespaceList());
            }
            else
            {
                nslist = o1.CompareSetToOther(o2);
            }
            return(nslist);
        }
        public XObjectsNamespaceList Clone()
        {
            XObjectsNamespaceList nsl = (XObjectsNamespaceList)this.MemberwiseClone();

            if (this.type == XObjectsNamespaceList.ListType.Set)
            {
                Debug.Assert(this.@set != null);
                nsl.@set = (Hashtable)[email protected]();
            }
            return(nsl);
        }
        public XObjectsNamespaceList Clone()
        {
            XObjectsNamespaceList nsl = (XObjectsNamespaceList)MemberwiseClone();

            if (type == ListType.Set)
            {
                Debug.Assert(set != null);
                nsl.set = (Hashtable)(set.Clone());
            }
            return(nsl);
        }
Пример #7
0
 public WildCard(string namespaces, string targetNamespace)
 {
     if (targetNamespace == null)
     {
         targetNamespace = "";
     }
     if (namespaces == null)
     {
         namespaces = "##any";
     }
     this.nsList = new XObjectsNamespaceList(namespaces, targetNamespace);
 }
        private XObjectsNamespaceList CompareSetToOther(XObjectsNamespaceList other)
        {
            XObjectsNamespaceList nslist = null;

            if ([email protected](other.targetNamespace))
            {
                nslist = ([email protected](string.Empty) ? new XObjectsNamespaceList("##other", string.Empty) : new XObjectsNamespaceList());
            }
            else if ([email protected](string.Empty))
            {
                nslist = other.Clone();
            }
            else
            {
                nslist = null;
            }
            return(nslist);
        }
Пример #9
0
 public static XObjectsNamespaceList Intersection(XObjectsNamespaceList o1, XObjectsNamespaceList o2, bool v1Compat) {
     XObjectsNamespaceList nslist = null;
     Debug.Assert(o1 != o2); //clause 1
     if (o1.type == ListType.Any) { //clause 2 - o1 is any
         nslist = o2.Clone();
     }
     else if (o2.type == ListType.Any) { //clause 2 - o2 is any
         nslist = o1.Clone();
     }
     else if (o1.type == ListType.Set && o2.type == ListType.Other) { //Clause 3 o2 is other
         nslist = o1.Clone();
         nslist.RemoveNamespace(o2.targetNamespace);
         if (!v1Compat) {
             nslist.RemoveNamespace(string.Empty); //remove ##local
         }
     }
     else if (o1.type == ListType.Other && o2.type == ListType.Set) { //Clause 3 o1 is other
         nslist = o2.Clone();
         nslist.RemoveNamespace(o1.targetNamespace);
         if (!v1Compat) {
             nslist.RemoveNamespace(string.Empty); //remove ##local
         }
     }
     else if (o1.type == ListType.Set && o2.type == ListType.Set) { //clause 4
         nslist =  o1.Clone();
         nslist = new XObjectsNamespaceList();
         nslist.type = ListType.Set;
         nslist.set = new Hashtable();
         foreach(string ns in o1.set.Keys) {
             if (o2.set.Contains(ns)) {
                 nslist.set.Add(ns, ns);
             }
         }
     }
     else if (o1.type == ListType.Other && o2.type == ListType.Other) {
         if (o1.targetNamespace == o2.targetNamespace) { //negation of same namespace name
             nslist = o1.Clone();
             return nslist;
         }
         if (!v1Compat) { 
             if (o1.targetNamespace == string.Empty) { // clause 6 - o1 is negation of absent
                 nslist = o2.Clone();
             }
             else if (o2.targetNamespace == string.Empty) { //clause 6 - o1 is negation of absent
                 nslist = o1.Clone();
             }
         }
         //if it comes here, its not expressible //clause 5
     }
     return nslist;
 }
Пример #10
0
 private XObjectsNamespaceList CompareSetToOther(XObjectsNamespaceList other) {
     //clause 5.1
     XObjectsNamespaceList nslist = null;
     if (this.set.Contains(other.targetNamespace)) { //S contains negated ns
         if (this.set.Contains(string.Empty)) { // AND S contains absent
             nslist = new XObjectsNamespaceList(); //any is the result
         }
         else { //clause 5.2
             nslist = new XObjectsNamespaceList("##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;    
 }
Пример #11
0
 public static XObjectsNamespaceList Union(XObjectsNamespaceList o1, XObjectsNamespaceList o2, bool v1Compat) {
     XObjectsNamespaceList nslist = null;
     Debug.Assert(o1 != o2);
     if (o1.type == ListType.Any) { //clause 2 - o1 is Any
         nslist = new XObjectsNamespaceList();
     }
     else if (o2.type == ListType.Any) { //clause 2 - o2 is Any
         nslist = new XObjectsNamespaceList();
     }
     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 XObjectsNamespaceList("##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 XObjectsNamespaceList();
             }
             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 XObjectsNamespaceList();
             }
             else { //clause 6.2 - set S does not include absent, result is not(absent)
                 nslist = new XObjectsNamespaceList("##other", string.Empty);
             }
         }
     }
     else if (o2.type == ListType.Set && o1.type == ListType.Other) {
         if (v1Compat) {
             if (o2.set.Contains(o2.targetNamespace)) {
                 nslist = new XObjectsNamespaceList();
             }
             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 XObjectsNamespaceList();
             }
             else { //clause 6.2 - set S does not include absent, result is not(absent)
                 nslist = new XObjectsNamespaceList("##other", string.Empty);
             }
         }
     }
     return nslist;
 }
Пример #12
0
 public static bool IsSubset(XObjectsNamespaceList sub, XObjectsNamespaceList super) {
     if (super.type == ListType.Any) {
         return true;
     }
     else if (sub.type == ListType.Other && super.type == ListType.Other) {
         return super.targetNamespace == sub.targetNamespace;
     }
     else  if (sub.type == ListType.Set) {
         if (super.type == ListType.Other) {
             return !sub.set.Contains(super.targetNamespace);
         }
         else {
             Debug.Assert(super.type == ListType.Set);
             foreach (string ns in sub.set.Keys) {
                 if (!super.set.Contains(ns)) {
                     return false;
                 }
             }
             return true;
         }           
     }
     return false;
 }
        public static XObjectsNamespaceList Intersection(XObjectsNamespaceList o1, XObjectsNamespaceList o2, bool v1Compat)
        {
            XObjectsNamespaceList xObjectsNamespaceList;
            XObjectsNamespaceList nslist = null;

            Debug.Assert(o1 != o2);
            if (o1.type == XObjectsNamespaceList.ListType.Any)
            {
                nslist = o2.Clone();
            }
            else if (o2.type == XObjectsNamespaceList.ListType.Any)
            {
                nslist = o1.Clone();
            }
            else if (!(o1.type != XObjectsNamespaceList.ListType.Set ? true : o2.type != XObjectsNamespaceList.ListType.Other))
            {
                nslist = o1.Clone();
                nslist.RemoveNamespace(o2.targetNamespace);
                if (!v1Compat)
                {
                    nslist.RemoveNamespace(string.Empty);
                }
            }
            else if (!(o1.type != XObjectsNamespaceList.ListType.Other ? true : o2.type != XObjectsNamespaceList.ListType.Set))
            {
                nslist = o2.Clone();
                nslist.RemoveNamespace(o1.targetNamespace);
                if (!v1Compat)
                {
                    nslist.RemoveNamespace(string.Empty);
                }
            }
            else if (!(o1.type != XObjectsNamespaceList.ListType.Set ? true : o2.type != XObjectsNamespaceList.ListType.Set))
            {
                nslist = o1.Clone();
                nslist = new XObjectsNamespaceList()
                {
                    type = XObjectsNamespaceList.ListType.Set,
                    @set = new Hashtable()
                };
                foreach (string ns in [email protected])
                {
                    if ([email protected](ns))
                    {
                        [email protected](ns, ns);
                    }
                }
            }
            else if ((o1.type != XObjectsNamespaceList.ListType.Other ? false : o2.type == XObjectsNamespaceList.ListType.Other))
            {
                if (o1.targetNamespace == o2.targetNamespace)
                {
                    nslist = o1.Clone();
                    xObjectsNamespaceList = nslist;
                    return(xObjectsNamespaceList);
                }
                if (!v1Compat)
                {
                    if (o1.targetNamespace == string.Empty)
                    {
                        nslist = o2.Clone();
                    }
                    else if (o2.targetNamespace == string.Empty)
                    {
                        nslist = o1.Clone();
                    }
                }
            }
            xObjectsNamespaceList = nslist;
            return(xObjectsNamespaceList);
        }
Пример #14
0
        public static XObjectsNamespaceList Intersection(XObjectsNamespaceList o1, XObjectsNamespaceList o2,
                                                         bool v1Compat)
        {
            XObjectsNamespaceList nslist = null;

            Debug.Assert(o1 != o2); //clause 1
            if (o1.type == ListType.Any)
            {
                //clause 2 - o1 is any
                nslist = o2.Clone();
            }
            else if (o2.type == ListType.Any)
            {
                //clause 2 - o2 is any
                nslist = o1.Clone();
            }
            else if (o1.type == ListType.Set && o2.type == ListType.Other)
            {
                //Clause 3 o2 is other
                nslist = o1.Clone();
                nslist.RemoveNamespace(o2.targetNamespace);
                if (!v1Compat)
                {
                    nslist.RemoveNamespace(string.Empty); //remove ##local
                }
            }
            else if (o1.type == ListType.Other && o2.type == ListType.Set)
            {
                //Clause 3 o1 is other
                nslist = o2.Clone();
                nslist.RemoveNamespace(o1.targetNamespace);
                if (!v1Compat)
                {
                    nslist.RemoveNamespace(string.Empty); //remove ##local
                }
            }
            else if (o1.type == ListType.Set && o2.type == ListType.Set)
            {
                //clause 4
                nslist      = o1.Clone();
                nslist      = new XObjectsNamespaceList();
                nslist.type = ListType.Set;
                nslist.set  = new Hashtable();
                foreach (string ns in o1.set.Keys)
                {
                    if (o2.set.Contains(ns))
                    {
                        nslist.set.Add(ns, ns);
                    }
                }
            }
            else if (o1.type == ListType.Other && o2.type == ListType.Other)
            {
                if (o1.targetNamespace == o2.targetNamespace)
                {
                    //negation of same namespace name
                    nslist = o1.Clone();
                    return(nslist);
                }

                if (!v1Compat)
                {
                    if (o1.targetNamespace == string.Empty)
                    {
                        // clause 6 - o1 is negation of absent
                        nslist = o2.Clone();
                    }
                    else if (o2.targetNamespace == string.Empty)
                    {
                        //clause 6 - o1 is negation of absent
                        nslist = o1.Clone();
                    }
                }

                //if it comes here, its not expressible //clause 5
            }

            return(nslist);
        }
Пример #15
0
        public static XObjectsNamespaceList Union(XObjectsNamespaceList o1, XObjectsNamespaceList o2, bool v1Compat)
        {
            XObjectsNamespaceList nslist = null;

            Debug.Assert(o1 != o2);
            if (o1.type == ListType.Any)
            {
                //clause 2 - o1 is Any
                nslist = new XObjectsNamespaceList();
            }
            else if (o2.type == ListType.Any)
            {
                //clause 2 - o2 is Any
                nslist = new XObjectsNamespaceList();
            }
            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 XObjectsNamespaceList("##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 XObjectsNamespaceList();
                    }
                    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 XObjectsNamespaceList();
                    }
                    else
                    {
                        //clause 6.2 - set S does not include absent, result is not(absent)
                        nslist = new XObjectsNamespaceList("##other", string.Empty);
                    }
                }
            }
            else if (o2.type == ListType.Set && o1.type == ListType.Other)
            {
                if (v1Compat)
                {
                    if (o2.set.Contains(o2.targetNamespace))
                    {
                        nslist = new XObjectsNamespaceList();
                    }
                    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 XObjectsNamespaceList();
                    }
                    else
                    {
                        //clause 6.2 - set S does not include absent, result is not(absent)
                        nslist = new XObjectsNamespaceList("##other", string.Empty);
                    }
                }
            }

            return(nslist);
        }