This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class ApiKeyAuthOpts : AuthenticationSchemeOptions { | |
| public string Secret { get; set; } | |
| } | |
| public class CustomJwtHendler : AuthenticationHandler<ApiKeyAuthOpts> { | |
| public CustomJwtHendler(IOptionsMonitor<ApiKeyAuthOpts> options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) | |
| : base(options, logger, encoder, clock) { | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static class TaskHelper { | |
| public static void SafeRun(Func<Task> action, HttpContext httpContext = null) { | |
| Task.Run(async () => { | |
| try { | |
| await action.Invoke(); | |
| } catch (Exception e) { | |
| var requestInfo = httpContext?.GetRequestInfos() ?? new Dictionary<string, object>(); | |
| Rollbar.RollbarLocator.RollbarInstance.Error(e, requestInfo); | |
| } | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| namespace Fias.Contracts { | |
| /// <summary> | |
| /// Получение данных о списке домов, зарегистрированных за указанных адресным объектом | |
| /// </summary> | |
| public class GetHouse { | |
| /// <summary> | |
| /// fias.getHouses.rpc | |
| /// </summary> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var errorMsg = ctx.Errors.Aggregate( | |
| new StringBuilder(ctx.StatusCode + Environment.NewLine), | |
| (sb, e) => sb.AppendLine(e.Message) | |
| ).ToString(); | |
| if (ctx.Message.IsRpcMessage()) { | |
| await Hub.SetRpcErrorAsync(ctx.Message, errorMsg, (int)ctx.StatusCode); | |
| } | |
| #pragma warning disable 4014 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static string AndQuery (this bool condition, string query) => | |
| condition ? $" and {query} " : string.Empty; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| await Task.WhenAll(Enumerable.Empty<Task>().Union(bpTasks).Union(spTasks).Union(cpTasks)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static string Stringify(this TimeSpan duration) { | |
| var result = new System.Text.StringBuilder(); | |
| int count; | |
| if (duration.TotalDays >= 1.0) { | |
| count = (int)duration.TotalDays; | |
| result.Append(count).Append(" ").Append(count.GetEnding("день", "дня", "дней")); | |
| } | |
| if (duration.Hours >= 1.0) { | |
| count = (int)duration.Hours; | |
| result.Append(" ").Append(count).Append(" ").Append(count.GetEnding("час", "часа", "часов")); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private string ConvertStringToUtf8Bom(string source) { | |
| var data = Encoding.UTF8.GetBytes(source); | |
| var result = Encoding.UTF8.GetPreamble().Concat(data).ToArray(); | |
| var encoder = new UTF8Encoding(true); | |
| return encoder.GetString(result); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class PetOwner | |
| { | |
| public string Name { get; set; } | |
| public List<string> Pets { get; set; } | |
| } | |
| public static void SelectManyEx3() | |
| { | |
| PetOwner[] petOwners = | |
| { new PetOwner { Name="Higa", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public enum TextCase { Nominative/*Кто? Что?*/, Genitive/*Кого? Чего?*/, Dative/*Кому? Чему?*/, Accusative/*Кого? Что?*/, Instrumental/*Кем? Чем?*/, Prepositional/*О ком? О чём?*/ }; | |
| public static class RuDateAndMoneyConverter | |
| { | |
| static string[] monthNamesGenitive = { "", "января", "февраля", "марта", "апреля", "мая", "июня", "июля", "августа", "сентября", "октября", "ноября", "декабря" }; | |
| static string zero = "ноль"; | |
| static string firstMale = "один"; | |
| static string firstFemale = "одна"; | |
| static string firstFemaleAccusative = "одну"; |