protected override bool TryReadRoleDescriptor(XmlDictionaryReader reader, out RoleDescriptor role)
        {
            if (!reader.IsStartElement(Saml2MetadataConstants.Elements.RoleDescriptor, Saml2MetadataConstants.Namespace))
            {
                return(Out.False(out role));
            }

            var d = null as RoleDescriptor;

            if (reader.TryReadFederationEndpointType(out var type))
            {
                if (type == FederationEndpointType.ApplicationService)
                {
                    d = new ApplicationServiceDescriptor();
                }
                if (type == FederationEndpointType.AttributeService)
                {
                    d = new AttributeServiceDescriptor();
                }
                if (type == FederationEndpointType.PseudonymService)
                {
                    d = new PseudonymServiceDescriptor();
                }
                if (type == FederationEndpointType.SecurityTokenService)
                {
                    d = new SecurityTokenServiceDescriptor();
                }
            }
            if (d == null)
            {
                d = new RoleDescriptor();
            }
            ReadRoleDescriptorAttributes(reader, d);

            reader.ForEachChild(r => TryReadRoleDescriptorChild(r, d), out var signature);
            d.Signature = signature;

            role = d;
            return(true);
        }
        protected virtual void WritePseudonymServiceDescriptorChildren(XmlDictionaryWriter writer, PseudonymServiceDescriptor pseudonymServiceDescriptor)
        {
            if (pseudonymServiceDescriptor == null)
            {
                return;
            }
            if (!pseudonymServiceDescriptor.PseudonymServiceEndpoint.Any())
            {
                throw XmlWriterExceptionHelper.CreateRequiredChildElementMissingException(Saml2MetadataConstants.Elements.RoleDescriptor, pseudonymServiceDescriptor.GetXmlTypeName());
            }

            WriteWebServiceDescriptorChildren(writer, pseudonymServiceDescriptor);

            foreach (var pseudonymServiceEndpoint in pseudonymServiceDescriptor.PseudonymServiceEndpoint)
            {
                WsAddressingSerializer.WriteEndpointReferenceCollection(writer, Prefix, Elements.PseudonymServiceEndpoint, Namespace, pseudonymServiceEndpoint);
            }

            foreach (var singleSignOutNotificationEndpoint in pseudonymServiceDescriptor.SingleSignOutNotificationEndpoint)
            {
                WsAddressingSerializer.WriteEndpointReferenceCollection(writer, Prefix, Elements.SingleSignOutNotificationEndpoint, Namespace, singleSignOutNotificationEndpoint);
            }
        }
 protected virtual void WritePseudonymServiceDescriptorAttributes(XmlDictionaryWriter writer, PseudonymServiceDescriptor pseudonymServiceDescriptor)
 {
     WriteWebServiceDescriptorAttributes(writer, pseudonymServiceDescriptor);
 }
 protected virtual void ReadPseudonymServiceDescriptorAttributes(XmlDictionaryReader reader, PseudonymServiceDescriptor pseudonymServiceDescriptor)
 {
     // No default attributes
 }
        protected virtual bool TryReadPseudonymServiceDescriptorChild(XmlDictionaryReader reader, PseudonymServiceDescriptor pseudonymServiceDescriptor)
        {
            if (WsAddressingSerializer.TryReadEndpointReferenceCollection(reader, Elements.SingleSignOutNotificationEndpoint, Namespace, out var singleSignOutNotificationEndpoint))
            {
                pseudonymServiceDescriptor.SingleSignOutNotificationEndpoint.Add(singleSignOutNotificationEndpoint);
            }
            else if (WsAddressingSerializer.TryReadEndpointReferenceCollection(reader, Elements.PseudonymServiceEndpoint, Namespace, out var pseudonymServiceEndpoint))
            {
                pseudonymServiceDescriptor.PseudonymServiceEndpoint.Add(pseudonymServiceEndpoint);
            }
            else
            {
                return(TryReadWebServiceDescriptorChild(reader, pseudonymServiceDescriptor));
            }

            return(true);
        }