Beispiel #1
0
        static void Main(string[] args)
        {
            _String str = new _String(new char[] { 'c', 'a', 't' });

            Console.WriteLine("Create string:");
            printStr(str.Chars);
            Console.WriteLine("\nUsing text");
            _String s    = new _String(new char[] { 'd', 'o', 'g' });
            _String s2   = new _String(new char[] { 'c', 'o', 'w' });
            Text    text = new Text(s.Chars);

            text.Add(str);
            text.Add(s);
            text.Add(s2);
            //Console.WriteLine("Before:"+str.Chars.Length);
            // text.DeleteFirstAndLastSpace(str);
            //Console.WriteLine("After:"+str.Chars.Length);
            //text.DeleteByIndex(2,false);
            Console.WriteLine(text.ToString());
            //str.CalcConsonants(new char[] { 'h', 'e', 'l', 'l', 'o' });
            // Console.WriteLine(text.ToString());
            // text.FindMinLenOfStr();
            // text.DeleteFirstAndLastSpace(str);
            // printStr(str.Chars);
            Console.WriteLine("\nPercentage of consonants:" + text.FindPercentageOfConsonants() + "%");
            //text.deleteExtraSpaces(str);
            // printStr(str.Chars);
            Console.ReadKey();
        }
Beispiel #2
0
        private static async Task <string> ValidateBadNameAsync(_String nameColumn, DataRow dataRow)
        {
            await Task.Delay(200);

            var value = nameColumn[dataRow];

            return(value == BAD_NAME ? "Bad Name" : null);
        }
Beispiel #3
0
 private void TestCastToString(TimeSpan? x, String expectedValue)
 {
     _TimeSpan column1 = x;
     _String expr = (_String)column1;
     var dbExpr = (DbCastExpression)expr.DbExpression;
     dbExpr.Verify(column1, typeof(TimeSpan?), typeof(String));
     expr.VerifyEval(expectedValue);
 }
Beispiel #4
0
 private void TestFromString(String x, TimeSpan? expectedValue)
 {
     _String column1 = x;
     _TimeSpan expr = (_TimeSpan)column1;
     var dbExpr = (DbCastExpression)expr.DbExpression;
     dbExpr.Verify(column1, typeof(String), typeof(TimeSpan?));
     expr.VerifyEval(expectedValue);
 }
Beispiel #5
0
        private void TestCastToString(SqlXml x, string expectedValue)
        {
            _SqlXml column1 = x;
            _String expr    = (_String)column1;
            var     dbExpr  = (DbCastExpression)expr.DbExpression;

            dbExpr.Verify(column1, typeof(SqlXml), typeof(string));
            expr.VerifyEval(expectedValue);
        }
Beispiel #6
0
        private void TestFromString(String x, DateTimeOffset?expectedValue)
        {
            _String         column1 = x;
            _DateTimeOffset expr    = (_DateTimeOffset)column1;
            var             dbExpr  = (DbCastExpression)expr.DbExpression;

            dbExpr.Verify(column1, typeof(String), typeof(DateTimeOffset?));
            expr.VerifyEval(expectedValue);
        }
Beispiel #7
0
 /// <summary>
 /// Specifies SQL Server CHAR(n) data type for column.
 /// </summary>
 /// <param name="column">The column.</param>
 /// <param name="size">The size of the data type.</param>
 /// <returns>This column for fluent coding.</returns>
 public static _String AsSqlChar(this _String column, int size)
 {
     column.VerifyNotNull(nameof(column));
     if (size < MIN_CHAR_SIZE || size > MAX_CHAR_SIZE)
     {
         throw new ArgumentOutOfRangeException(nameof(size));
     }
     column.SetSqlType(SqlType.Char(column, size));
     return(column);
 }
Beispiel #8
0
        private void TestFromString(string x, SqlXml expectedValue)
        {
            _String column1 = x;
            _SqlXml expr    = (_SqlXml)column1;
            var     dbExpr  = (DbCastExpression)expr.DbExpression;

            dbExpr.Verify(column1, typeof(string), typeof(SqlXml));
            var result = expr.Eval();

            Assert.AreEqual(expectedValue == null ? null : expectedValue.Value, result == null ? null : result.Value);
        }
            internal List <string> GetStringList()
            {
                List <string> list = new List <String>();

                if (context == ItemType.VALUE_LIST)
                {
                    _ValueList SettingList = (_ValueList)value;
                    foreach (_Value v in SettingList.Value)
                    {
                        _ScalarValue s   = (_ScalarValue)v.Value;
                        _String      str = (_String)s.Value;
                        list.Add(str.Value);
                    }
                }
                else
                {
                    throw new NotImplementedException();
                }
                return(list);
            }
Beispiel #10
0
        //Return the corresponding fret to play the given pitch on the given string.
        static int FindFret(_String s, int pitch)
        {
            int fret = -1;

            switch (s)
            {
            case _String.E:
                fret = pitch - 40;
                break;

            case _String.A:
                fret = pitch - 45;
                break;

            case _String.D:
                fret = pitch - 50;
                break;

            case _String.G:
                fret = pitch - 55;
                break;
            }
            return(fret);
        }
 /// <summary>
 /// Determines whether a specific character string does not match a specified pattern.
 /// </summary>
 /// <param name="source">The source string column.</param>
 /// <param name="pattern">The pattern.</param>
 /// <returns><see cref="_Boolean"/> column that contains the result.</returns>
 public static _Boolean NotLike(this _String source, _String pattern)
 {
     source.VerifyNotNull(nameof(source));
     pattern.VerifyNotNull(nameof(pattern));
     return(new NotLikeFunction(source, pattern).MakeColumn <_Boolean>());
 }
Beispiel #12
0
 private static DbSet <Movie> Filter(DbSet <Movie> movies, _String text)
 {
     return(movies.Where(_ => _.Title.Contains(text) | _.Genre.Contains(text)));
 }
Beispiel #13
0
        public void Column_intercepted_MySqlType()
        {
            {
                var binary = new _Binary().AsMySqlBinary(255);
                VerifyMySqlType(MySqlVersion.LowestSupported, binary, MySqlDbType.Binary, 255, "BINARY(255)");
            }

            {
                var varBinary = new _Binary().AsMySqlVarBinary(4000);
                VerifyMySqlType(MySqlVersion.LowestSupported, varBinary, MySqlDbType.VarBinary, 4000, "VARBINARY(4000)");
            }

            {
                var binary = new _Binary().AsMySqlTinyBlob();
                VerifyMySqlType(MySqlVersion.LowestSupported, binary, MySqlDbType.TinyBlob, "TINYBLOB");
            }

            {
                var binary = new _Binary().AsMySqlBlob();
                VerifyMySqlType(MySqlVersion.LowestSupported, binary, MySqlDbType.Blob, "BLOB");
            }

            {
                var binary = new _Binary().AsMySqlMediumBlob();
                VerifyMySqlType(MySqlVersion.LowestSupported, binary, MySqlDbType.MediumBlob, "MEDIUMBLOB");
            }

            {
                var binary = new _Binary().AsMySqlLongBlob();
                VerifyMySqlType(MySqlVersion.LowestSupported, binary, MySqlDbType.LongBlob, "LONGBLOB");
            }

            {
                var timestamp = new _DateTime().AsMySqlTimestamp();
                VerifyMySqlType(MySqlVersion.LowestSupported, timestamp, MySqlDbType.Timestamp, "TIMESTAMP");
            }

            {
                var decimalColumn = new _Decimal().AsMySqlDecimal(28, 8);
                VerifyMySqlType(MySqlVersion.LowestSupported, decimalColumn, MySqlDbType.Decimal, "DECIMAL(28, 8)", 28, 8);
            }

            {
                var money = new _Decimal().AsMySqlMoney();
                VerifyMySqlType(MySqlVersion.LowestSupported, money, MySqlDbType.Decimal, "DECIMAL(19, 4)", 19, 4);
            }

            {
                var date = new _DateTime().AsMySqlDate();
                VerifyMySqlType(MySqlVersion.LowestSupported, date, MySqlDbType.Date, "DATE");
            }

            {
                var time = new _DateTime().AsMySqlTime();
                VerifyMySqlType(MySqlVersion.LowestSupported, time, MySqlDbType.Time, "TIME");
            }

            {
                var dateTime = new _DateTime().AsMySqlDateTime();
                VerifyMySqlType(MySqlVersion.LowestSupported, dateTime, MySqlDbType.DateTime, "DATETIME");
            }

            {
                var charColumn = new _String().AsMySqlChar(255, "utf8mb4");
                VerifyMySqlType(MySqlVersion.LowestSupported, charColumn, MySqlDbType.String, 255, "CHAR(255) CHARACTER SET utf8mb4");
            }

            {
                var varchar = new _String().AsMySqlVarChar(512, "utf8mb4");
                VerifyMySqlType(MySqlVersion.LowestSupported, varchar, MySqlDbType.VarString, 512, "VARCHAR(512) CHARACTER SET utf8mb4");
            }

            {
                var singleChar = new _Char().AsMySqlChar();
                VerifyMySqlType(MySqlVersion.LowestSupported, singleChar, MySqlDbType.String, 1, "CHAR(1)");
                singleChar = new _Char().AsMySqlChar("utf8mb4");
                VerifyMySqlType(MySqlVersion.LowestSupported, singleChar, MySqlDbType.String, 1, "CHAR(1) CHARACTER SET utf8mb4");
            }

            {
                var text = new _String().AsMySqlTinyText("utf8mb4");
                VerifyMySqlType(MySqlVersion.LowestSupported, text, MySqlDbType.TinyText, "TINYTEXT CHARACTER SET utf8mb4");
            }

            {
                var text = new _String().AsMySqlText("utf8mb4");
                VerifyMySqlType(MySqlVersion.LowestSupported, text, MySqlDbType.Text, "TEXT CHARACTER SET utf8mb4");
            }

            {
                var text = new _String().AsMySqlMediumText("utf8mb4");
                VerifyMySqlType(MySqlVersion.LowestSupported, text, MySqlDbType.MediumText, "MEDIUMTEXT CHARACTER SET utf8mb4");
            }

            {
                var text = new _String().AsMySqlLongText("utf8mb4");
                VerifyMySqlType(MySqlVersion.LowestSupported, text, MySqlDbType.LongText, "LONGTEXT CHARACTER SET utf8mb4");
            }
        }
Beispiel #14
0
 /// <summary>
 /// Specifies SQL Server VARCHAR(MAX) data type for column.
 /// </summary>
 /// <param name="column">The column.</param>
 /// <returns>This column for fluent coding.</returns>
 public static _String AsSqlVarCharMax(this _String column)
 {
     column.VerifyNotNull(nameof(column));
     column.SetSqlType(SqlType.VarChar(column, -1));
     return(column);
 }
        public void Column_intercepted_SqlType()
        {
            {
                var binary = new _Binary().AsSqlBinary(500);
                VerifySqlType(SqlVersion.Sql13, binary, SqlDbType.Binary, 500, "BINARY(500)");
            }

            {
                var binaryMax = new _Binary().AsSqlBinaryMax();
                VerifySqlType(SqlVersion.Sql13, binaryMax, SqlDbType.Binary, -1, "BINARY(MAX)");
            }

            {
                var varBinary = new _Binary().AsSqlVarBinary(225);
                VerifySqlType(SqlVersion.Sql13, varBinary, SqlDbType.VarBinary, 225, "VARBINARY(225)");
            }

            {
                var varBinaryMax = new _Binary().AsSqlVarBinaryMax();
                VerifySqlType(SqlVersion.Sql13, varBinaryMax, SqlDbType.VarBinary, -1, "VARBINARY(MAX)");
            }

            {
                var timestamp = new _Binary().AsSqlTimestamp();
                VerifySqlType(SqlVersion.Sql13, timestamp, SqlDbType.Timestamp, "TIMESTAMP");
            }

            {
                var decimalColumn = new _Decimal().AsSqlDecimal(28, 8);
                VerifySqlType(SqlVersion.Sql13, decimalColumn, SqlDbType.Decimal, "DECIMAL(28, 8)", 28, 8);
            }

            {
                var smallMoney = new _Decimal().AsSqlSmallMoney();
                VerifySqlType(SqlVersion.Sql13, smallMoney, SqlDbType.SmallMoney, "SMALLMONEY");
            }

            {
                var money = new _Decimal().AsSqlMoney();
                VerifySqlType(SqlVersion.Sql13, money, SqlDbType.Money, "MONEY");
            }

            {
                var date = new _DateTime().AsSqlDate();
                VerifySqlType(SqlVersion.Sql13, date, SqlDbType.Date, "DATE");
            }

            {
                var time = new _DateTime().AsSqlTime();
                VerifySqlType(SqlVersion.Sql13, time, SqlDbType.Time, "TIME");
            }

            {
                var dateTime = new _DateTime().AsSqlDateTime();
                VerifySqlType(SqlVersion.Sql13, dateTime, SqlDbType.DateTime, "DATETIME");
            }

            {
                var smallDateTime = new _DateTime().AsSqlSmallDateTime();
                VerifySqlType(SqlVersion.Sql13, smallDateTime, SqlDbType.SmallDateTime, "SMALLDATETIME");
            }

            {
                var dateTime2 = new _DateTime().AsSqlDateTime2(5);
                VerifySqlType(SqlVersion.Sql13, dateTime2, SqlDbType.DateTime2, "DATETIME2(5)", 5);
            }

            {
                var charColumn = new _String().AsSqlChar(478);
                VerifySqlType(SqlVersion.Sql13, charColumn, SqlDbType.Char, 478, "CHAR(478)");
            }

            {
                var charMax = new _String().AsSqlCharMax();
                VerifySqlType(SqlVersion.Sql13, charMax, SqlDbType.Char, -1, "CHAR(MAX)");
            }

            {
                var nchar = new _String().AsSqlNChar(333);
                VerifySqlType(SqlVersion.Sql13, nchar, SqlDbType.NChar, 333, "NCHAR(333)");
            }

            {
                var ncharMax = new _String().AsSqlNCharMax();
                VerifySqlType(SqlVersion.Sql13, ncharMax, SqlDbType.NChar, -1, "NCHAR(MAX)");
            }

            {
                var varchar = new _String().AsSqlVarChar(512);
                VerifySqlType(SqlVersion.Sql13, varchar, SqlDbType.VarChar, 512, "VARCHAR(512)");
            }

            {
                var varcharMax = new _String().AsSqlVarCharMax();
                VerifySqlType(SqlVersion.Sql13, varcharMax, SqlDbType.VarChar, -1, "VARCHAR(MAX)");
            }

            {
                var nvarchar = new _String().AsSqlNVarChar(1024);
                VerifySqlType(SqlVersion.Sql13, nvarchar, SqlDbType.NVarChar, 1024, "NVARCHAR(1024)");
            }

            {
                var nvarcharMax = new _String().AsSqlNVarCharMax();
                VerifySqlType(SqlVersion.Sql13, nvarcharMax, SqlDbType.NVarChar, -1, "NVARCHAR(MAX)");
            }

            {
                var singleChar = new _Char().AsSqlChar(true);
                VerifySqlType(SqlVersion.Sql13, singleChar, SqlDbType.NChar, 1, "NCHAR(1)");
                singleChar = new _Char().AsSqlChar(false);
                VerifySqlType(SqlVersion.Sql13, singleChar, SqlDbType.Char, 1, "CHAR(1)");
            }
        }
 public NotLikeFunction(_String source, _String pattern)
     : base(source, pattern)
 {
 }
Beispiel #17
0
 private static string GetContactPerson(DataRow dataRow, _String lastName, _String firstName, _String title)
 {
     return(GetContactPerson(lastName[dataRow], firstName[dataRow], title[dataRow]));
 }
Beispiel #18
0
 private DbSet <SalesOrderHeader> GetSalesOrderHeaders(_String filterText)
 {
     return(SalesOrderHeader.Where(_ => _.SalesOrderNumber.Contains(filterText) | _.PurchaseOrderNumber.Contains(filterText)));
 }
Beispiel #19
0
 public PK(_Int32 productModelID, _Int32 productDescriptionID, _String culture)
     : base(productModelID, productDescriptionID, culture)
 {
 }
Beispiel #20
0
 /// <summary>
 /// Specifies MySQL LONGTEXT data type for column.
 /// </summary>
 /// <param name="column">The column.</param>
 /// <param name="charSetName">The char set name of the data type.</param>
 /// <param name="collationName">The collation name of the data type.</param>
 /// <returns>This column for fluent coding.</returns>
 public static _String AsMySqlLongText(this _String column, string charSetName = null, string collationName = null)
 {
     column.VerifyNotNull(nameof(column));
     column.SetMySqlType(MySqlType.LongText(column, charSetName, collationName));
     return(column);
 }