public override string ToString() => $"{PrimaryType.ToString()} of ({ElementType.ToString()})";
Beispiel #2
0
        private IType NormalizePrimaryType(PrimaryType primaryType)
        {
            if (primaryType.Type == KnownPrimaryType.Object)
            {
                return(new MapType(new InterfaceType()));
            }
            else if (primaryType.Type == KnownPrimaryType.Date)
            {
                return(new PackageType {
                    Import = "github.com/Azure/go-autorest/autorest/date", Member = "Date"
                });
            }
            else if (primaryType.Type == KnownPrimaryType.DateTimeRfc1123)
            {
                return(new PackageType {
                    Import = "github.com/Azure/go-autorest/autorest/date", Member = "TimeRFC1123"
                });
            }
            else if (primaryType.Type == KnownPrimaryType.DateTime)
            {
                return(new PackageType {
                    Import = "github.com/Azure/go-autorest/autorest/date", Member = "Time"
                });
            }
            else if (primaryType.Type == KnownPrimaryType.Decimal)
            {
                return(new PackageType {
                    Import = "github.com/shopspring/decimal", Member = "Decimal"
                });
            }
            else if (primaryType.Type == KnownPrimaryType.Uuid)
            {
                return(new PackageType {
                    Import = "github.com/satori/uuid", Member = "UUID"
                });
            }
            else
            {
                // The remaining Primary types normalize to the same object
                _normalizedTypes[primaryType] = primaryType;

                if (primaryType.Type == KnownPrimaryType.Boolean)
                {
                    primaryType.Name = "bool";
                }
                else if (primaryType.Type == KnownPrimaryType.ByteArray)
                {
                    primaryType.Name = "[]byte";
                }
                else if (primaryType.Type == KnownPrimaryType.Double)
                {
                    primaryType.Name = "float64";
                }
                else if (primaryType.Type == KnownPrimaryType.Int)
                {
                    primaryType.Name = "int32";
                }
                else if (primaryType.Type == KnownPrimaryType.Long)
                {
                    primaryType.Name = "int64";
                }
                else if (primaryType.Type == KnownPrimaryType.Stream)
                {
                    // Note:
                    // -- All streaming will be through instances of an io.ReadCloser
                    // -- When streaming to the server, the method will take an io.ReadCloser as the http.Request body
                    // -- When streaming from the servier, the method will return access to the (open) http.Response body
                    primaryType.Name = "io.ReadCloser";
                }
                else if (primaryType.Type == KnownPrimaryType.String)
                {
                    primaryType.Name = "string";
                }
                else if (primaryType.Type == KnownPrimaryType.TimeSpan)
                {
                    primaryType.Name = "string";
                }
                else if (primaryType.Type == KnownPrimaryType.Base64Url)
                {
                    //TODO: add base64Url type.
                    primaryType.Name = "string";
                }
                else if (primaryType.Type == KnownPrimaryType.UnixTime)
                {
                    //TODO: add unixtime type.
                    primaryType.Name = "string";
                }
                else
                {
                    throw new ArgumentException("Illegal primary type for Go: " + primaryType.ToString());
                }

                return(primaryType);
            }
        }
 public override string ToString() => PrimaryType.ToString();