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 Animal : ICloneable<Animal> | |
| { | |
| public virtual Animal Clone() | |
| { | |
| return new Animal(this); | |
| } | |
| } | |
| // нет переопределения метода | |
| class Dog : Animal |
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
| namespace Serializer | |
| { | |
| public class F { | |
| public int i1 { get; set; } | |
| public int i2 { get; set; } | |
| public int i3 { get; set; } | |
| public int i4 { get; set; } | |
| public int i5 { get; set; } | |
| public F(int i) { i1 = i; i2 = i + 1; i3 = i + 2; i4 = i + 3; i5 = i + 4; } |
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; | |
| using System.Collections.Generic; | |
| using System.Net; | |
| using Microsoft.AspNetCore.Mvc; | |
| namespace YourNamespace | |
| { | |
| public class ValidationProblemDetails : ProblemDetails | |
| { | |
| // 400 status ccode is usually used for input validation errors |
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.Collections.Generic; | |
| using System.Linq; | |
| using System.Threading.Tasks; | |
| using Microsoft.AspNetCore.Mvc; | |
| using Utils.Serialization; | |
| namespace YourNamespace | |
| { | |
| public class ValidationProblemDetailsResult : IActionResult | |
| { |
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 Startup | |
| { | |
| // ... | |
| public void ConfigureServices(IServiceCollection services) | |
| { | |
| // ... | |
| services | |
| .Configure<ApiBehaviorOptions>(x => | |
| { | |
| x.InvalidModelStateResponseFactory = ctx => new ValidationProblemDetailsResult(); |
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 Startup | |
| { | |
| public void ConfigureServices(IServiceCollection services) | |
| { | |
| // ... | |
| services | |
| .AddMvc() | |
| .AddJsonOptions(x => | |
| { | |
| x.JsonSerializerOptions.PropertyNamingPolicy = new SnakeCaseNamingPolicy(); |
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.Text.Json; | |
| using Utils.Serialization; | |
| namespace YourNamespace | |
| { | |
| public class SnakeCaseNamingPolicy : JsonNamingPolicy | |
| { | |
| public override string ConvertName(string name) => name.ToSnakeCase(); | |
| } | |
| } |
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 Newtonsoft.Json; | |
| using Newtonsoft.Json.Serialization; | |
| using Utils.Helpers; | |
| namespace YourNamespace | |
| { | |
| public static class JsonSerializationExtensions | |
| { | |
| private static readonly SnakeCaseNamingStrategy _snakeCaseNamingStrategy | |
| = new SnakeCaseNamingStrategy(); |
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; | |
| using System.Collections.Generic; | |
| using System.Diagnostics; | |
| using System.Linq; | |
| using System.Threading; | |
| using System.Threading.Tasks; | |
| namespace MultiThread_25 | |
| { | |
| class Program |
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; | |
| using System.Text.RegularExpressions; | |
| namespace Utils.Helpers | |
| { | |
| public class EmailValidRegex : Regex | |
| { | |
| private const string Pattern = | |
| @"^(?("")("".+?(?<!\\)""@)|(([0-9a-z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-z])@))" + | |
| @"(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-z][-0-9a-z]*[0-9a-z]*\.)+[a-z0-9][\-a-z0-9]{0,22}[a-z0-9]))$"; |