Пример #1
0
 private string ToGerman(FormattableString src)
 {
     return string.Format(
         CultureInfo.CreateSpecificCulture("de-de"),
         src.Format,
         src.GetArguments());
 }
        protected override string ConstructFullSelectStatementInternal(
            string selectClause,
            string fromClause,
            FormattableString whereClause = null,
            FormattableString orderClause = null,
            long? skipRowsCount = null,
            long? limitRowsCount = null,
            bool forceTableColumnResolution = false)
        {
            var sql = this.ResolveWithCultureInvariantFormatter($"SELECT {selectClause} FROM {fromClause}");

            if (whereClause != null)
            {
                sql += " WHERE " + this.ResolveWithSqlFormatter(whereClause, forceTableColumnResolution);
            }
            if (orderClause != null)
            {
                sql += " ORDER BY " + this.ResolveWithSqlFormatter(orderClause, forceTableColumnResolution);
            }

            if (limitRowsCount.HasValue || skipRowsCount.HasValue)
            {
                sql += this.ResolveWithCultureInvariantFormatter($" LIMIT {limitRowsCount ?? -1}");
            }
            if (skipRowsCount.HasValue)
            {
                sql += this.ResolveWithCultureInvariantFormatter($" OFFSET {skipRowsCount}");
            }

            return sql;
        }
Пример #3
0
        public async Task <IActionResult> OnPostVerifyAsync()
        {
            System.FormattableString query = $"EXECUTE [dbo].[VerifyLedger]";
            await _context.Database.ExecuteSqlInterpolatedAsync(query);

            return(RedirectToPage("/LedgerVerifications/Index"));
        }
        /// <summary>
        /// Constructs a full batch select statement
        /// </summary>
        protected override string ConstructFullBatchSelectStatementInternal(
            FormattableString whereClause = null,
            FormattableString orderClause = null,
            long? skipRowsCount = null,
            long? limitRowsCount = null,
            object queryParameters = null)
        {
            var sql = this.ResolveWithCultureInvariantFormatter($"SELECT {this.ConstructColumnEnumerationForSelect()} FROM {this.GetTableName()}");

            if (whereClause != null)
            {
                sql += string.Format(this.StatementFormatter, " WHERE {0}", whereClause);
            }
            if (orderClause != null)
            {
                sql += string.Format(this.StatementFormatter, " ORDER BY {0}", orderClause);
            }
            if (limitRowsCount.HasValue)
            {
                sql += string.Format(CultureInfo.InvariantCulture, " LIMIT {0}", limitRowsCount);
            }
            if (skipRowsCount.HasValue)
            {
                sql += string.Format(CultureInfo.InvariantCulture, " OFFSET {0}", skipRowsCount);
            }

            return sql;
        }
        public override string ConstructFullBatchSelectStatement(
            FormattableString whereClause = null,
            FormattableString orderClause = null,
            int? skipRowsCount = null,
            int? limitRowsCount = null,
            object queryParameters = null)
        {
            var sql = $"SELECT {this.ConstructColumnEnumerationForSelect()} FROM {this.GetTableName()}";
            if (whereClause != null)
            {
                sql += string.Format(CultureInfo.InvariantCulture, " WHERE {0}", whereClause);
            }
            if (orderClause != null)
            {
                sql += string.Format(CultureInfo.InvariantCulture, " ORDER BY {0}", orderClause);
            }
            if (skipRowsCount.HasValue)
            {
                sql += string.Format(CultureInfo.InvariantCulture, " OFFSET {0} ROWS", skipRowsCount);
            }
            if (limitRowsCount.HasValue)
            {
                sql += string.Format(CultureInfo.InvariantCulture, " FETCH NEXT {0} ROWS ONLY", limitRowsCount);
            }

            return sql;
        }
Пример #6
0
 public void Log(LogSeverity severity, string source, FormattableString message, Exception exception = null)
 {
     if (severity <= Level)
     {
         try { Message(this, new LogMessageEventArgs(severity, source, message.ToString(), exception)); }
         catch { } //We dont want to log on log errors
     }
 }
Пример #7
0
 private static Exception ProtocolError(FormattableString fs, object message = null) {
     var s = Invariant(fs);
     if (message != null) {
         s += "\n\n" + message;
     }
     Trace.Fail(s);
     return new InvalidDataException(s);
 }
Пример #8
0
 public static string Invariant(FormattableString formattable)
 {
     if (formattable == null)
     {
         throw new ArgumentNullException(nameof(formattable));
     }
     return formattable.ToString(CultureInfo.InvariantCulture);
 }
        //public static string Invariant(FormattableString s) =>
        //    s.ToString(CultureInfo.InvariantCulture);
        


        public static void ShowDetails(FormattableString s)
        {
            WriteLine($"argument count: {s.ArgumentCount}");
            WriteLine($"format: {s.Format}");
            for (int i = 0; i < s.ArgumentCount; i++)
            {
                WriteLine($"Argument {i}: {s.GetArgument(i)}");
            }

        }
 /// <summary>
 /// Default constructor.
 /// </summary>
 public StatementSqlBuilderJoinInstruction(
     GenericStatementSqlBuilder sqlBuilder, 
     SqlJoinType joinType,
     FormattableString whereClause, 
     FormattableString orderClause)
 {
     this.SqlBuilder = sqlBuilder;
     this.JoinType = joinType;
     this.WhereClause = whereClause;
     this.OrderClause = orderClause;
 }
Пример #11
0
 internal static SqlCommand ToSqlCommand(SqlConnection conn, FormattableString formattableString)
 {
     object[] args = formattableString.GetArguments();
     var parameters = args.Select((value, position) => new InterpolatedSqlParameter(value, position)).ToArray();
     string sql = string.Format(formattableString.Format, parameters);
     var command = new SqlCommand(sql, conn);
     foreach (var p in parameters)
     {
         command.Parameters.Add(p.ToSqlParameter());
     }
     return command;
 }
Пример #12
0
 public static SqlCommand NewSqlCommand(
     this SqlConnection conn, FormattableString formattableString)
 {
     SqlParameter[] sqlParameters = formattableString.GetArguments()
         .Select((value, position) =>
             new SqlParameter(Invariant($"@p{position}"), value))
         .ToArray();
     object[] formatArguments = sqlParameters
         .Select(p => new FormatCapturingParameter(p))
         .ToArray();
     string sql = string.Format(formattableString.Format, formatArguments);
     var command = new SqlCommand(sql, conn);
     command.Parameters.AddRange(sqlParameters);
     return command;
 }
Пример #13
0
        // To protect from overposting attacks, enable the specific properties you want to bind to.
        // For more details, see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Attach(Employee).State = EntityState.Modified;

            try
            {
                string userName = HttpContext.User.Identity.Name;
                var    ssn      = new SqlParameter();
                ssn.ParameterName = @"@SSN";
                ssn.DbType        = DbType.AnsiStringFixedLength;
                ssn.Direction     = ParameterDirection.Input;
                ssn.Value         = Employee.Ssn;
                ssn.Size          = ssn.Value.ToString().Length;

                var salary = new SqlParameter();
                salary.ParameterName = @"@Salary";
                salary.DbType        = DbType.Currency;
                salary.Direction     = ParameterDirection.Input;
                salary.Value         = Employee.Salary;

                System.FormattableString query = $"UPDATE [dbo].[Employees] SET [SSN] = {ssn}, [FirstName] = {Employee.FirstName}, [LastName] = {Employee.LastName}, [Salary] = {salary} WHERE [EmployeeID] = {Employee.EmployeeId}";
                string queryString             = $"UPDATE [dbo].[Employees] SET [SSN] = '{Employee.Ssn}', [FirstName] = '{Employee.FirstName}', [LastName] = '{Employee.LastName}', [Salary] = '{Employee.Salary}' WHERE [EmployeeID] = '{Employee.EmployeeId}'";
                await _context.Database.ExecuteSqlInterpolatedAsync(query);

                await _context.Database.ExecuteSqlInterpolatedAsync($"INSERT INTO [dbo].[AuditEvents] ([UserName], [Query]) VALUES ({userName}, {queryString})");
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!EmployeeExists(Employee.EmployeeId))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
Пример #14
0
 public void Verbose(string source, FormattableString message, Exception ex = null)
     => Log(LogSeverity.Verbose, source, message, ex);
 private static Task<REvaluationResult> EvaluateNonReentrantAsync(this IRSessionEvaluation evaluation, FormattableString commandText) {
     return evaluation.EvaluateAsync(FormattableString.Invariant(commandText));
 }
Пример #16
0
 /// <summary>
 /// Format the given object in the current culture. This static method may be
 /// imported in C# by
 /// <code>
 /// using static System.FormattableString;
 /// </code>.
 /// Within the scope
 /// of that import directive an interpolated string may be formatted in the
 /// current culture by writing, for example,
 /// <code>
 /// CurrentCulture($"{{ lat = {latitude}; lon = {longitude} }}")
 /// </code>
 /// </summary>
 public static string CurrentCulture(FormattableString formattable)
 {
     ArgumentNullException.ThrowIfNull(formattable);
     return(formattable.ToString(Globalization.CultureInfo.CurrentCulture));
 }
Пример #17
0
 private string PointsInGerman(FormattableString invariantString) => Format(
         System.Globalization.CultureInfo.GetCultureInfo("de-de"),
         invariantString.Format,
         invariantString.GetArguments());
Пример #18
0
 public static void LogVerboseF(this ILogger logger, FormattableString message)
 {
     logger.LogVerbose(message.Format, message.GetArguments());
 }
Пример #19
0
 public static string Invariant(FormattableString messageFormat)
 {
     return(messageFormat.ToString(CultureInfo.InvariantCulture));
 }
Пример #20
0
		public static string CurrentCulture(FormattableString formattable) => formattable?.ToString(CultureInfo.CurrentCulture);
        /*
         *      BASE METHODS
         */

        private static void send_pm(string text, Player player, ChatCategory Category, DefaultChatTags Tags)
        {
            System.FormattableString s = $"{text}";
            ChatManager.ServerMessageToPlayer(s, player.User, false, Tags, Category);
        }
Пример #22
0
 static string Url(FormattableString str)
 {
     return str.ToString(UrlFormatProvider.Instance);
 }
Пример #23
0
 public void Error(string source, FormattableString message, Exception ex = null)
     => Log(LogSeverity.Error, source, message, ex);
Пример #24
0
 public static string Invariant(FormattableString formattable)
 {
     return(formattable.ToString(CultureInfo.InvariantCulture));
 }
Пример #25
0
 public static string Invariant([NotNull] FormattableString formattable) => formattable.ToString(CultureInfo.InvariantCulture);
Пример #26
0
        public static string Invariant(FormattableString formattableString)
        {
            string str = formattableString.ToString(CultureInfo.InvariantCulture);

            return(str);
        }
 FormattableString Interpolation(FormattableString str) => str;
Пример #28
0
 public static string Invariant(FormattableString formattable)
 {
     return String.Format(CultureInfo.InvariantCulture, formattable.Format, formattable.GetArguments());
 }
Пример #29
0
 public static string Invariant (FormattableString formattable) => formattable.ToString(CultureInfo.InvariantCulture);
 private static void send_msg(string text, ChatCategory Category, DefaultChatTags Tags)
 {
     System.FormattableString s = $"{text}";
     ChatManager.ServerMessageToAll(s, false, Tags, Category);
 }
Пример #31
0
 public void Info(string source, FormattableString message, Exception ex = null)
     => Log(LogSeverity.Info, source, message, ex);
Пример #32
0
 /// <summary>
 /// 执行指定的命令。
 /// </summary>
 /// <param name="fs">一个复合格式字符串</param>
 /// <returns>数据源查询与交互的执行器。</returns>
 public IDbExecutor Execute(FormattableString fs)
 {
     this.ThrowIfDisposed();
     return this.Execute(this.Owner.Parse(fs));
 }
Пример #33
0
 public void Debug(string source, FormattableString message, Exception ex = null)
     => Log(LogSeverity.Debug, source, message, ex);
Пример #34
0
 /// <summary>
 /// 执行指定的命令。
 /// </summary>
 /// <param name="fs">一个复合格式字符串</param>
 /// <returns>数据源查询与交互的执行器。</returns>
 public IDbExecutor Execute(FormattableString fs) => this.Execute(this.Parse(fs));
Пример #35
0
        /// <summary> 
        /// Format the given object in the invariant culture. This static method may be 
        /// imported in C# by 
        /// <code> 
        /// using static System.FormattableString; 
        /// </code>. 
        /// Within the scope 
        /// of that import directive an interpolated string may be formatted in the 
        /// invariant culture by writing, for example, 
        /// <code> 
        /// Invariant($""{{ lat = {latitude}; lon = {longitude} }}"") 
        /// </code> 
        /// </summary> 
        public static string Invariant(FormattableString formattable)
        {
            if (formattable == null)
            {
                throw new ArgumentNullException("formattable");
            }

            return formattable.ToString(Globalization.CultureInfo.InvariantCulture);
        }
Пример #36
0
        /// <summary>
        /// 将一个复合格式字符串转换为 <see cref="ExecuteCommand"/> 的对象实例。
        /// </summary>
        /// <param name="fs">一个复合格式字符串</param>
        /// <returns><see cref="ExecuteCommand"/> 的对象实例。</returns>
        public ExecuteCommand Parse(FormattableString fs)
        {
            if(fs == null) throw new ArgumentNullException(nameof(fs));

            var parameters = new ExecuteParameterCollection();
            var sfp = new SqlFormatProvider(parameters, this.Provider);
            var text = fs.ToString(sfp);
            return new ExecuteCommand(text, parameters);
        }
Пример #37
0
	static void FormatPrint (FormattableString message)
	{
		Console.WriteLine(message);
		++counter;
	}
Пример #38
0
 public static void LogErrorF(this ILogger logger, Exception error, FormattableString message)
 {
     logger.LogError(new FormattedLogValues(message.Format, message.GetArguments()), error);
 }
Пример #39
0
 public static void LogInformationF(this ILogger logger, FormattableString message)
 {
     logger.LogInformation(message.Format, message.GetArguments());
 }
Пример #40
0
 public static string Invariant(FormattableString formattable) =>
 formattable?.ToString(Globalization.CultureInfo.InvariantCulture);