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.Threading; | |
| using System.Threading.Tasks; | |
| using Microsoft.Extensions.Caching.Distributed; | |
| using Microsoft.Extensions.Configuration; | |
| using Microsoft.Extensions.DependencyInjection; | |
| using StackExchange.Redis; | |
| using Xunit; | |
| [assembly: CollectionBehavior(DisableTestParallelization = true)] |
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.ComponentModel.DataAnnotations; | |
| using System.Linq; | |
| using System.Reflection; | |
| namespace Examples.Extensions | |
| { | |
| public static class ObjectArrayToHtmlTable_Extension | |
| { |
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 ParseNumberByNumberStyles_Test | |
| { | |
| [Fact] | |
| public void DefaultNumberParsing_TestCase() | |
| { | |
| { | |
| var val = "1.0"; | |
| var isSuccess = int.TryParse(val, out int parsedNumber); | |
| Assert.False(isSuccess); | |
| } |
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 CheckboxGroupNotEmptyValidation : ValidationAttribute | |
| { | |
| readonly object TRUE = true; | |
| string[] _alltheOtherProperty; | |
| public CheckboxGroupNotEmptyValidation(params string[] alltheOthersProperty) | |
| { | |
| _alltheOtherProperty = alltheOthersProperty; | |
| } |
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 ServiceCollectionExtension | |
| { | |
| public static IServiceCollection AddDerivedRepository(this IServiceCollection services, ServiceLifetime lifetime) | |
| { | |
| var scanAssemblies = AppDomain.CurrentDomain.GetAssemblies().ToList(); | |
| var interfaces = scanAssemblies.SelectMany(o => o.DefinedTypes | |
| .Where(x => x.IsInterface) | |
| .Where(x => x != typeof(IRepository)) // exclude super interface | |
| .Where(x => typeof(IRepository).IsAssignableFrom(x)) | |
| ); |
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 MethodReturnType_Test | |
| { | |
| [Fact] | |
| public void IsGenericType_ReturnFalse_TestCase() | |
| { | |
| var method1 = GetType().GetMethod(nameof(Method1ReturnVoid), | |
| BindingFlags.Instance | BindingFlags.NonPublic | |
| ); | |
| Assert.NotNull(method1); | |
| Assert.Equal(typeof(void), method1.ReturnType); |
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 IServiceCollection RegisterAssemblyTypes<T>(this IServiceCollection services, ServiceLifetime lifetime, params Assembly[] assemblies) => | |
| services.RegisterAssemblyTypes<T>(lifetime: lifetime, predicates: null, assemblies: assemblies); | |
| public static IServiceCollection RegisterAssemblyTypes<T>(this IServiceCollection services, | |
| ServiceLifetime lifetime, List<Func<TypeInfo, bool>> predicates, params Assembly[] assemblies) | |
| { | |
| var inputAssemblies = assemblies.ToList(); | |
| scanAssemblies.SelectMany(x => x.GetReferencedAssemblies()) | |
| .Where(t => false == scanAssemblies.Any(a => a.FullName == t.FullName)) | |
| .Distinct() |
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 Interface_Test : TestBase | |
| { | |
| [Fact] | |
| public void IsAssignable_Test() | |
| { | |
| Assert.True(typeof(IRepository).IsAssignableFrom(typeof(IRepository))); | |
| Assert.True(typeof(IRepository).IsAssignableFrom(typeof(IEmployeeRepository))); | |
| Assert.True(typeof(IRepository).IsAssignableFrom(typeof(RepositoryBase))); | |
| Assert.True(typeof(IRepository).IsAssignableFrom(typeof(EmployeeRepository))); | |
| Assert.True(typeof(IRepository).IsAssignableFrom(typeof(CustomerRepository))); |
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
| TAG_REGEX="[0-9]\+.[0-9]\+.[0-9]\+[.-]\(build\)\?[0-9]\+" | |
| ECR_HOST="123456789.dkr.ecr.us-west-2.amazonaws.com" | |
| ECR_REPO="hello-api" | |
| target_file="02_deployment.yaml" | |
| next_version="1.0.0.1" | |
| # 1.0.0.0 => 1.0.0.1 | |
| sed -i "s/$(ECR_HOST)\/$(ECR_REPO):$(TAG_REGEX)/$(ECR_HOST)\/$(ECR_REPO):$(next_version)/" $target_file | |
| cat $target_file |
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
| # ASP.NET Core | |
| # Build and test ASP.NET Core projects targeting .NET Core. | |
| # Add steps that run tests, create a NuGet package, deploy, and more: | |
| # https://docs.microsoft.com/en-us/azure/devops/pipelines/ecosystems/dotnet-core?view=azure-devops | |
| name: "Build API && Deploy" | |
| trigger: | |
| branches: | |
| include: | |
| - feat/* |