public virtual IScalarType ImportType(string typeName, IAttributeTypeDefinitionImported attrTypeDef) { Metamodel.Type type = GenieLamp.Instance.Model.Types.GetByName(String.IsNullOrEmpty(typeName) ? "int" : typeName); if (type == null || !(type is ScalarType)) { type = GenieLamp.Instance.Model.Types.GetByName("int"); } return(type as ScalarType); }
public override IScalarType ImportType(string typeName, IAttributeTypeDefinitionImported attrTypeDef) { if (String.IsNullOrEmpty(typeName)) { return(base.ImportType(typeName, attrTypeDef)); } Metamodel.Type targetType = GenieLamp.Instance.Model.Types.GetByName("int", true); string srcTypeName = typeName.ToUpper(); if (srcTypeName == "NUMBER" || srcTypeName == "DECIMAL") { targetType = GenieLamp.Instance.Model.Types.GetByName("decimal", true); if (attrTypeDef.Precision == 0) { if (attrTypeDef.Length <= 19) { if (attrTypeDef.Length <= 3) { targetType = GenieLamp.Instance.Model.Types.GetByName("byte", true); } else if (attrTypeDef.Length <= 5) { targetType = GenieLamp.Instance.Model.Types.GetByName("shortint", true); } else if (attrTypeDef.Length > 10) { targetType = GenieLamp.Instance.Model.Types.GetByName("bigint", true); } else { targetType = GenieLamp.Instance.Model.Types.GetByName("int", true); } attrTypeDef.Length = 0; } } } else if (srcTypeName == "CHAR" || srcTypeName == "VARCHAR" || srcTypeName == "VARCHAR2") { if (attrTypeDef.Length == 1) { targetType = GenieLamp.Instance.Model.Types.GetByName("ansichar", true); attrTypeDef.Length = 0; } else { targetType = GenieLamp.Instance.Model.Types.GetByName("ansistring", true); } } else if (srcTypeName == "NCHAR" || srcTypeName == "NVARCHAR" || srcTypeName == "NVARCHAR2") { if (attrTypeDef.Length == 1) { targetType = GenieLamp.Instance.Model.Types.GetByName("char", true); attrTypeDef.Length = 0; } else { targetType = GenieLamp.Instance.Model.Types.GetByName("string", true); } } else if (srcTypeName == "DATE") { targetType = GenieLamp.Instance.Model.Types.GetByName("datetime", true); attrTypeDef.Length = 0; } else if (srcTypeName == "BINARY_DOUBLE") { targetType = GenieLamp.Instance.Model.Types.GetByName("float", true); attrTypeDef.Length = 0; } else if (srcTypeName == "BLOB") { targetType = GenieLamp.Instance.Model.Types.GetByName("blob", true); } return(targetType as ScalarType); }