當前位置: 首頁>>代碼示例>>C#>>正文


C# DbFunctionTools.GetString方法代碼示例

本文整理匯總了C#中RDBMS_DBCORE.DbFunctionTools.GetString方法的典型用法代碼示例。如果您正苦於以下問題:C# DbFunctionTools.GetString方法的具體用法?C# DbFunctionTools.GetString怎麽用?C# DbFunctionTools.GetString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在RDBMS_DBCORE.DbFunctionTools的用法示例。


在下文中一共展示了DbFunctionTools.GetString方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: INSTR

        public static DbValue INSTR(DbFunctionTools tools, DbFunctionArguments args)
        {
            string FunctionName = "INSTR";

            args.EnsureMinCount(FunctionName, 2);

            DbType arg0type;
            ByteSlice arg0 = args[0].Eval(out arg0type);
            if (Types.IsNullValue(arg0))
            {
                return tools.AllocNullValue(); // Give a null, take a null.
            }
            if (arg0type.ID != DbTypeID.CHARS)
            {
                args.Expected(FunctionName, 0, "input CHAR(n), got " + arg0type.Name.ToUpper());
            }

            DbType arg1type;
            ByteSlice arg1 = args[1].Eval(out arg1type);
            if (Types.IsNullValue(arg1))
            {
                return tools.AllocNullValue(); // Give a null, take a null.
            }
            if (arg1type.ID != DbTypeID.CHARS)
            {
                args.Expected(FunctionName, 0, "input CHAR(n), got " + arg1type.Name.ToUpper());
            }

            int startIndex = 0;
            if (args.Length > 2)
            {
                DbType arg2type;
                ByteSlice arg2 = args[2].Eval(out arg2type);
                if (arg2type.ID != DbTypeID.INT)
                {
                    args.Expected(FunctionName, 0, "input INT, got " + arg2type.Name.ToUpper());
                }
                if (!Types.IsNullValue(arg2))
                {
                    startIndex = tools.GetInt(arg2);
                }
            }
            
            mstring sentence = tools.GetString(arg0);
            mstring word = tools.GetString(arg1);
            int index = -1;
            if (startIndex < sentence.Length)
            {
                if (startIndex > 0)
                {
                    sentence = sentence.SubstringM(startIndex);
                }
                index = sentence.IndexOf(word);
                if (index > -1)
                {
                    index += startIndex;
                }
            }
            return tools.AllocValue(index);
        }
開發者ID:erisonliang,項目名稱:qizmt,代碼行數:60,代碼來源:DbFunctions_INSTR.cs

示例2: Conv_String

 ByteSlice Conv_String(ByteSlice value, int ResultSize, DbFunctionTools tools)
 {
     mstring x = tools.GetString(value);
     x = x.ToUpperM();
     DbValue v = tools.AllocValue(x, ResultSize);
     return v.Eval();
 }
開發者ID:erisonliang,項目名稱:qizmt,代碼行數:7,代碼來源:QaJoinOn.cs

示例3: DbFunctions_UPPER

        public static void DbFunctions_UPPER()
        {
            DbFunctionTools tools = new DbFunctionTools();

            //String,Int32.
            {
                Console.WriteLine("Testing DbFunctions.UPPER(String)...");

                List<DbValue> args = new List<DbValue>();
                args.Add(tools.AllocValue(mstring.Prepare("hello world")));
                DbFunctionArguments fargs = new DbFunctionArguments(args);

                DbValue valOutput = DbFunctions.UPPER(tools, fargs);
                ByteSlice bs = valOutput.Eval();
                mstring output = tools.GetString(bs);

                mstring expected = mstring.Prepare("HELLO WORLD");

                if (expected != output)
                {
                    throw new Exception("DbFunctions.UPPER(String) has failed.  Expected result: " + expected.ToString() + ", but received: " + output.ToString());
                }
                else
                {
                    Console.WriteLine("Expected results received.");
                }
            }

        }
開發者ID:erisonliang,項目名稱:qizmt,代碼行數:29,代碼來源:DbFunctions_UPPER.cs

示例4: DbFunctions_RIGHT

        public static void DbFunctions_RIGHT()
        {
            DbFunctionTools tools = new DbFunctionTools();

            //String,Int32.
            {
                Console.WriteLine("Testing DbFunctions.RIGHT(String,Int32)...");

                mstring input = Utils.GenString(100);
                List<DbValue> args = new List<DbValue>();
                args.Add(tools.AllocValue(input));
                args.Add(tools.AllocValue(5));
                DbFunctionArguments fargs = new DbFunctionArguments(args);

                DbValue valOutput = DbFunctions.RIGHT(tools, fargs);
                ByteSlice bs = valOutput.Eval();
                mstring output = tools.GetString(bs);

                string str = input.ToString();
                string expected = str.Substring(str.Length - 5, 5);

                if (expected != output.ToString())
                {
                    throw new Exception("DbFunctions.RIGHT(String,Int32) has failed.  Expected result: " + expected.ToString() + ", but received: " + output.ToString());
                }
                else
                {
                    Console.WriteLine("Expected results received.");
                }
            }

        }
開發者ID:erisonliang,項目名稱:qizmt,代碼行數:32,代碼來源:DbFunctions_RIGHT.cs

示例5: REVERSE

        public static DbValue REVERSE(DbFunctionTools tools, DbFunctionArguments args)
        {
            string FunctionName = "REVERSE";

            args.EnsureCount(FunctionName, 1);

            DbType arg0type;
            ByteSlice arg0 = args[0].Eval(out arg0type);
            if (Types.IsNullValue(arg0))
            {
                return tools.AllocNullValue(); // Give a null, take a null.
            }
            if (arg0type.ID != DbTypeID.CHARS)
            {
                args.Expected(FunctionName, 0, "input CHAR(n), got " + arg0type.Name.ToUpper());
            }

            mstring x = tools.GetString(arg0);

            mstring r = mstring.Prepare();

            for (int i = x.Length-1; i >= 0; i--)
            {
                r = r.AppendM(x.SubstringM(i, 1));
            }

            return tools.AllocValue(r);
        }
開發者ID:erisonliang,項目名稱:qizmt,代碼行數:28,代碼來源:DbFunctions_REVERSE.cs

示例6: SUBSTRING

        public static DbValue SUBSTRING(DbFunctionTools tools, DbFunctionArguments args)
        {
            string FunctionName = "SUBSTRING";

            args.EnsureCount(FunctionName, 3);

            DbType arg0type;
            ByteSlice arg0 = args[0].Eval(out arg0type);
            if (Types.IsNullValue(arg0))
            {
                return tools.AllocNullValue(); // Give a null, take a null.
            }
            if (arg0type.ID != DbTypeID.CHARS)
            {
                args.Expected(FunctionName, 0, "input CHAR(n), got " + arg0type.Name.ToUpper());
                return null;
            }

            DbType arg1type;
            ByteSlice arg1 = args[1].Eval(out arg1type);
            if (arg1type.ID != DbTypeID.INT)
            {
                args.Expected(FunctionName, 1, "count INT, got " + arg1type.Name.ToUpper());
                return null;
            }

            DbType arg2type;
            ByteSlice arg2 = args[2].Eval(out arg2type);
            if (arg2type.ID != DbTypeID.INT)
            {
                args.Expected(FunctionName, 1, "count INT, got " + arg2type.Name.ToUpper());
                return null;
            }

            mstring x = tools.GetString(arg0);
            int startIndex = tools.GetInt(arg1);
            if (startIndex < 0)
            {
                startIndex = 0;
            }
            int len = tools.GetInt(arg2);
            if (len < 0)
            {
                throw new ArgumentException(FunctionName + " length cannot be negative");
            }

            if (startIndex + len > x.Length)
            {
                return tools.AllocValue(mstring.Prepare());
            }
            else
            {
                mstring sub = x.SubstringM(startIndex, len);
                return tools.AllocValue(sub);
            }
        }
開發者ID:erisonliang,項目名稱:qizmt,代碼行數:56,代碼來源:DbFunctions_SUBSTRING.cs

示例7: REPLACE

        public static DbValue REPLACE(DbFunctionTools tools, DbFunctionArguments args)
        {
            string FunctionName = "REPLACE";

            args.EnsureCount(FunctionName, 3);

            DbType arg0type;
            ByteSlice arg0 = args[0].Eval(out arg0type);
            if (Types.IsNullValue(arg0))
            {
                return tools.AllocNullValue(); // Give a null, take a null.
            }
            if (arg0type.ID != DbTypeID.CHARS)
            {
                args.Expected(FunctionName, 0, "input CHAR(n), got " + arg0type.Name.ToUpper());
            }
            DbType arg1type;
            ByteSlice arg1 = args[1].Eval(out arg1type);
            if (Types.IsNullValue(arg1))
            {
                return tools.AllocNullValue(); // Give a null, take a null.
            }
            if (arg1type.ID != DbTypeID.CHARS)
            {
                args.Expected(FunctionName, 0, "input CHAR(n), got " + arg1type.Name.ToUpper());
            }
            DbType arg2type;
            ByteSlice arg2 = args[2].Eval(out arg2type);
            if (Types.IsNullValue(arg2))
            {
                return tools.AllocNullValue(); // Give a null, take a null.
            }
            if (arg2type.ID != DbTypeID.CHARS)
            {
                args.Expected(FunctionName, 0, "input CHAR(n), got " + arg2type.Name.ToUpper());
            }

            mstring sentence = tools.GetString(arg0);
            mstring word = tools.GetString(arg1);
            mstring replacement = tools.GetString(arg2);
            sentence = sentence.ReplaceM(ref word, ref replacement);
            return tools.AllocValue(sentence);
        }
開發者ID:erisonliang,項目名稱:qizmt,代碼行數:43,代碼來源:DbFunctions_REPLACE.cs

示例8: ISLIKE

        public static DbValue ISLIKE(DbFunctionTools tools, DbFunctionArguments args)
        {
            string FunctionName = "ISLIKE";

            args.EnsureCount(FunctionName, 2);

            int ismatch = 0;
            DbType arg0type;
            ByteSlice arg0 = args[0].Eval(out arg0type);
            if (Types.IsNullValue(arg0))
            {
                return tools.AllocValue(ismatch);
            }
            if (arg0type.ID != DbTypeID.CHARS)
            {
                args.Expected(FunctionName, 0, "input CHAR(n), got " + arg0type.Name.ToUpper());
            }

            DbType arg1type;
            ByteSlice arg1 = args[1].Eval(out arg1type);
            if (arg1type.ID != DbTypeID.CHARS)
            {
                args.Expected(FunctionName, 1, "pattern CHAR(n), got " + arg1type.Name.ToUpper());
            }

            string x = tools.GetString(arg0).ToString();
            string y = tools.GetString(arg1).ToString();
            string pattern = GetRegexString(y);            

            if (pattern != null)
            {
                System.Text.RegularExpressions.Regex regx = new System.Text.RegularExpressions.Regex(pattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase);                
                if(regx.IsMatch(x))
                {
                    ismatch = 1;
                }
            }

            return tools.AllocValue(ismatch);
        }
開發者ID:erisonliang,項目名稱:qizmt,代碼行數:40,代碼來源:DbFunctions_ISLIKE.cs

示例9: PATINDEX

        public static DbValue PATINDEX(DbFunctionTools tools, DbFunctionArguments args)
        {
            string FunctionName = "PATINDEX";

            args.EnsureCount(FunctionName, 2);

            DbType arg0type;
            ByteSlice arg0 = args[0].Eval(out arg0type);
            DbType arg1type;
            ByteSlice arg1 = args[1].Eval(out arg1type);
            if (Types.IsNullValue(arg0))
            {
                return tools.AllocNullValue(); // Give a null, take a null.
            }
            if (arg0type.ID != DbTypeID.CHARS)
            {
                args.Expected(FunctionName, 0, "input CHAR(n), got " + arg0type.Name.ToUpper());
            }
            if (arg1type.ID != DbTypeID.CHARS)
            {
                args.Expected(FunctionName, 0, "input CHAR(n), got " + arg1type.Name.ToUpper());
            }

            string pat = tools.GetString(arg0).ToString();
            string str = tools.GetString(arg1).ToString();
            pat = pat.Trim('%');

            string rpat = GetRegexString(pat);

            System.Text.RegularExpressions.Regex regx = new System.Text.RegularExpressions.Regex(rpat);
            System.Text.RegularExpressions.Match match = regx.Match(str);
            int indx = -1;
            if (match != null)
            {
                indx = match.Index;
            }

            return tools.AllocValue(indx);
        }
開發者ID:erisonliang,項目名稱:qizmt,代碼行數:39,代碼來源:DbFunctions_PATINDEX.cs

示例10: LEFT

        public static DbValue LEFT(DbFunctionTools tools, DbFunctionArguments args)
        {
            string FunctionName = "LEFT";

            args.EnsureCount(FunctionName, 2);

            DbType arg0type;
            ByteSlice arg0 = args[0].Eval(out arg0type);
            if (Types.IsNullValue(arg0))
            {
                return tools.AllocNullValue(); // Give a null, take a null.
            }
            if (arg0type.ID != DbTypeID.CHARS)
            {
                args.Expected(FunctionName, 0, "input CHAR(n), got " + arg0type.Name.ToUpper());
            }
            
            DbType arg1type;
            ByteSlice arg1 = args[1].Eval(out arg1type);
            if (arg1type.ID != DbTypeID.INT)
            {
                args.Expected(FunctionName, 1, "count INT, got " + arg1type.Name.ToUpper());
            }

            mstring x = tools.GetString(arg0);
            int LeftCount = tools.GetInt(arg1);
            if (LeftCount >= x.Length)
            {
                // User requested the whole string.
                return tools.AllocValue(arg0, arg0type);
            }
            else if (LeftCount < 0)
            {
                throw new ArgumentException(FunctionName + " count cannot be negative");
            }
            else
            {
                x = x.SubstringM(0, LeftCount);
                return tools.AllocValue(x);
            }

        }
開發者ID:erisonliang,項目名稱:qizmt,代碼行數:42,代碼來源:DbFunctions_LEFT.cs

示例11: LTRIM

        public static DbValue LTRIM(DbFunctionTools tools, DbFunctionArguments args)
        {
            string FunctionName = "LTRIM";

            args.EnsureCount(FunctionName, 1);

            DbType arg0type;
            ByteSlice arg0 = args[0].Eval(out arg0type);
            if (Types.IsNullValue(arg0))
            {
                return tools.AllocNullValue(); // Give a null, take a null.
            }
            if (arg0type.ID != DbTypeID.CHARS)
            {
                args.Expected(FunctionName, 0, "input CHAR(n), got " + arg0type.Name.ToUpper());
            }

            string x = tools.GetString(arg0).ToString();
            string y = x.TrimStart();
            return tools.AllocValue(mstring.Prepare(y));
        }
開發者ID:erisonliang,項目名稱:qizmt,代碼行數:21,代碼來源:DbFunctions_LTRIM.cs

示例12: LOWER

        public static DbValue LOWER(DbFunctionTools tools, DbFunctionArguments args)
        {
            string FunctionName = "LOWER";

            args.EnsureCount(FunctionName, 1);

            DbType arg0type;
            ByteSlice arg0 = args[0].Eval(out arg0type);
            if (Types.IsNullValue(arg0))
            {
                return tools.AllocNullValue(); // Give a null, take a null.
            }
            if (arg0type.ID != DbTypeID.CHARS)
            {
                args.Expected(FunctionName, 0, "input CHAR(n), got " + arg0type.Name.ToUpper());
            }

            mstring x = tools.GetString(arg0);
            mstring lower = x.ToLowerM();
            return tools.AllocValue(lower);
        }
開發者ID:erisonliang,項目名稱:qizmt,代碼行數:21,代碼來源:DbFunctions_LOWER.cs

示例13: FORMAT

        public static DbValue FORMAT(DbFunctionTools tools, DbFunctionArguments args)
        {
            string FunctionName = "FORMAT";

            args.EnsureCount(FunctionName, 2);

            DbType arg0type;
            ByteSlice arg0 = args[0].Eval(out arg0type);
            DbType arg1type;
            ByteSlice arg1 = args[1].Eval(out arg1type);
            if (Types.IsNullValue(arg0))
            {
                return tools.AllocNullValue(); // Give a null, take a null.
            }
            if (arg0type.ID != DbTypeID.CHARS)
            {
                args.Expected(FunctionName, 0, "input CHAR(n), got " + arg0type.Name.ToUpper());
            }
            if (Types.IsNullValue(arg1))
            {
                return tools.AllocNullValue(); // Give a null, take a null.
            }
            if (arg1type.ID != DbTypeID.DATETIME)
            {
                args.Expected(FunctionName, 0, "input DATETIME, got " + arg1type.Name.ToUpper());
            }

            string formatstr = tools.GetString(arg0).ToString();            
            DateTime dt = tools.GetDateTime(arg1);

            mstring result = mstring.Prepare(dt.ToString(formatstr));
            while (result.Length < 80)
            {
                result.MAppend('\0');
            }
            return tools.AllocValue(result);
        }
開發者ID:erisonliang,項目名稱:qizmt,代碼行數:37,代碼來源:DbFunctions_FORMAT.cs

示例14: DbAggregators_MIN


//.........這裏部分代碼省略.........
            }

            {
                Console.WriteLine("Testing DbAggregators_MIN(Int32)...");

                DbFunctionArguments[] fargs = new DbFunctionArguments[rowcount];
                int expected = Int32.MaxValue;

                for (int i = 0; i < fargs.Length; i++)
                {
                    int input = rnd.Next(Int32.MinValue, Int32.MaxValue);
                    if (input < expected)
                    {
                        expected = input;
                    }
                    List<DbValue> args = new List<DbValue>();
                    args.Add(tools.AllocValue(input));
                    fargs[i] = new DbFunctionArguments(args);
                }
                DbValue valOutput = DbAggregators.MIN(tools, new DbAggregatorArguments(fargs));
                ByteSlice bs = valOutput.Eval();
                int output = tools.GetInt(bs);

                if (expected != output)
                {
                    throw new Exception("DbAggregators_MIN(Int32) has failed.  Expected result: " + expected.ToString() + ", but received: " + output.ToString());
                }
                else
                {
                    Console.WriteLine("Expected results received.");
                }
            }

            {
                Console.WriteLine("Testing DbAggregators_MIN(Int64)...");

                DbFunctionArguments[] fargs = new DbFunctionArguments[rowcount];
                long expected = Int64.MaxValue;

                for (int i = 0; i < fargs.Length; i++)
                {
                    long input = DateTime.Now.Ticks;
                    if (input % 2 == 0)
                    {
                        input = input * -1;
                    }
                    if (input < expected)
                    {
                        expected = input;
                    }
                    List<DbValue> args = new List<DbValue>();
                    args.Add(tools.AllocValue(input));
                    fargs[i] = new DbFunctionArguments(args);
                }
                DbValue valOutput = DbAggregators.MIN(tools, new DbAggregatorArguments(fargs));
                ByteSlice bs = valOutput.Eval();
                long output = tools.GetLong(bs);

                if (expected != output)
                {
                    throw new Exception("DbAggregators_MIN(Int64) has failed.  Expected result: " + expected.ToString() + ", but received: " + output.ToString());
                }
                else
                {
                    Console.WriteLine("Expected results received.");
                }
            }

            {
                Console.WriteLine("Testing DbAggregators_MIN(char(n))...");

                DbFunctionArguments[] fargs = new DbFunctionArguments[rowcount];
                string expected = null;

                for (int i = 0; i < fargs.Length; i++)
                {
                    int strlen = rnd.Next(1, 100);
                    mstring input = Utils.GenString(strlen);
                    if (expected == null || input.ToString().CompareTo(expected) < 0)
                    {
                        expected = input.ToString();
                    }
                    List<DbValue> args = new List<DbValue>();
                    args.Add(tools.AllocValue(input));
                    fargs[i] = new DbFunctionArguments(args);
                }
                DbValue valOutput = DbAggregators.MIN(tools, new DbAggregatorArguments(fargs));
                ByteSlice bs = valOutput.Eval();
                mstring output = tools.GetString(bs);

                if (expected != output.ToString())
                {
                    throw new Exception("DbAggregators_MIN(char(n)) has failed.  Expected result: " + expected.ToString() + ", but received: " + output.ToString());
                }
                else
                {
                    Console.WriteLine("Expected results received.");
                }
            }
        }
開發者ID:erisonliang,項目名稱:qizmt,代碼行數:101,代碼來源:DbAggregators_MIN.cs

示例15: CHARINDEX

        public static DbValue CHARINDEX(DbFunctionTools tools, DbFunctionArguments args)
        {
            string FunctionName = "CHARINDEX";

            args.EnsureMinCount(FunctionName, 2);

            int index = -1;
            DbType arg0type;
            ByteSlice arg0 = args[0].Eval(out arg0type);
            DbType arg1type;
            ByteSlice arg1 = args[1].Eval(out arg1type);
            if (Types.IsNullValue(arg0) || Types.IsNullValue(arg1))
            {
                return tools.AllocValue(index);
            }

            if (arg0type.ID != DbTypeID.CHARS)
            {
                args.Expected(FunctionName, 0, "input CHAR(n), got " + arg0type.Name.ToUpper());
                return null;
            }
            if (arg1type.ID != DbTypeID.CHARS)
            {
                args.Expected(FunctionName, 0, "input CHAR(n), got " + arg1type.Name.ToUpper());
                return null;
            }

            int startIndex = 0;
            if (args.Length > 2)
            {
                DbType arg2type;
                ByteSlice arg2 = args[2].Eval(out arg2type);
                if (arg2type.ID != DbTypeID.INT)
                {
                    args.Expected(FunctionName, 0, "input INT, got " + arg2type.Name.ToUpper());
                    return null;
                }
                startIndex = tools.GetInt(arg2);
                if (startIndex < 0)
                {
                    startIndex = 0;
                }
            }
            
            mstring word = tools.GetString(arg0);
            mstring sentence = tools.GetString(arg1);

            if (startIndex > sentence.Length - 1)
            {
                index = -1;
            }
            else if (startIndex == 0)
            {
                index = sentence.IndexOf(word);
            }
            else
            {
                mstring partsentence = sentence.SubstringM(startIndex);
                int ix = partsentence.IndexOf(word);
                if (ix == -1)
                {
                    index = -1;
                }
                else
                {
                    index = startIndex + ix;
                }
            }
            return tools.AllocValue(index);
        }
開發者ID:erisonliang,項目名稱:qizmt,代碼行數:70,代碼來源:DbFunctions_CHARINDEX.cs


注:本文中的RDBMS_DBCORE.DbFunctionTools.GetString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。