Opc.Ua.EncodeableFactory.GetXmlName C# (CSharp) Method

GetXmlName() public static method

Returns the xml qualified name for the specified system type id.
Returns the xml qualified name for the specified system type id.
public static GetXmlName ( System systemType ) : XmlQualifiedName
systemType System The underlying type to query and return the Xml qualified name of
return System.Xml.XmlQualifiedName
        public static XmlQualifiedName GetXmlName(System.Type systemType)
		{
            if (systemType == null)
            {
                return null;
            }

            object[] attributes = systemType.GetTypeInfo().GetCustomAttributes(typeof(DataContractAttribute), true).ToArray();
            
            if (attributes != null)
            {
                for (int ii = 0; ii < attributes.Length; ii++)
                {
                    DataContractAttribute contract = attributes[ii] as DataContractAttribute;

                    if (contract != null)
                    {
                        if (String.IsNullOrEmpty(contract.Name))
                        {
                            return new XmlQualifiedName(systemType.Name, contract.Namespace);
                        }
                         
                        return new XmlQualifiedName(contract.Name, contract.Namespace);
                    }
                }                            
            }

            attributes = systemType.GetTypeInfo().GetCustomAttributes(typeof(CollectionDataContractAttribute), true).ToArray();
            
            if (attributes != null)
            {
                for (int ii = 0; ii < attributes.Length; ii++)
                {
                    CollectionDataContractAttribute contract = attributes[ii] as CollectionDataContractAttribute;

                    if (contract != null)
                    {
                        if (String.IsNullOrEmpty(contract.Name))
                        {
                            return new XmlQualifiedName(systemType.Name, contract.Namespace);
                        }
                         
                        return new XmlQualifiedName(contract.Name, contract.Namespace);
                    }
                }                            
            }
            
            return new XmlQualifiedName(systemType.FullName);
		}
		#endregion