コード例 #1
0
        /// <summary>
        /// Get the required elements - elements which minOccurs > 0.
        /// </summary>
        /// <param name="result"></param>
        /// <returns>True if there are required elements in this particle.</returns>
        public override bool GetRequiredElements(ExpectedChildren result)
        {
            bool requiredElements       = true;
            var  requiredChoiceChildren = new ExpectedChildren();

            // if there are any child elements that minOccurs = 0, then there is no requried children.

            if (this.ParticleConstraint.MinOccurs > 0)
            {
                foreach (var constraint in this.ParticleConstraint.ChildrenParticles)
                {
                    if (!constraint.ParticleValidator.GetRequiredElements(requiredChoiceChildren))
                    {
                        requiredElements = false;
                    }
                }


                if (requiredElements && result != null)
                {
                    result.Add(requiredChoiceChildren);
                }

                return(requiredElements);
            }
            else
            {
                return(false);
            }
        }
コード例 #2
0
        /// <summary>
        /// Add all expected children from another ExpectedChildren.
        /// </summary>
        /// <param name="expectedChildren"></param>
        internal void Add(ExpectedChildren expectedChildren)
        {
            if (expectedChildren._elementTypeIds != null &&
                expectedChildren._elementTypeIds.Count > 0)
            {
                // No lock, not safe for multi-thread
                if (this._elementTypeIds == null)
                {
                    this._elementTypeIds = new List <int>();
                }

                foreach (var id in expectedChildren._elementTypeIds)
                {
                    this._elementTypeIds.Add(id);
                }
            }

            if (expectedChildren._xsdanyNamespaces != null &&
                expectedChildren._xsdanyNamespaces.Count > 0)
            {
                // No lock, not safe for multi-thread
                if (this._xsdanyNamespaces == null)
                {
                    this._xsdanyNamespaces = new List <string>();
                }

                foreach (var ns in expectedChildren._xsdanyNamespaces)
                {
                    this._xsdanyNamespaces.Add(ns);
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Get the expected elements - elements which minOccurs >= 0.
        /// </summary>
        /// <returns>Expected elements in this particle.</returns>
        public ExpectedChildren GetExpectedElements()
        {
            ExpectedChildren expectedElements = new ExpectedChildren();

            expectedElements.Add(this.ElementId);

            return(expectedElements);
        }
コード例 #4
0
        /// <summary>
        /// Get the required elements - elements which minOccurs > 0.
        /// </summary>
        /// <returns>Required elements in this particle.</returns>
        public ExpectedChildren GetRequiredElements()
        {
            ExpectedChildren requiredElements = new ExpectedChildren();

            this.GetRequiredElements(requiredElements);

            return(requiredElements);
        }
コード例 #5
0
        /// <summary>
        /// Get the expected elements - elements which minOccurs >= 0.
        /// </summary>
        /// <returns>Expected elements in this particle.</returns>
        public ExpectedChildren GetExpectedElements()
        {
            ExpectedChildren expectedElements = new ExpectedChildren();

            this.GetExpectedElements(expectedElements);

            return(expectedElements);
        }
コード例 #6
0
        /// <summary>
        /// Get the expected elements - elements which minOccurs >= 0.
        /// </summary>
        /// <param name="result"></param>
        /// <returns>True if there are expected elements in this particle.</returns>
        public virtual bool GetExpectedElements(ExpectedChildren result)
        {
            if (result != null)
            {
                result.Add(XsdAnyPrefidefinedValue.GetNamespaceString(this._particleConstraint.NamespaceValue));
            }

            return(true);
        }
コード例 #7
0
        /// <summary>
        /// Get the expected elements - elements which minOccurs >= 0.
        /// </summary>
        /// <param name="result"></param>
        /// <returns>True if there are expected elements in this particle.</returns>
        public override bool GetExpectedElements(ExpectedChildren result)
        {
            foreach (var constraint in this.ParticleConstraint.ChildrenParticles)
            {
                constraint.ParticleValidator.GetExpectedElements(result);
            }

            return(true);
        }
コード例 #8
0
        /// <summary>
        /// Get the expected elements - elements which minOccurs >= 0.
        /// </summary>
        /// <param name="result"></param>
        /// <returns>True if there are expected elements in this particle.</returns>
        public override bool GetExpectedElements(ExpectedChildren result)
        {
            if (result != null)
            {
                result.Add(NamespaceIdMap.GetNamespaceUri(this._nsAnyParticleConstraint.NamespaceId));
            }

            return(true);
        }
コード例 #9
0
        /// <summary>
        /// Get the required elements - elements which minOccurs > 0.
        /// </summary>
        /// <returns>Required elements in this particle.</returns>
        public ExpectedChildren GetRequiredElements()
        {
            ExpectedChildren requiredElements = new ExpectedChildren();

            if (this.MinOccurs > 0)
            {
                requiredElements.Add(this.ElementId);
            }

            return(requiredElements);
        }
コード例 #10
0
 /// <summary>
 /// The .ExpectedChildren will be non-null after this call.
 /// </summary>
 internal void InitExpectedChildren()
 {
     if (this.ExpectedChildren == null)
     {
         this.ExpectedChildren = new ExpectedChildren();
     }
     else
     {
         this.ExpectedChildren.Clear();
     }
 }
コード例 #11
0
        internal static string GetExpectedChildrenMessage(OpenXmlElement parent, ExpectedChildren expectedChildrenIds)
        {
            Debug.Assert(parent != null);

            if (expectedChildrenIds != null)
            {
                return(expectedChildrenIds.GetExpectedChildrenMessage(parent));
            }

            return(string.Empty);
        }
コード例 #12
0
 /// <summary>
 /// Get the required elements - elements which minOccurs > 0.
 /// </summary>
 /// <param name="result"></param>
 /// <returns>True if there are required elements in this particle.</returns>
 public bool GetRequiredElements(ExpectedChildren result)
 {
     if (this.MinOccurs > 0)
     {
         if (result != null)
         {
             result.Add(this.ElementId);
         }
         return(true);
     }
     return(false);
 }
コード例 #13
0
        /// <summary>
        /// Get the expected elements - elements which minOccurs >= 0.
        /// </summary>
        /// <param name="result"></param>
        /// <returns>True if there are expected elements in this particle.</returns>
        public override bool GetExpectedElements(ExpectedChildren result)
        {
            if (this.ParticleConstraint.ChildrenParticles.Length > 0)
            {
                // sequence, return only the first child.
                this.ParticleConstraint.ChildrenParticles[0].ParticleValidator.GetExpectedElements(result);

                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #14
0
        /// <summary>
        /// Get the required elements - elements which minOccurs > 0.
        /// </summary>
        /// <param name="result"></param>
        /// <returns>True if there are required elements in this particle.</returns>
        public override bool GetRequiredElements(ExpectedChildren result)
        {
            bool requiredElements = false;

            if (this._particleConstraint.MinOccurs > 0)
            {
                foreach (var constraint in this._particleConstraint.ChildrenParticles)
                {
                    if (constraint.ParticleValidator.GetRequiredElements(result))
                    {
                        requiredElements = true;
                    }
                }
            }
            return(requiredElements);
        }
コード例 #15
0
 /// <summary>
 /// Purpose:
 /// Resue this.ExpectedChildren data field.
 /// Avoid this.ExpectedChildren be referenced by more than one object (so "this.ExpectedChildren = other.ExpectedChildren" is not allowed).
 /// </summary>
 /// <param name="expectedChildren"></param>
 internal void SetExpectedChildren(ExpectedChildren expectedChildren)
 {
     if (expectedChildren == null || expectedChildren.Count == 0)
     {
         if (this.ExpectedChildren != null)
         {
             this.ExpectedChildren.Clear();
         }
         // else, both are null, just return, nothing to do.
     }
     else
     {
         if (this.ExpectedChildren == null)
         {
             this.ExpectedChildren = new ExpectedChildren();
         }
         this.ExpectedChildren.Clear();
         this.ExpectedChildren.Add(expectedChildren);
     }
 }
コード例 #16
0
        /// <summary>
        /// Get the expected elements - elements which minOccurs >= 0.
        /// </summary>
        /// <param name="result"></param>
        /// <returns>True if there are expected elements in this particle.</returns>
        public virtual bool GetExpectedElements(ExpectedChildren result)
        {
            if (result != null)
            {
                result.Add(XsdAnyPrefidefinedValue.GetNamespaceString(this._particleConstraint.NamespaceValue));
            }

            return true;
        }
コード例 #17
0
        /// <summary>
        /// Get the required elements - elements which minOccurs > 0.
        /// </summary>
        /// <param name="result"></param>
        /// <returns>True if there are required elements in this particle.</returns>
        public override bool GetRequiredElements(ExpectedChildren result)
        {
            bool requiredElements = true;
            var requiredChoiceChildren = new ExpectedChildren();

            // if there are any child elements that minOccurs = 0, then there is no requried children.

            if (this.ParticleConstraint.MinOccurs > 0)
            {
                foreach (var constraint in this.ParticleConstraint.ChildrenParticles)
                {
                    if (!constraint.ParticleValidator.GetRequiredElements(requiredChoiceChildren))
                    {
                        requiredElements = false;
                    }
                }


                if (requiredElements && result != null)
                {
                    result.Add(requiredChoiceChildren);
                }

                return requiredElements;
            }
            else
            {
                return false;
            }
        }        
コード例 #18
0
 /// <summary>
 /// Get the required elements - elements which minOccurs > 0.
 /// </summary>
 /// <param name="result"></param>
 /// <returns>True if there are required elements in this particle.</returns>
 public virtual bool GetRequiredElements(ExpectedChildren result)
 {
     return(false);
 }
コード例 #19
0
        /// <summary>
        /// Get the expected elements - elements which minOccurs >= 0.
        /// </summary>
        /// <param name="result"></param>
        /// <returns>True if there are expected elements in this particle.</returns>
        public override bool GetExpectedElements(ExpectedChildren result)
        {
            if (this.ParticleConstraint.ChildrenParticles.Length > 0)
            {
                // sequence, return only the first child.
                this.ParticleConstraint.ChildrenParticles[0].ParticleValidator.GetExpectedElements(result);

                return true;
            }
            else
            {
                return false;
            }
        }
コード例 #20
0
        internal static string GetExpectedChildrenMessage(OpenXmlElement parent, ExpectedChildren expectedChildrenIds)
        {
            Debug.Assert(parent != null);

            if (expectedChildrenIds != null)
            {
                return expectedChildrenIds.GetExpectedChildrenMessage(parent);
            }

            return string.Empty;
        }
コード例 #21
0
        /// <summary>
        /// Get the expected elements - elements which minOccurs >= 0.
        /// </summary>
        /// <param name="result"></param>
        /// <returns>True if there are expected elements in this particle.</returns>
        public override bool GetExpectedElements(ExpectedChildren result)
        {
            foreach (var constraint in this.ParticleConstraint.ChildrenParticles)
            {
                constraint.ParticleValidator.GetExpectedElements(result);
            }

            return true;
        }
コード例 #22
0
 /// <summary>
 /// Get the required elements - elements which minOccurs > 0.
 /// </summary>
 /// <param name="result"></param>
 /// <returns>True if there are required elements in this particle.</returns>
 public bool GetRequiredElements(ExpectedChildren result)
 {
     if (this.MinOccurs > 0)
     {
         if (result != null)
         {
             result.Add(this.ElementId);
         }
         return true;
     }
     return false;
 }
コード例 #23
0
        /// <summary>
        /// Get the expected elements - elements which minOccurs >= 0.
        /// </summary>
        /// <param name="result"></param>
        /// <returns>True if there are expected elements in this particle.</returns>
        public override bool GetExpectedElements(ExpectedChildren result)
        {
            if (result != null)
            {
                result.Add(NamespaceIdMap.GetNamespaceUri(this._nsAnyParticleConstraint.NamespaceId));
            }

            return true;
        }
コード例 #24
0
        // TODO: do better job for simple sequence ( children are elements only ).


        /// <summary>
        /// Get the required elements - elements which minOccurs > 0.
        /// </summary>
        /// <param name="result"></param>
        /// <returns>True if there are required elements in this particle.</returns>
        public override bool GetRequiredElements(ExpectedChildren result)
        {
            bool requiredElements = false;

            if (this.ParticleConstraint.MinOccurs > 0)
            {
                foreach (var constraint in this.ParticleConstraint.ChildrenParticles)
                {
                    if (constraint.ParticleValidator.GetRequiredElements(result))
                    {
                        requiredElements = true;
                        break; // return the first required element in sequence.
                    }
                }
            }
            return requiredElements;
        }
コード例 #25
0
 /// <summary>
 /// Get the expected elements - elements which minOccurs >= 0.
 /// </summary>
 /// <param name="result"></param>
 /// <returns>True if there are expected elements in this particle.</returns>
 public virtual bool GetExpectedElements(ExpectedChildren result)
 {
     return false;
 }
コード例 #26
0
        /// <summary>
        /// Get the required elements - elements which minOccurs > 0.
        /// </summary>
        /// <returns>Required elements in this particle.</returns>
        public ExpectedChildren GetRequiredElements()
        {
            ExpectedChildren requiredElements = new ExpectedChildren();

            this.GetRequiredElements(requiredElements);

            return requiredElements;
        }
コード例 #27
0
        /// <summary>
        /// Get the required elements - elements which minOccurs > 0.
        /// </summary>
        /// <returns>Required elements in this particle.</returns>
        public ExpectedChildren GetRequiredElements()
        {
            ExpectedChildren requiredElements = new ExpectedChildren();

            if (this.MinOccurs > 0)
            {
                requiredElements.Add(this.ElementId);
            }

            return requiredElements;
        }
コード例 #28
0
 /// <summary>
 /// Get the expected elements - elements which minOccurs >= 0.
 /// </summary>
 /// <param name="result"></param>
 /// <returns>True if there are expected elements in this particle.</returns>
 public bool GetExpectedElements(ExpectedChildren result)
 {
     result.Add(this.ElementId);
     return(true);
 }
コード例 #29
0
 /// <summary>
 /// Get the expected elements - elements which minOccurs >= 0.
 /// </summary>
 /// <param name="result"></param>
 /// <returns>True if there are expected elements in this particle.</returns>
 public bool GetExpectedElements(ExpectedChildren result)
 {
     result.Add(this.ElementId);
     return true;
 }
コード例 #30
0
        /// <summary>
        /// Get the expected elements - elements which minOccurs >= 0.
        /// </summary>
        /// <returns>Expected elements in this particle.</returns>
        public ExpectedChildren GetExpectedElements()
        {
            ExpectedChildren expectedElements = new ExpectedChildren();

            this.GetExpectedElements(expectedElements);

            return expectedElements;
        }
コード例 #31
0
        /// <summary>
        /// Get the expected elements - elements which minOccurs >= 0.
        /// </summary>
        /// <returns>Expected elements in this particle.</returns>
        public ExpectedChildren GetExpectedElements()
        {
            ExpectedChildren expectedElements = new ExpectedChildren();

            expectedElements.Add(this.ElementId);

            return expectedElements;
        }