예제 #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);
                }
            }
        }
        /// <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);
        }
        /// <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);
        }
        /// <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);
        }
        /// <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);
 }
        /// <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);
        }
        /// <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);
            }
        }
        /// <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);
        }
        // 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();
     }
 /// <inheritdoc/>
 public bool GetExpectedElements(ExpectedChildren result)
 {
     result.Add(ElementType);
     return(true);
 }
예제 #28
0
 public virtual bool GetExpectedElements(ExpectedChildren result)
 {
     return(false);
 }