YAXLib.YAXSerializer.AtLeastOneOfCollectionMembersExists C# (CSharp) Method

AtLeastOneOfCollectionMembersExists() private method

Checks whether at least one of the collection memebers of the specified collection exists.
private AtLeastOneOfCollectionMembersExists ( System.Xml.Linq.XElement elem, MemberWrapper member ) : bool
elem System.Xml.Linq.XElement The XML element to check its content.
member MemberWrapper The class-member corresponding to the collection for /// which we intend to check existence of its members.
return bool
        private bool AtLeastOneOfCollectionMembersExists(XElement elem, MemberWrapper member)
        {
            if (!((member.IsTreatedAsCollection || member.IsTreatedAsDictionary) && member.CollectionAttributeInstance != null &&
                member.CollectionAttributeInstance.SerializationType == YAXCollectionSerializationTypes.RecursiveWithNoContainingElement))
                throw new ArgumentException("member should be a collection serialized without containing element");

            XName eachElementName = null;

            if (member.CollectionAttributeInstance != null)
            {
                eachElementName = StringUtils.RefineSingleElement(member.CollectionAttributeInstance.EachElementName);
            }

            if (member.DictionaryAttributeInstance != null && member.DictionaryAttributeInstance.EachPairName != null)
            {
                eachElementName = StringUtils.RefineSingleElement(member.DictionaryAttributeInstance.EachPairName);
            }

            if (eachElementName == null)
            {
                Type colItemType = ReflectionUtils.GetCollectionItemType(member.MemberType);
                eachElementName = StringUtils.RefineSingleElement(ReflectionUtils.GetTypeFriendlyName(colItemType));
            }

            // return if such an element exists
            return (elem.Element(eachElementName.OverrideNsIfEmpty(member.Namespace.IfEmptyThen(TypeNamespace).IfEmptyThenNone())) != null);
        }