SchemaZen.Library.Models.Column.ScriptBase C# (CSharp) Method

ScriptBase() private method

private ScriptBase ( bool includeDefaultConstraint ) : string
includeDefaultConstraint bool
return string
        private string ScriptBase(bool includeDefaultConstraint)
        {
            if (string.IsNullOrEmpty(ComputedDefinition)) {
                switch (Type) {
                    case "bigint":
                    case "bit":
                    case "date":
                    case "datetime":
                    case "datetime2":
                    case "datetimeoffset":
                    case "float":
                    case "hierarchyid":
                    case "image":
                    case "int":
                    case "money":
                    case "ntext":
                    case "real":
                    case "smalldatetime":
                    case "smallint":
                    case "smallmoney":
                    case "sql_variant":
                    case "text":
                    case "time":
                    case "timestamp":
                    case "tinyint":
                    case "uniqueidentifier":
                    case "geography":
                    case "xml":
                    case "sysname":
                        return string.Format("[{0}] [{1}] {2} {3} {4} {5}", Name, Type, IsNullableText,
                            includeDefaultConstraint ? DefaultText : string.Empty, IdentityText, RowGuidColText);
                    case "binary":
                    case "char":
                    case "nchar":
                    case "nvarchar":
                    case "varbinary":
                    case "varchar":
                        var lengthString = Length.ToString();
                        if (lengthString == "-1") lengthString = "max";

                        return string.Format("[{0}] [{1}]({2}) {3} {4}", Name, Type, lengthString, IsNullableText,
                            includeDefaultConstraint ? DefaultText : string.Empty);
                    case "decimal":
                    case "numeric":

                        return string.Format("[{0}] [{1}]({2},{3}) {4} {5} {6}", Name, Type, Precision, Scale, IsNullableText,
                            includeDefaultConstraint ? DefaultText : string.Empty, IdentityText);
                    default:
                        throw new NotSupportedException("Error scripting column " + Name + ". SQL data type " + Type + " is not supported.");
                }
            }
            return string.Format("[{0}] AS {1}", Name, ComputedDefinition);
        }