1- using  System . Collections . Generic ; 
1+ using  System ; 
2+ using  System . Collections . Generic ; 
23using  System . Xml . Linq ; 
34using  System . Xml . Schema ; 
45
@@ -31,6 +32,8 @@ public RequestedAttribute(string name, string attributeValue, bool isRequired =
3132
3233        public  string  AttributeValueType  {  get ;  set ;  }  =  "xs:string" ; 
3334
35+         public  string  AttributeValueDataTypeNamespace  {  get ;  set ;  }  =  XmlSchema . Namespace ; 
36+ 
3437        public  string  AttributeValueTypeNamespace  {  get ;  set ;  }  =  XmlSchema . InstanceNamespace ; 
3538
3639        public  XElement  ToXElement ( ) 
@@ -54,13 +57,27 @@ protected IEnumerable<XObject> GetXContent()
5457                    Value  =  AttributeValue 
5558                } ; 
5659                attribVal . Add ( new  XAttribute ( Saml2MetadataConstants . SamlAssertionNamespaceNameX ,  Saml2MetadataConstants . SamlAssertionNamespace ) ) ; 
57-                 if  ( ! string . IsNullOrWhiteSpace ( AttributeValueType )  &&  ! string . IsNullOrWhiteSpace ( AttributeValueTypeNamespace ) ) 
60+                 if  ( ! string . IsNullOrWhiteSpace ( AttributeValueType )  &&  TryGetAttributeValueTypeNamespaceName ( out   var   attributeValueTypeNamespaceName )   &&   ! string . IsNullOrWhiteSpace ( AttributeValueDataTypeNamespace )   &&   ! string . IsNullOrWhiteSpace ( AttributeValueTypeNamespace ) ) 
5861                { 
59-                     attribVal . Add ( new  XAttribute ( Saml2MetadataConstants . XsiNamespaceNameX ,  AttributeValueTypeNamespace ) ) ; 
62+                     attribVal . Add ( new  XAttribute ( XNamespace . Xmlns  +  attributeValueTypeNamespaceName ,  AttributeValueDataTypeNamespace ) ) ; 
63+                     attribVal . Add ( new  XAttribute ( Saml2MetadataConstants . XsiInstanceNamespaceNameX ,  AttributeValueTypeNamespace ) ) ; 
6064                    attribVal . Add ( new  XAttribute ( XNamespace . Get ( AttributeValueTypeNamespace )  +  Saml2MetadataConstants . Message . Type ,  AttributeValueType ) ) ; 
6165                } 
6266                yield  return  attribVal ; 
6367            } 
6468        } 
69+ 
70+         private  bool  TryGetAttributeValueTypeNamespaceName ( out  string  attributeValueTypeNamespaceName ) 
71+         { 
72+             var  splitValues  =  AttributeValueType ? . Split ( ':' ) ; 
73+             if  ( splitValues ? . Length  ==  2 ) 
74+             { 
75+                 attributeValueTypeNamespaceName  =  splitValues [ 0 ] ; 
76+                 return  true ; 
77+             } 
78+ 
79+             attributeValueTypeNamespaceName  =  null ; 
80+             return  false ; 
81+         } 
6582    } 
6683} 
0 commit comments