Exemple #1
0
        public XName GetXmlTypeName(Type type)
        {
            if (type.IsNullable())
            {
                return(GetXmlTypeName(Nullable.GetUnderlyingType(type)));
            }

            switch (type.FullName)
            {
            case "System.Byte": return(XName.Get("byte", NamespaceConstants.XSD));

            case "System.DateTime": return(XName.Get("dateTime", NamespaceConstants.XSD));

            case "System.Boolean": return(XName.Get("boolean", NamespaceConstants.XSD));

            case "System.Single": return(XName.Get("float", NamespaceConstants.XSD));

            case "System.Double": return(XName.Get("double", NamespaceConstants.XSD));

            case "System.Decimal": return(XName.Get("decimal", NamespaceConstants.XSD));

            case "System.Int64": return(XName.Get("long", NamespaceConstants.XSD));

            case "System.Int32": return(XName.Get("int", NamespaceConstants.XSD));

            case "System.String": return(XName.Get("string", NamespaceConstants.XSD));
            }

            if (ReferenceEquals(type.GetTypeInfo().Assembly, contractAssembly))
            {
                return(XName.Get(type.Name, Protocol.ProducerNamespace));
            }

            throw XRoadException.AndmetüübileVastavNimeruumPuudub(type.FullName);
        }