示例#1
0
        public static ITypeMapping Initialize(this ITypeMapping typeMapping)
        {
            typeMapping.Map <ReflectionLanguage>().To <CsharpLanguage>()
            .From("System.Array").To("Array").Namespace("System").FromSystem()
            .From("System.Boolean").To("bool").FromSystem()
            .From("System.Byte").To("byte").FromSystem()
            .From("System.Char").To("char").FromSystem()
            .From("System.DateTime").To("DateTime").Namespace("System").FromSystem()
            .From("System.Decimal").To("decimal").FromSystem()
            .From("System.Double").To("double").FromSystem()
            .From("System.Guid").To("Guid").Namespace("System").FromSystem()
            .From("System.Int16").To("short").FromSystem()
            .From("System.Int32").To("int").FromSystem()
            .From("System.Int64").To("long").FromSystem()
            .From("System.Object").To("object").FromSystem()
            .From("System.Single").To("float").FromSystem()
            .From("System.String").To("string").Nullable().FromSystem()
            .From("System.TimeSpan").To("TimeSpan").Namespace("System").FromSystem()
            .From("System.UInt16").To("ushort").FromSystem()
            .From("System.UInt32").To("uint").FromSystem()
            .From("System.UInt64").To("ulong").FromSystem()
            .From("System.Void").To("void").FromSystem()
            .From("System.Collections.Generic.ICollection").To("ICollection").Namespace("System.Collections.Generic").FromSystem()
            .From("System.Collections.Generic.IList").To("IList").Namespace("System.Collections.Generic").FromSystem()
            .From("System.Collections.Generic.List").To("List").Namespace("System.Collections.Generic").FromSystem()
            .From("System.Collections.Generic.IEnumerable").To("IEnumerable").Namespace("System.Collections.Generic").FromSystem()
            .From("System.Collections.Generic.Dictionary").To("Dictionary").Namespace("System.Collections.Generic").FromSystem()
            .From("System.Collections.Generic.IDictionary").To("IDictionary").Namespace("System.Collections.Generic").FromSystem()
            .From("System.Nullable").To("Nullable").Nullable().FromSystem();

            typeMapping.Map <ReflectionLanguage>().To <TypeScriptLanguage>()
            .From("System.Array").To("Array").Nullable().FromSystem().Default(Code.Instance.TypeScript("[]"))
            .From("System.Boolean").To("boolean").Nullable().FromSystem().Default(Code.Instance.Boolean(false))
            .From("System.Byte").To("number").Nullable().FromSystem().Default(Code.Instance.Number(0))
            .From("System.Char").To("number").Nullable().FromSystem().Default(Code.Instance.Number(0))
            .From("System.DateTime").To("Date").Nullable().FromSystem().Default(Code.Instance.New(Code.Instance.Type("Date"), Code.Instance.Number(0)))
            .From("System.Decimal").To("number").Nullable().FromSystem().Default(Code.Instance.Number(0))
            .From("System.Double").To("number").Nullable().FromSystem().Default(Code.Instance.Number(0))
            .From("System.Guid").To("string").Nullable().FromSystem()
            .From("System.Int16").To("number").Nullable().FromSystem().Default(Code.Instance.Number(0))
            .From("System.Int32").To("number").Nullable().FromSystem().Default(Code.Instance.Number(0))
            .From("System.Int64").To("number").Nullable().FromSystem().Default(Code.Instance.Number(0))
            .From("System.Object").To("unknown").Nullable().FromSystem()
            .From("System.Single").To("number").Nullable().FromSystem().Default(Code.Instance.Number(0))
            .From("System.String").To("string").Nullable().FromSystem()
            .From("System.TimeSpan").To("string").Nullable().FromSystem()
            .From("System.UInt16").To("number").Nullable().FromSystem().Default(Code.Instance.Number(0))
            .From("System.UInt32").To("number").Nullable().FromSystem().Default(Code.Instance.Number(0))
            .From("System.UInt64").To("number").Nullable().FromSystem().Default(Code.Instance.Number(0))
            .From("System.Void").To("void").Nullable().FromSystem()
            .From("System.Collections.Generic.ICollection").To("Array").Nullable().FromSystem().Default(Code.Instance.TypeScript("[]"))
            .From("System.Collections.Generic.IList").To("Array").Nullable().FromSystem().Default(Code.Instance.TypeScript("[]"))
            .From("System.Collections.Generic.List").To("Array").Nullable().FromSystem().Default(Code.Instance.TypeScript("[]"))
            .From("System.Collections.Generic.IEnumerable").To("Array").Nullable().FromSystem().Default(Code.Instance.TypeScript("[]"))
            .From("System.Collections.Generic.Dictionary").To("Dictionary").Nullable().FromSystem().Default(Code.Instance.TypeScript("{}"))
            .From("System.Collections.Generic.IDictionary").To("Dictionary").Nullable().FromSystem().Default(Code.Instance.TypeScript("{}"))
            .From("System.Nullable").To("Nullable").Nullable().FromSystem();

            return(typeMapping);
        }
示例#2
0
        public static ITypeMapping Initialize(this ITypeMapping typeMapping)
        {
            typeMapping.Map <SqliteLanguage>().To <CsharpLanguage>()
            .From(SqliteType.Real).To("double").FromSystem()
            .From(SqliteType.Numeric).To("double").FromSystem()
            .From(SqliteType.Integer).To("int").FromSystem()
            .From(SqliteType.Text).To("string").Nullable().FromSystem()
            .From(SqliteType.Blob).To("byte[]").Nullable().FromSystem();

            typeMapping.Map <ReflectionLanguage>().To <SqliteLanguage>()
            .From("System.Boolean").To(SqliteType.Integer)
            .From("System.Byte").To(SqliteType.Integer)
            .From("System.Char").To(SqliteType.Integer)
            .From("System.DateTime").To(SqliteType.Text)
            .From("System.Decimal").To(SqliteType.Integer)
            .From("System.Double").To(SqliteType.Integer)
            .From("System.Guid").To(SqliteType.Text)
            .From("System.Int16").To(SqliteType.Integer)
            .From("System.Int32").To(SqliteType.Integer)
            .From("System.Int64").To(SqliteType.Integer)
            .From("System.Single").To(SqliteType.Integer)
            .From("System.String").To(SqliteType.Text)
            .From("System.TimeSpan").To(SqliteType.Text)
            .From("System.UInt16").To(SqliteType.Integer)
            .From("System.UInt32").To(SqliteType.Integer)
            .From("System.UInt64").To(SqliteType.Integer);

            return(typeMapping);
        }
        public static ITypeMapping Initialize(this ITypeMapping typeMapping)
        {
            typeMapping.Map <JsonLanguage>().To <CsharpLanguage>()
            .From(JTokenType.Array.ToString()).To("List").Nullable().Namespace("System.Collections.Generic").FromSystem()
            .From(JTokenType.Boolean.ToString()).To("bool").FromSystem()
            .From(JTokenType.Bytes.ToString()).To("byte").FromSystem()
            .From(JTokenType.Integer.ToString()).To("int").FromSystem()
            .From(JTokenType.Float.ToString()).To("double").FromSystem()
            .From(JTokenType.String.ToString()).To("string").Nullable().FromSystem()
            .From(JTokenType.Date.ToString()).To("DateTime").Namespace("System").FromSystem()
            .From(JTokenType.Guid.ToString()).To("Guid").Namespace("System").FromSystem()
            .From(JTokenType.Uri.ToString()).To("Uri").Namespace("System").FromSystem()
            .From(JTokenType.TimeSpan.ToString()).To("TimeSpan").Namespace("System").FromSystem()
            .From(JTokenType.Object.ToString()).To("object").Nullable().FromSystem();

            typeMapping.Map <JsonLanguage>().To <TypeScriptLanguage>()
            .From(JTokenType.Array.ToString()).To("Array").Nullable().Namespace("System.Collections.Generic").FromSystem()
            .From(JTokenType.Boolean.ToString()).To("boolean").Nullable().FromSystem()
            .From(JTokenType.Bytes.ToString()).To("number").Nullable().FromSystem()
            .From(JTokenType.Integer.ToString()).To("number").Nullable().FromSystem()
            .From(JTokenType.Float.ToString()).To("number").Nullable().FromSystem()
            .From(JTokenType.String.ToString()).To("string").Nullable().FromSystem()
            .From(JTokenType.Date.ToString()).To("Date").Nullable().FromSystem()
            .From(JTokenType.Guid.ToString()).To("string").Nullable().FromSystem()
            .From(JTokenType.Uri.ToString()).To("string").Nullable().FromSystem()
            .From(JTokenType.TimeSpan.ToString()).To("string").Nullable().FromSystem()
            .From(JTokenType.Object.ToString()).To("Object").Nullable().FromSystem();

            return(typeMapping);
        }
示例#4
0
        public static ITypeMapping Initialize(this ITypeMapping typeMapping)
        {
            typeMapping.Map <OpenApiLanguage>().To <CsharpLanguage>()
            .From("array").To("List").Namespace("System.Collections.Generic").FromSystem()
            .From("string").To("string").Nullable().FromSystem()
            .From("boolean").To("bool").Nullable().FromSystem()
            .From("integer").To("int").Nullable().FromSystem()
            .From("number").To("double").Nullable().FromSystem();

            typeMapping.Map <OpenApiLanguage>().To <TypeScriptLanguage>()
            .From("array").To("Array").FromSystem()
            .From("string").To("string").Nullable().FromSystem()
            .From("boolean").To("boolean").Nullable().FromSystem()
            .From("integer").To("number").Nullable().FromSystem()
            .From("number").To("number").Nullable().FromSystem();

            return(typeMapping);
        }
示例#5
0
        public static ITypeMapping Initialize(this ITypeMapping typeMapping)
        {
            typeMapping.Map <TsqlLanguage>().To <CsharpLanguage>()
            .From("smallint").To("short").Nullable()
            .From("bigint").To("long").Nullable()
            .From("bit").To("bool").Nullable()
            .From("int").To("int").Nullable()
            .From("date").To("DateTime").Nullable().Namespace("System")
            .From("datetime").To("DateTime").Nullable().Namespace("System")
            .From("datetime2").To("DateTime").Nullable().Namespace("System")
            .From("decimal").To("decimal").Nullable()
            .From("nchar").To("string")
            .From("nvarchar").To("string")
            .From("char").To("string")
            .From("varchar").To("string")
            .From("varbinary").To("byte[]")
            .From("timestamp").To("byte[]")
            .From("uniqueidentifier").To("Guid").Namespace("System")
            .From("float").To("double").Nullable();

            typeMapping.Map <TsqlLanguage>().To <TypeScriptLanguage>()
            .From("smallint").To("number").Nullable()
            .From("bigint").To("number").Nullable()
            .From("bit").To("boolean").Nullable()
            .From("int").To("number").Nullable()
            .From("date").To("Date").Nullable()
            .From("datetime").To("Date").Nullable()
            .From("datetime2").To("Date").Nullable()
            .From("decimal").To("number").Nullable()
            .From("nchar").To("string").Nullable()
            .From("nvarchar").To("string").Nullable()
            .From("char").To("string").Nullable()
            .From("varchar").To("string").Nullable()
            .From("varbinary").To("number[]").Nullable()
            .From("timestamp").To("number[]").Nullable()
            .From("uniqueidentifier").To("string").Nullable()
            .From("float").To("number").Nullable();
            return(typeMapping);
        }
 public static ITypeMapping Initialize(this ITypeMapping typeMapping)
 {
     typeMapping.Map <ODataLanguage>().To <TypeScriptLanguage>()
     .From("Edm.Binary").To("string", "String")
     .From("Edm.Boolean").To("boolean", "Boolean")
     .From("Edm.Byte").To("number", "Number")
     .From("Edm.Date").To("Date")
     .From("Edm.DateTimeOffset").To("Date")
     .From("Edm.Decimal").To("number", "Number")
     .From("Edm.Double").To("number", "Number")
     .From("Edm.Decimal").To("number", "Number")
     .From("Edm.Duration").To("string", "String")
     .From("Edm.Guid").To("string", "String")
     .From("Edm.Int16").To("number", "Number")
     .From("Edm.Int32").To("number", "Number")
     .From("Edm.Int64").To("number", "Number")
     .From("Edm.SByte").To("number", "Number")
     .From("Edm.Single").To("number", "Number")
     .From("Edm.String").To("string", "String")
     .From("Edm.TimeOfDay").To("string", "String")
     .From("Edm.Void").To("void");
     return(typeMapping);
 }