This file contains 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 MyService | |
{ | |
/* ... dependencies ... */ | |
MyResult Process(MyParams params) | |
{ | |
if (!IsSerialCodeValid(params.SerialCode)) return MyResult.InvalidSerialCode; | |
var externalId = GetExternalId(params.SerialCode); | |
StoreData(params.SerialCode, externalId); | |
Report(params.SerialCode, externalId); |
This file contains 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 MyService | |
{ | |
private readonly ISerialCodeValidator serialCodeValidator; | |
private readonly IExternalIdService externalIdService; | |
private readonly IDataService dataService; | |
private readonly IReportingService reportingService; | |
MyResult Process(MyParams params) | |
{ | |
if (!serialCodeValidator.IsSerialCodeValid(params.SerialCode)) return MyResult.InvalidSerialCode; |
This file contains 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 EmailValidator | |
{ | |
/* dependencies */ | |
bool IsEmailValid(string email) | |
{ | |
if ((email?.Length ?? 0) < 3) return false; | |
if (!Regex.IsMatch(email, myPattern)) return false; | |
if (myBlacklistService.IsEmailBlacklisted(email)) return false; | |
return true; |
This file contains 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 EmailValidator | |
{ | |
private readonly IEmailLengthValidation emailLengthValidation; | |
private readonly IEmailRegexValidation emailRegexValidation; | |
private readonly IEmailBlacklistValidation emailBlacklistValidation; | |
bool IsEmailValid(string email) | |
{ | |
if (!emailLengthValidation.IsEmailValid(email)) return false; | |
if (!emailRegexValidation.IsEmailValid(email)) return false; |
This file contains 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 EmailValidator | |
{ | |
private readonly IEnumerable<IEmailValidation> emailValidations; | |
/*...ctor...*/ | |
bool IsEmailValid(string email) => emailValidations | |
.Aggregate(true, (acc, src) => acc ? src.IsEmailValid(email) : acc); | |
} | |
interface IEmailValidation | |
{ |
This file contains 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 Processor | |
{ | |
// .. dependencies | |
void Process(MyInput input) | |
{ | |
if (ValidateInput(input)) | |
{ | |
new DatabaseConnection(...).ExecuteSql("..."); | |
} |
This file contains 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 serviceCollection = new ServiceCollection(); | |
serviceCollection.AddTransient<IHttpService, HttpService>(); | |
serviceCollection.AddTransient<IService, LoggingService>(); |
This file contains 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 MyDto | |
{ | |
public string MyQueryStringValue { get; set; } | |
public string[] MyQuerystringArray { get; set; } | |
} |
This file contains 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
// myApiResource: Resource defined | |
myApiResource.addMethod( | |
...http_method..., | |
{ | |
...lambda_integration_options... | |
requestTemplates: 'application/json': `{ | |
"MyQueryStringValue": "$input.params('MyQueryStringValue')" | |
#if ($input.params('MyQuerystringArray') != '') | |
,"MyQuerystringArray": $input.params('MyQuerystringArray') |
This file contains 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
{ | |
..., | |
"multiValueQueryStringParameters": { | |
"parameter1": [ | |
"value1", | |
"value2" | |
], | |
"parameter2": [ | |
"value" | |
] |