public static string DataType(WDataTypeReference dtype)
        {
            switch (dtype.GetType().Name)
            {
            case "SqlDataTypeReference":
            {
                var sqltype = dtype as WSqlDataTypeReference;
                var sb      = new StringBuilder(1024);
                sb.Append(WSchemaObjectName(sqltype.Name));
                if (sqltype.Parameters.Any())
                {
                    sb.Append("(");
                    for (var j = 0; j < sqltype.Parameters.Count; ++j)
                    {
                        if (j > 0)
                        {
                            sb.Append(", ");
                        }
                        sb.Append(sqltype.Parameters[j].Value);
                    }
                    sb.Append(")");
                }
                return(sb.ToString());
            }

            default:
                return("");
            }
        }
Exemplo n.º 2
0
        //private static bool ParseXmlDataType(
        //    IList<TSqlParserToken> tokens,
        //    ref int nextToken,
        //    ref WDataTypeReference result,
        //    ref int farestError)
        //{
        //    var firstToken = nextToken;
        //    var currentToken = nextToken;
        //    WSchemaObjectName varName = null;
        //    WSchemaObjectName xmlSchemaCollection = null;
        //    if (!ParseSchemaObjectName(tokens, ref currentToken, ref varName, ref farestError))
        //        return false;
        //    var xmlDataTypeOption = XmlDataTypeOption.None;
        //    if (ReadToken(tokens, "(", ref currentToken, ref farestError))
        //    {
        //        if (ReadToken(tokens, "document", ref currentToken, ref farestError))
        //            xmlDataTypeOption = XmlDataTypeOption.Document;
        //        else if (ReadToken(tokens, "content", ref currentToken, ref farestError))
        //            xmlDataTypeOption = XmlDataTypeOption.Content;
        //        if (!ParseSchemaObjectName(tokens, ref currentToken, ref xmlSchemaCollection, ref farestError))
        //            return false;
        //        if (!ReadToken(tokens, ")", ref currentToken, ref farestError))
        //            return false;
        //    }
        //    var dataTypeReference = new WXmlDataTypeReference
        //    {
        //        Name = varName,
        //        XmlDataTypeOption = xmlDataTypeOption,
        //        XmlSchemaCollection = xmlSchemaCollection,
        //        FirstTokenIndex = firstToken,
        //        LastTokenIndex = currentToken - 1,
        //    };
        //    nextToken = currentToken;
        //    result = dataTypeReference;
        //    return true;
        //}

        private static bool ParseDataType(
            IList<TSqlParserToken> tokens,
            ref int nextToken,
            ref WDataTypeReference result,
            ref int farestError)
        {
            return (ParseParameterizedDataType(tokens, ref nextToken, ref result, ref farestError));
        }
Exemplo n.º 3
0
        private static bool ParseParameterizedDataType(
            IList<TSqlParserToken> tokens,
            ref int nextToken,
            ref WDataTypeReference result,
            ref int farestError)
        {
            var firstToken = nextToken;
            var currentToken = nextToken;
            WSchemaObjectName varName = null;
            if (!ParseSchemaObjectName(tokens, ref currentToken, ref varName, ref farestError))
                return false;
            List<Literal> parameters = null;
            ParseLiteralList(tokens, ref currentToken, ref parameters, ref farestError);

            var dataTypeReference = new WParameterizedDataTypeReference
            {
                Name = varName,
                Parameters = parameters,
                FirstTokenIndex = firstToken,
                LastTokenIndex = currentToken - 1,
            };
            nextToken = currentToken;
            result = dataTypeReference;
            return true;
        }