コード例 #1
0
        /// <summary>
        /// Add all expected children from another ExpectedChildren.
        /// </summary>
        /// <param name="expectedChildren"></param>
        internal void Add(ExpectedChildren expectedChildren)
        {
            if (expectedChildren._elementTypes is not null &&
                expectedChildren._elementTypes.Count > 0)
            {
                // No lock, not safe for multi-thread
                if (_elementTypes is null)
                {
                    _elementTypes = new List <Type>();
                }

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

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

                foreach (var ns in expectedChildren._xsdanyNamespaces)
                {
                    _xsdanyNamespaces.Add(ns);
                }
            }
        }
コード例 #2
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 required children.
            if (ParticleConstraint.MinOccurs > 0)
            {
                foreach (var constraint in ParticleConstraint.ChildrenParticles)
                {
                    if (!constraint.ParticleValidator.GetRequiredElements(requiredChoiceChildren))
                    {
                        requiredElements = false;
                    }
                }

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

                return(requiredElements);
            }
            else
            {
                return(false);
            }
        }
コード例 #3
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();

            GetRequiredElements(requiredElements);

            return(requiredElements);
        }
コード例 #4
0
        /// <inheritdoc/>
        public ExpectedChildren GetExpectedElements()
        {
            var expectedElements = new ExpectedChildren();

            expectedElements.Add(ElementType);

            return(expectedElements);
        }
コード例 #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();

            GetExpectedElements(expectedElements);

            return(expectedElements);
        }
コード例 #6
0
        /// <inheritdoc/>
        public ExpectedChildren GetExpectedElements()
        {
            ExpectedChildren expectedElements = new ExpectedChildren();

            expectedElements.Add(this.ElementId);

            return(expectedElements);
        }
コード例 #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 virtual bool GetExpectedElements(ExpectedChildren result)
        {
            if (result != null)
            {
                result.Add(_particleConstraint.NamespaceValue.GetNamespaceString());
            }

            return(true);
        }
コード例 #8
0
        internal static string GetExpectedChildrenMessage(OpenXmlElement parent, ExpectedChildren expectedChildrenIds)
        {
            if (expectedChildrenIds is not null)
            {
                return(expectedChildrenIds.GetExpectedChildrenMessage(parent));
            }

            return(string.Empty);
        }
コード例 #9
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);
        }
コード例 #10
0
        public override bool GetExpectedElements(ExpectedChildren result)
        {
            foreach (var constraint in ParticleConstraint.ChildrenParticles)
            {
                constraint.ParticleValidator.GetExpectedElements(result);
            }

            return(true);
        }
コード例 #11
0
        /// <inheritdoc/>
        public ExpectedChildren GetRequiredElements()
        {
            var requiredElements = new ExpectedChildren();

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

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

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

            return(string.Empty);
        }
コード例 #13
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();
     }
 }
コード例 #14
0
 internal void InitExpectedChildren()
 {
     if (ExpectedChildren is null)
     {
         ExpectedChildren = new ExpectedChildren();
     }
     else
     {
         ExpectedChildren.Clear();
     }
 }
コード例 #15
0
        internal void SetExpectedChildren(ExpectedChildren expectedChildren)
        {
            if (expectedChildren is null || expectedChildren.Count == 0)
            {
                if (ExpectedChildren is not null)
                {
                    ExpectedChildren.Clear();
                }

                // else, both are null, just return, nothing to do.
            }
コード例 #16
0
        /// <inheritdoc/>
        public ExpectedChildren GetRequiredElements()
        {
            ExpectedChildren requiredElements = new ExpectedChildren();

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

            return(requiredElements);
        }
コード例 #17
0
 /// <inheritdoc/>
 public bool GetRequiredElements(ExpectedChildren result)
 {
     if (this.MinOccurs > 0)
     {
         if (result != null)
         {
             result.Add(this.ElementId);
         }
         return(true);
     }
     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 override bool GetRequiredElements(ExpectedChildren result)
        {
            if (ParticleConstraint.MinOccurs > 0)
            {
                if (result != null)
                {
                    result.Add(NamespaceIdMap.GetNamespaceUri(_nsAnyParticleConstraint.NamespaceId));
                }

                return(true);
            }
            return(false);
        }
コード例 #19
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)
        {
            if (ParticleConstraint.MinOccurs > 0)
            {
                if (result != null)
                {
                    result.Add(XsdAnyPrefidefinedValue.GetNamespaceString(_particleConstraint.NamespaceValue));
                }

                return(true);
            }
            return(false);
        }
コード例 #20
0
        public bool GetRequiredElements(ExpectedChildren result)
        {
            if (MinOccurs > 0)
            {
                if (result is not null)
                {
                    result.Add(ElementType);
                }

                return(true);
            }

            return(false);
        }
コード例 #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)
        {
            if (this.ParticleConstraint.ChildrenParticles.Length > 0)
            {
                // sequence, return only the first child.
                this.ParticleConstraint.ChildrenParticles[0].ParticleValidator.GetExpectedElements(result);

                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #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 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);
        }
コード例 #23
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 (ParticleConstraint.MinOccurs > 0)
            {
                foreach (var constraint in ParticleConstraint.ChildrenParticles)
                {
                    if (constraint.ParticleValidator.GetRequiredElements(result))
                    {
                        requiredElements = true;
                        break; // return the first required element in sequence.
                    }
                }
            }
            return(requiredElements);
        }
コード例 #24
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);
     }
 }
コード例 #25
0
 /// <inheritdoc/>
 public bool GetExpectedElements(ExpectedChildren result)
 {
     result.Add(this.ElementId);
     return(true);
 }
コード例 #26
0
 /// <summary>
 /// Purpose:
 /// Reuse 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 is null || expectedChildren.Count == 0)
     {
         ExpectedChildren.Clear();
     }
コード例 #27
0
 /// <inheritdoc/>
 public bool GetExpectedElements(ExpectedChildren result)
 {
     result.Add(ElementType);
     return(true);
 }
コード例 #28
0
 public virtual bool GetExpectedElements(ExpectedChildren result)
 {
     return(false);
 }