Example #1
0
        public static string GetXsdName(this SoalType type)
        {
            if (type is PrimitiveType)
            {
                string name = ((PrimitiveType)type).Name;
                switch (name)
                {
                case "int":
                case "long":
                case "float":
                case "double":
                case "string":
                case "byte":
                    return(name);

                case "object":
                    return("anyType");

                case "bool":
                    return("boolean");

                case "Date":
                    return("date");

                case "Time":
                    return("time");

                case "DateTime":
                    return("dateTime");

                case "TimeSpan":
                    return("duration");

                default:
                    break;
                }
            }
            if (type is NullableType)
            {
                return(GetXsdName(((NullableType)type).InnerType));
            }
            if (type is NonNullableType)
            {
                return(GetXsdName(((NonNullableType)type).InnerType));
            }
            if (type is ArrayType)
            {
                if (((ArrayType)type).InnerType == SoalInstance.Byte)
                {
                    return("base64Binary");
                }
                else
                {
                    return((GetXsdName(((ArrayType)type).InnerType) + "List").ToPascalCase());
                }
            }
            if (type is Enum)
            {
                Enum   etype   = (Enum)type;
                string newName = etype.GetAnnotationPropertyValue(SoalAnnotations.Type, SoalAnnotationProperties.Name) as string;
                return(newName ?? etype.Name);
            }
            if (type is Struct)
            {
                Struct stype   = (Struct)type;
                string newName = stype.GetAnnotationPropertyValue(SoalAnnotations.Type, SoalAnnotationProperties.Name) as string;
                return(newName ?? stype.Name);
            }
            return(null);
        }