public static SqlType Resolve(SqlTypeCode typeCode, string typeName, DataTypeMeta[] metadata, ITypeResolver resolver) { if (PrimitiveTypes.IsPrimitive(typeCode)) { return(PrimitiveTypes.Resolve(typeCode, typeName, metadata)); } if (resolver == null) { throw new NotSupportedException(String.Format("Cannot resolve type '{0}' without context.", typeName)); } var resolveCcontext = new TypeResolveContext(typeCode, typeName, metadata); return(resolver.ResolveType(resolveCcontext)); }
public static SqlType ResolveType(this IContext context, string typeName, params DataTypeMeta[] meta) { if (PrimitiveTypes.IsPrimitive(typeName)) { return(PrimitiveTypes.Resolve(typeName, meta)); } var resolvers = context.ResolveAllServices <ITypeResolver>(); foreach (var resolver in resolvers) { var sqlType = resolver.ResolveType(new TypeResolveContext(SqlTypeCode.Unknown, typeName, meta)); if (sqlType != null) { return(sqlType); } } return(null); }
public SqlType Parse(IContext context, string s) { var typeInfo = PlSqlParser.ParseType(s); if (PrimitiveTypes.IsPrimitive(typeInfo.TypeName)) { return(PrimitiveTypes.Resolver.Resolve(typeInfo)); } if (context == null) { throw new Exception($"Type {typeInfo.TypeName} is not primitive and no context is provided"); } var resolver = context.Scope.Resolve <ISqlTypeResolver>(); if (resolver == null) { throw new InvalidOperationException($"The type {typeInfo.TypeName} is not primitive and no resolver was found in context"); } return(resolver.Resolve(typeInfo)); }
public static void IsCodePrimitive(SqlTypeCode typeCode, bool expected) { Assert.Equal(expected, PrimitiveTypes.IsPrimitive(typeCode)); }
public static void IsStringPrimitive(string name, bool expected) { Assert.Equal(expected, PrimitiveTypes.IsPrimitive(name)); }
public static bool IsPrimitiveType(SqlTypeCode typeCode) { return(PrimitiveTypes.IsPrimitive(typeCode)); }