string GetVariableDeclaration(SqlType sqlType, bool suppressSize, int?length) { string result = null; if (typeNames == null) { typeNames = new NLite.Data.Schema.Script.Generator.SqlServerScriptGenerator().typeNames; } if (!suppressSize) { result = typeNames.Get(sqlType.DbType); } else if (sqlType.Length > 0 || sqlType.Precision > 0 || sqlType.Scale > 0) { result = typeNames.Get(sqlType.DbType, sqlType.Length, sqlType.Precision, sqlType.Scale); } else { result = typeNames.Get(sqlType.DbType); } if (result == null) { throw new InvalidCastException(string.Format(Res.CastTypeInvalid, sqlType)); } return(result); }
public void WriteComponent <T>(int maxCapacity) { string shortName = typeof(T).Name; int repeatCount = 1; while (_types.ContainsValue(shortName)) { shortName = $"{typeof(T).Name}_{repeatCount++}"; } _types.Add(typeof(T), shortName); _writer.Write(nameof(EntryType.ComponentType)); _writer.WriteSpace(); _writer.Write(shortName); _writer.WriteSpace(); _writer.WriteLine(TypeNames.Get(typeof(T))); if (maxCapacity != _worldMaxCapacity && !typeof(T).GetTypeInfo().IsFlagType()) { _writer.Write(nameof(EntryType.ComponentMaxCapacity)); _writer.WriteSpace(); _writer.Write(shortName); _writer.WriteSpace(); _writer.Stream.WriteLine(maxCapacity); } }
void IComponentTypeReader.OnRead <T>(int maxCapacity) { string shortName = typeof(T).Name; int repeatCount = 1; while (_types.ContainsValue(shortName)) { shortName = $"{typeof(T).Name}_{repeatCount++}"; } _types.Add(typeof(T), shortName); _writer.WriteLine($"{nameof(EntryType.ComponentType)} {shortName} {TypeNames.Get(typeof(T))}"); if (maxCapacity != _worldMaxCapacity && !typeof(T).GetTypeInfo().IsFlagType()) { _writer.WriteLine($"{nameof(EntryType.ComponentMaxCapacity)} {shortName} {maxCapacity}"); } }
/// <summary> /// 得到对应的数据库类型 /// </summary> /// <param name="sqlType"></param> /// <returns></returns> public string GetDbType(SqlType sqlType) { return(typeNames.Get(sqlType.DbType, sqlType.Length, sqlType.Precision, sqlType.Scale)); }