├── blazor-ui └── README.md ├── blazor-features └── README.md ├── blazor-libraries └── README.md ├── aspnetcore-webapi ├── VersioningRestAPI │ └── VersioningRestAPI │ │ ├── libman.json │ │ ├── appsettings.Development.json │ │ ├── appsettings.json │ │ ├── Data.cs │ │ ├── V2 │ │ └── Controllers │ │ │ └── StringListController.cs │ │ ├── V3 │ │ └── Controllers │ │ │ └── StringListController.cs │ │ ├── VersioningRestAPI.csproj │ │ └── V1 │ │ └── Controllers │ │ └── StringListController.cs ├── Minimal API │ └── Minimal API │ │ ├── ArticleRequest.cs │ │ ├── appsettings.Development.json │ │ ├── appsettings.json │ │ ├── Article.cs │ │ ├── ApiContext.cs │ │ ├── IArticleService.cs │ │ └── Minimal API.csproj ├── ASPNETCoreRabbitMQ │ ├── Producer │ │ ├── RabbitMQ │ │ │ └── IMessageProducer.cs │ │ ├── appsettings.Development.json │ │ ├── Data │ │ │ ├── IOrderDbContext.cs │ │ │ ├── Order.cs │ │ │ └── OrderDbContext.cs │ │ ├── Dtos │ │ │ └── OrderDto.cs │ │ └── appsettings.json │ └── Subscriber │ │ ├── Properties │ │ └── launchSettings.json │ │ └── Subscriber.csproj ├── MassTransitRabbitMQ │ ├── Producer │ │ ├── appsettings.Development.json │ │ ├── appsettings.json │ │ ├── OrderDto.cs │ │ ├── Program.cs │ │ └── Producer.csproj │ ├── SharedModels │ │ ├── SharedModels.csproj │ │ └── OrderCreated.cs │ └── Consumer │ │ └── Consumer.csproj ├── CreatingMultipleResourcesWithPOST │ └── CreatingMultipleResourcesWithPOST │ │ ├── Models │ │ ├── BookModel.cs │ │ ├── MultipleBooksBase.cs │ │ ├── BookRequest.cs │ │ ├── MultipleBooksModel.cs │ │ └── MultipleBooksErrorModel.cs │ │ ├── appsettings.Development.json │ │ ├── appsettings.json │ │ ├── Services │ │ └── IBookService.cs │ │ └── CreatingMultipleResourcesWithPOST.csproj ├── RateLimitingDemo │ ├── RateLimitingDemo.Common │ │ ├── Model │ │ │ └── Product.cs │ │ ├── RateLimitingDemo.Common.csproj │ │ └── Repositories │ │ │ └── IProductCatalogRepository.cs │ ├── RateLimitingDemo.UsingCustomMiddleware │ │ ├── appsettings.Development.json │ │ ├── appsettings.json │ │ ├── Decorators │ │ │ └── LimitRequests.cs │ │ ├── Extensions │ │ │ └── MiddlewareExtensions.cs │ │ ├── RateLimitingDemo - Backup.UsingCustomMiddleware.csproj │ │ └── RateLimitingDemo.UsingCustomMiddleware.csproj │ └── RateLimitingDemo.UsingAspNetCoreRateLimitPackage │ │ ├── appsettings.Development.json │ │ └── appsettings.json ├── HealthChecksAspNetCore │ └── HealthChecksAspNetCore │ │ ├── appsettings.Development.json │ │ └── appsettings.json ├── WorkingWithRestSharp │ └── WorkingWithRestSharp │ │ ├── appsettings.Development.json │ │ ├── appsettings.json │ │ ├── DataTransferObject │ │ ├── Support.cs │ │ ├── UserDetails.cs │ │ ├── UserForUpdate.cs │ │ ├── UserForCreation.cs │ │ ├── UserList.cs │ │ ├── UserUpdateResponse.cs │ │ ├── UserCreationResponse.cs │ │ ├── PagingInformation.cs │ │ └── UserData.cs │ │ ├── WorkingWithRestSharp.csproj │ │ └── Program.cs ├── SerializationDemo │ ├── SerializationDemo.EmployeeApi │ │ ├── appsettings.Development.json │ │ ├── appsettings.json │ │ ├── Repositories │ │ │ └── IEmployeeRepository.cs │ │ └── SerializationDemo.EmployeeApi.csproj │ ├── SerializationDemo.Client │ │ ├── Clients │ │ │ ├── ClientBase.cs │ │ │ └── IClient.cs │ │ ├── Serialization │ │ │ ├── IByteSerializer.cs │ │ │ └── IStringSerializer.cs │ │ └── SerializationDemo.Client.csproj │ └── SerializationDemo.Common │ │ ├── SerializationDemo.Common.csproj │ │ └── Models │ │ ├── Employee.cs │ │ └── Address.cs ├── OptionalParameterinWebApi │ ├── OptionalParameterinWebApi │ │ ├── appsettings.Development.json │ │ ├── appsettings.json │ │ ├── Product.cs │ │ ├── OptionalParameterinWebApi.csproj │ │ └── WeatherForecast.cs │ └── Test │ │ └── WeatherForecastControllerTest.cs ├── CustomHeadersInASPNETCoreWebAPI │ ├── CustomHeadersInASPNETCoreWebAPI │ │ ├── appsettings.Development.json │ │ ├── appsettings.json │ │ ├── CustomHeadersInASPNETCoreWebAPI.csproj │ │ └── CustomHeaderAttribute.cs │ └── ClientApplication │ │ └── client-custom-header.js └── MandatoryQueryStringParameters │ └── MandatoryQueryStringParameters │ ├── appsettings.Development.json │ ├── appsettings.json │ ├── MandatoryQueryStringParameters.csproj │ ├── QueryParameters.cs │ └── Program.cs ├── csharp-algorithms ├── MergeSort │ └── MergeSort │ │ ├── Program.cs │ │ └── MergeSort.csproj ├── BubbleSort │ └── BubbleSort │ │ ├── Program.cs │ │ └── BubbleSort.csproj ├── SelectionSort │ └── SelectionSort │ │ ├── Program.cs │ │ └── SelectionSort.csproj └── README.md ├── collections-csharp ├── CsharpLists │ └── CsharpLists │ │ ├── Program.cs │ │ ├── CsharpLists.csproj │ │ └── ListOperations.cs ├── SortedListInCSharp │ ├── SortedListInCSharp │ │ ├── SortedListInCSharp.csproj │ │ └── Program.cs │ └── Tests │ │ └── Tests.csproj ├── HowToDetectIfADictionaryKeyExistsInCsharp │ ├── Test │ │ └── HowToDetectIfADictionaryKeyExistsInCsharpUnitTest.cs │ └── HowToDetectIfADictionaryKeyExistsInCsharp │ │ ├── HowToDetectIfADictionaryKeyExistsInCsharp.csproj │ │ ├── Program.cs │ │ └── MyClass.cs ├── IterateThroughDictionary │ ├── BenchmarkRunner │ │ ├── ProgramBenchmark.cs │ │ └── BenchmarkRunner.csproj │ └── IterateThroughDictionary │ │ └── IterateThroughDictionary.csproj ├── DictionaryGetValueByIndex │ ├── DictionaryGetValueByIndex │ │ └── DictionaryGetValueByIndex.csproj │ └── DictionaryTests │ │ └── DictionaryTests.csproj ├── RemoveFromListWhileIterating │ └── RemoveFromListWhileIterating │ │ └── RemoveFromListWhileIterating.csproj └── README.md ├── csharp-arrays ├── CompareArrays │ ├── BenchmarkRunner │ │ ├── Program.cs │ │ └── BenchmarkRunner.csproj │ ├── CompareArrays │ │ ├── CompareArrays.csproj │ │ └── Article.cs │ └── Tests │ │ └── Tests.csproj ├── InitializeArrays │ └── InitializeArrays │ │ ├── Program.cs │ │ └── InitializeArrays.csproj ├── SliceArrays │ ├── SliceArrays │ │ └── SliceArrays.csproj │ └── SliceArrayTests │ │ └── SliceArrayTests.csproj ├── SumUpArrayElements │ ├── BenchmarkRunner │ │ ├── Program.cs │ │ └── BenchmarkRunner.csproj │ └── SumUpArrayElements │ │ └── SumUpArrayElements.csproj ├── PopulateArrayWithTheSameValue │ ├── BenchmarkRunner │ │ ├── Program.cs │ │ └── BenchmarkRunner.csproj │ └── PopulateArrayWithTheSameValue │ │ ├── PopulateArrayWithTheSameValue.csproj │ │ └── Article.cs ├── CopyArrayElements │ ├── BenchmarkRunner │ │ ├── Program.cs │ │ └── BenchmarkRunner.csproj │ └── CopyArrayElements │ │ ├── Article.cs │ │ └── CopyArrayElements.csproj ├── FindTheMaximumValue │ ├── BenchmarkRunner │ │ ├── Program.cs │ │ └── BenchmarkRunner.csproj │ └── FindTheMaximumValue │ │ └── FindTheMaximumValue.csproj └── README.md ├── csharp-basic-topics ├── TopLevelStatementsInCSharp │ └── TopLevelStatementsInCSharp │ │ ├── TopLevelProgram.cs │ │ ├── OldStyleProgram.cs │ │ ├── Fridge.cs │ │ └── TopLevelStatementsInCSharp.csproj ├── InequalityVsIsNotInCSharp │ └── InequalityVsIsNot │ │ ├── Brand.cs │ │ ├── Car.cs │ │ └── InequalityVsIsNot.csproj ├── WhatsNewInCSharp10 │ └── WhatsNewInCSharp10 │ │ ├── Usings.cs │ │ ├── CodeMazeArticle.cs │ │ ├── Article.cs │ │ ├── WhatsNewInCSharp10.csproj │ │ └── Maze.cs ├── ExpressionBodiedMembersInCsharp │ ├── ExpressionBodiedMembersInCsharp │ │ ├── Program.cs │ │ ├── ExpressionBodiedMembersInCsharp.csproj │ │ ├── Square.cs │ │ ├── SquareRefactored.cs │ │ ├── Staff.cs │ │ ├── Employee.cs │ │ └── EmployeeRefactored.cs │ └── Test │ │ └── SquareTests.cs ├── TypesOfInheritanceInCSharp │ └── TypesOfInheritanceInCSharp │ │ ├── ILaptop.cs │ │ ├── TypesOfInheritanceInCSharp.csproj │ │ ├── MobileDevice.cs │ │ ├── ConvertibleNotebook.cs │ │ └── AndroidSmartphone.cs ├── BreakAndContinueStatementsInCsharp │ └── BreakAndContinueStatementsInCsharp │ │ └── BreakAndContinueStatementsInCsharp.csproj ├── AsAndIsOperatorsInCSharp │ └── AsAndIsOperatorsInCSharp │ │ ├── AsAndIsOperatorsInCSharp.csproj │ │ ├── Cow.cs │ │ └── Animal.cs ├── SwitchCaseExpressions │ └── SwitchCaseExpressions │ │ └── SwitchCaseExpressions.csproj ├── ParamsKeyword │ └── ParamsKeyword │ │ ├── ShoppingList.cs │ │ └── ParamsKeyword.csproj ├── NamedAndOptionalArgumentsInCSharp │ └── NamedAndOptionalArgumentsInCSharp │ │ └── NamedAndOptionalArgumentsInCSharp.csproj └── PatternMatchingInCSharp │ └── PropertyPatternsDemo │ ├── DataModel.cs │ └── PropertyPatternsTest.csproj ├── json-csharp ├── README.md ├── JsonSerializationWriteToFile │ ├── JsonSerializationWriteToFile.Benchmark │ │ └── Program.cs │ └── JsonSerializationWriteToFile │ │ ├── JsonSerializationWriteToFile.csproj │ │ └── College.cs ├── JsonSerializationOfEnumAsString │ ├── JsonSerialization.Native.EnumAsString.WebApi │ │ ├── appsettings.Development.json │ │ ├── appsettings.json │ │ ├── Program.cs │ │ └── Controllers │ │ │ └── CanvasController.cs │ ├── JsonSerialization.Native.EnumAsString.MinimalApi │ │ ├── appsettings.Development.json │ │ ├── appsettings.json │ │ └── Program.cs │ ├── JsonSerialization.Newtonsoft.EnumAsString.WebApi │ │ ├── appsettings.Development.json │ │ ├── appsettings.json │ │ ├── Program.cs │ │ └── Controllers │ │ │ └── CanvasController.cs │ ├── JsonSerialization.EnumAsString.Models │ │ ├── TextStyles.cs │ │ ├── JsonSerialization.EnumAsString.Models.csproj │ │ ├── ToggleControl.cs │ │ └── Canvas.cs │ ├── JsonSerialization.Native.EnumAsStringTests │ │ ├── PropertySelection │ │ │ └── PropertySelectionUnitTest.cs │ │ ├── TypeSelection │ │ │ └── TypeSelectionUnitTest.cs │ │ ├── DefaultSerializationUnitTest.cs │ │ └── UnitTestBase.cs │ └── JsonSerialization.Newtonsoft.EnumAsStringTests │ │ ├── PropertySelection │ │ └── PropertySelectionUnitTest.cs │ │ ├── TypeSelection │ │ └── TypeSelectionUnitTest.cs │ │ ├── DefaultSerializationUnitTest.cs │ │ └── UnitTestBase.cs └── DeserializeComplexJsonObject │ ├── DeserializeComplexJSONObject │ ├── POCO │ │ ├── Cofounder.cs │ │ ├── Position.cs │ │ ├── Benefit.cs │ │ ├── Company.cs │ │ └── Employee.cs │ └── NewtonsoftDeserializer.cs │ └── BenchmarkRunner │ ├── Program.cs │ └── BenchmarkRunner.csproj ├── dotnet-datetime ├── DateTimeOperators │ └── DateTimeOperators │ │ ├── Program.cs │ │ └── DateTimeOperators.csproj ├── DateTimeFormatInCSharp │ ├── DateTimeFormatInCSharp │ │ ├── Program.cs │ │ └── DateTimeFormatInCSharp.csproj │ └── Test │ │ └── Test.csproj ├── CheckDateTimeIsWeekend │ ├── CheckDateTime │ │ └── CheckDateTime.csproj │ └── CheckDateTime.Tests │ │ └── CheckDateTime.Tests.csproj ├── GetDatePartFromDateTime │ ├── GetDatePartFromDateTime │ │ └── GetDatePartFromDateTime.csproj │ └── GetDatePartFromDateTime.Tests │ │ └── GetDatePartFromDateTime.Tests.csproj ├── DateTimeNowVsDateTimeUtcNow │ ├── DateTimeNowVsDateTimeUtcNow │ │ └── DateTimeNowVsDateTimeUtcNow.csproj │ └── DateTimeNow.Tests │ │ └── DateTimeNow.Tests.csproj ├── DateOnlyAndTimeOnlyInCSharp │ └── DateOnlyAndTimeOnlyInCSharpExample │ │ └── DateOnlyAndTimeOnlyInCSharpExample.csproj └── ConvertDateTimeToIso8601String │ └── ConvertDateTimeToIso8601String │ └── ConvertDateTimeToIso8601String.csproj ├── files-csharp ├── WriteToCsv │ └── WriteToCsv │ │ ├── Program.cs │ │ ├── WriteToCsv.csproj │ │ └── Person.cs ├── README.md └── ByteArrayToFile │ └── ByteArrayToFile │ ├── ByteArrayToFile.csproj │ └── ByteArrayToFileConverter.cs ├── csharp-intermediate-topics ├── CompositionVsInheritance │ └── CompositionVsInheritance │ │ ├── Caravan.cs │ │ ├── Address.cs │ │ ├── Floor.cs │ │ ├── Ceiling.cs │ │ ├── CompositionVsInheritance.csproj │ │ ├── BrickHouse.cs │ │ ├── GlassHouse.cs │ │ ├── House.cs │ │ └── Program.cs ├── RecordsInCSharp │ └── RecordsInCSharpExample │ │ ├── Employee.cs │ │ ├── RecordsInCSharpExample.csproj │ │ ├── Person.cs │ │ └── Program.cs ├── PolymorphismInCsharp │ └── PolymorphismInCsharp │ │ └── PolymorphismInCsharp.csproj ├── StaticClasses │ └── StaticClasses │ │ └── StaticClasses.csproj ├── TuplesInCsharp │ └── TuplesInCsharp │ │ └── TuplesInCsharp.csproj ├── OperatorOverloading │ └── OperatorOverloading │ │ └── OperatorOverloading.csproj ├── DifferencesBetweenValueTupleAndTupleInCSharp │ └── DifferencesBetweenValueTupleAndTupleInCSharp │ │ └── DifferencesBetweenValueTupleAndTupleInCSharp.csproj └── README.md ├── strings-csharp ├── UsingVariablesInsideStrings │ └── UsingVariablesInsideStrings │ │ ├── Program.cs │ │ ├── UsingVariablesInsideStrings.csproj │ │ └── MyClass.cs ├── AddParametersToString │ ├── AddParametersToString │ │ └── AddParametersToString.csproj │ └── AddParametersToStringTests │ │ └── AddParametersToStringTests.csproj ├── ConvertStringToBoolean │ ├── ConvertStringToBoolean │ │ └── ConvertStringToBoolean.csproj │ └── ConvertStringToBooleanTests │ │ └── ConvertStringToBooleanTests.csproj ├── StringBuilderType │ ├── BenchmarkRunner │ │ ├── Program.cs │ │ └── BenchmarkRunner.csproj │ └── StringBuilderType │ │ └── StringBuilderType.csproj ├── ConvertInt2String │ ├── ConvertInt2String │ │ └── ConvertInt2String.csproj │ └── ConvertInt2StringTests │ │ └── ConvertInt2StringTests.csproj ├── ConvertCharArray2String │ ├── ConvertCharArray2String │ │ └── ConvertCharArray2String.csproj │ └── ConvertCharArray2StringTests │ │ └── ConvertCharArray2StringTests.csproj ├── StringBuilderCheckEmpty │ ├── StringBuilderCheckEmpty │ │ └── StringBuilderCheckEmpty.csproj │ └── StringBuilderTests │ │ └── StringBuilderTests.csproj ├── ConvertTitleCaseToCamelCase │ └── ConvertTitleCaseToCamelCase │ │ ├── ConvertTitleCaseToCamelCase.csproj │ │ └── Program.cs └── README.md ├── aspnetcore-features ├── README.md ├── InMemoryCaching │ └── InMemoryCacheExample │ │ ├── appsettings.Development.json │ │ ├── Models │ │ ├── Repository │ │ │ └── IDataRepository.cs │ │ └── Employee.cs │ │ ├── appsettings.json │ │ └── Properties │ │ └── launchSettings.json └── CustomAttributes │ └── CustomAttributes │ ├── CustomAttributes.csproj │ ├── Enums.cs │ ├── YourTasks.cs │ ├── ManagerTaskAttribute.cs │ ├── TaskDescriptorAttribute.cs │ ├── DeveloperTaskAttribute.cs │ └── Program.cs ├── dotnet-projects ├── ProjectTemplates │ ├── codemazeapi │ │ ├── appsettings.Development.json │ │ ├── appsettings.json │ │ ├── codemazeapi.csproj │ │ ├── Controllers │ │ │ ├── ContactController.cs │ │ │ └── ValuesController.cs │ │ └── Program.cs │ └── Test │ │ └── CustomWebApplicationFactory.cs ├── README.md └── NugetUsingCLI │ ├── CodeMaze.Utilities.TemperatureConverter │ ├── Converter.cs │ └── CodeMaze.Utilities.TemperatureConverter.csproj │ └── Tests │ └── ConverterTests.cs ├── xml-csharp ├── README.md └── XMLSerializationInCsharp │ └── XMLSerializationInCsharp │ ├── XMLSerializationInCsharp.csproj │ ├── Program.cs │ ├── XMLSerialization_v1.cs │ ├── XMLSerialization_v2.cs │ └── XMLSerialization_v5.cs ├── numbers-csharp ├── ParseAndTryParseInCSharp │ └── ParseAndTryParseInCSharp │ │ ├── Program.cs │ │ └── ParseAndTryParseInCSharp.csproj ├── MathInCSharp │ └── MathInCSharp │ │ └── MathInCSharp.csproj ├── ConvertString2Int │ ├── ConvertString2Int │ │ ├── ConvertString2Int.csproj │ │ ├── CustomConvert.cs │ │ └── Program.cs │ ├── BenchmarkRunner │ │ ├── Program.cs │ │ └── BenchmarkRunner.csproj │ └── ConvertString2IntTests │ │ └── ConvertString2IntTests.csproj ├── GenerateRandomDoubles │ └── GenerateRandomDoubles │ │ └── GenerateRandomDoubles.csproj ├── GenerateRandomNumbers │ └── GenerateRandomNumbers │ │ └── GenerateRandomNumbers.csproj ├── IntParseVsConvertToInt │ ├── IntParseVsConvertToInt │ │ └── IntParseVsConvertToInt.csproj │ └── Tests │ │ └── Tests.csproj └── README.md ├── threads-csharp ├── README.md └── MultithreadingInCsharp │ ├── RunCodeInNewThreadConsoleApplication │ ├── ThreadInfo.cs │ └── RunCodeInNewThreadConsoleApplication.csproj │ └── RunCodeInNewThreadApplication │ ├── App.xaml.cs │ ├── App.xaml │ ├── RunCodeInNewThreadApplication.csproj │ ├── PdfValidator.cs │ └── AssemblyInfo.cs ├── csharp-advanced-topics ├── EventsInCsharp │ └── EventsInCsharp │ │ ├── Model │ │ └── Order.cs │ │ ├── EventsInCsharp.csproj │ │ ├── EventArguments │ │ └── FoodPreparedEventArgs.cs │ │ ├── Services │ │ ├── AppService.cs │ │ ├── MailService.cs │ │ └── FoodOrderingService.cs │ │ └── Program.cs ├── DelegatesInCsharp │ ├── .idea │ │ └── .idea.DelegatesInCsharp │ │ │ └── .idea │ │ │ ├── encodings.xml │ │ │ ├── vcs.xml │ │ │ ├── indexLayout.xml │ │ │ └── .gitignore │ ├── DelegatesInCsharp │ │ └── DelegatesInCsharp.csproj │ ├── ActionAndFuncDelegatesInCsharp │ │ └── ActionAndFuncDelegatesInCsharp.csproj │ └── Tests │ │ └── Tests.csproj ├── README.md └── QueueInCSharp │ └── QueueInCSharp │ ├── QueueInCSharp.csproj │ ├── Models │ └── Order.cs │ └── Program.cs ├── visual-studio ├── README.md └── DebuggingBasicsInCSharp │ ├── DebuggingBasicsInCSharp │ └── DebuggingBasicsInCSharp.csproj │ └── Tests │ └── Tests.cs ├── csharp-design-patterns ├── VisitorPattern │ ├── VisitorPatternTests │ │ └── Structural Code Tests │ │ │ ├── Elements │ │ │ ├── IVisitableElement.cs │ │ │ ├── ConcreteElementTwo.cs │ │ │ └── ConcreteElementOne.cs │ │ │ └── Visitors │ │ │ ├── IVisitor.cs │ │ │ └── ConcreteVisitorOne.cs │ ├── TeamA.TestResults │ │ ├── ExtensibilityContract │ │ │ ├── AlertReport.cs │ │ │ ├── ISicknessAlertVisitable.cs │ │ │ └── ISicknessAlertVisitor.cs │ │ ├── TeamA.TestResults.csproj │ │ └── Results │ │ │ ├── BloodSample.cs │ │ │ ├── EcgReading.cs │ │ │ └── XRayImage.cs │ ├── TeamB.Detectors │ │ └── TeamB.Detectors.csproj │ └── .editorconfig ├── ObserverPattern │ ├── ObserverPattern │ │ ├── ObserverPattern.csproj │ │ └── Application.cs │ └── Tests │ │ └── Tests.csproj └── README.md ├── authorization-dotnet ├── UsingAuthorizationWithSwagger │ ├── UsingAuthorizationWithSwagger │ │ ├── appsettings.Development.json │ │ ├── Models │ │ │ ├── Product.cs │ │ │ └── LoginModel.cs │ │ ├── appsettings.json │ │ └── UsingAuthorizationWithSwagger.csproj │ └── Test │ │ └── Helpers │ │ ├── Token.cs │ │ └── HelperClass.cs └── README.md ├── dotnet-dependency-injection ├── DependencyInjectionLifetimeScopes │ ├── DependencyInjectionLifetimeScopes │ │ ├── Services │ │ │ ├── Interfaces │ │ │ │ ├── IMyScopedService.cs │ │ │ │ ├── IMySingletonService.cs │ │ │ │ ├── IMyTransientService .cs │ │ │ │ └── IMyService.cs │ │ │ └── MyService.cs │ │ ├── appsettings.Development.json │ │ ├── appsettings.json │ │ └── DependencyInjectionLifetimeScopes.csproj │ └── Test │ │ └── CustomWebApplicationFactory.cs └── README.md ├── dotnet-client-libraries ├── README.md └── Google Sheets API │ ├── GoogleSheetsAPI │ ├── appsettings.Development.json │ ├── appsettings.json │ ├── Item.cs │ ├── GoogleSheetsAPI.csproj │ └── Program.cs │ └── GoogleSheetsAPITest │ └── CustomWebApplicationFactory.cs ├── dependency-injection-tools ├── AutoFacImplementationWeb │ ├── AutoFacImplementationWeb │ │ ├── Interface │ │ │ ├── IStringBusiness.cs │ │ │ └── IPersonBusiness.cs │ │ ├── appsettings.Development.json │ │ ├── appsettings.json │ │ ├── Implementation │ │ │ ├── StringBusiness.cs │ │ │ └── PersonBusiness.cs │ │ ├── AutoFacImplementationWeb.csproj │ │ ├── Program.cs │ │ └── Controllers │ │ │ └── StringHelperController.cs │ └── Test.AutoFacImplementationWeb │ │ ├── StringBusinessTestImplementation.cs │ │ └── PersonBusinessTestImplementation.cs └── README.md ├── dotnet-logging ├── README.md └── LoggingAPI │ └── LoggingAPI │ ├── Program.cs │ └── LoggingAPI.csproj ├── dotnet-testing └── NUnitProject │ ├── NUnitProject │ ├── NUnitProject.csproj │ └── Calculator.cs │ └── NUnitProject.Tests │ └── NUnitProject.UnitTests.csproj ├── exception-handling ├── CatchMultipleExceptions │ └── CatchMultipleExceptions │ │ └── CatchMultipleExceptions.csproj ├── README.md └── ThrowVsThrowEx │ └── ThrowVsThrowEx │ └── ThrowVsThrowEx.csproj └── async-csharp ├── README.md ├── Asynchronous Programming vs Multithreading └── Asynchronous Programming │ └── AsynchronousProgramming.csproj └── CancellationTokensIAsyncEnumerable └── CancellationIAsyncEnumerable ├── CancellationIAsyncEnumerable.csproj └── CancellationToken.cs /blazor-ui/README.md: -------------------------------------------------------------------------------- 1 | ## Blazor UI 2 | -------------------------------------------------------------------------------- /blazor-features/README.md: -------------------------------------------------------------------------------- 1 | ## Blazor Features 2 | -------------------------------------------------------------------------------- /blazor-libraries/README.md: -------------------------------------------------------------------------------- 1 | ## Blazor Libraries 2 | -------------------------------------------------------------------------------- /aspnetcore-webapi/VersioningRestAPI/VersioningRestAPI/libman.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0", 3 | "defaultProvider": "cdnjs", 4 | "libraries": [] 5 | } -------------------------------------------------------------------------------- /csharp-algorithms/MergeSort/MergeSort/Program.cs: -------------------------------------------------------------------------------- 1 | using BenchmarkDotNet.Running; 2 | using MergeSort; 3 | 4 | var summary = BenchmarkRunner.Run(); -------------------------------------------------------------------------------- /csharp-algorithms/BubbleSort/BubbleSort/Program.cs: -------------------------------------------------------------------------------- 1 | using BenchmarkDotNet.Running; 2 | using BubbleSort; 3 | 4 | var summary = BenchmarkRunner.Run(); -------------------------------------------------------------------------------- /collections-csharp/CsharpLists/CsharpLists/Program.cs: -------------------------------------------------------------------------------- 1 | // See https://aka.ms/new-console-template for more information 2 | Console.WriteLine("Hello, World!"); 3 | -------------------------------------------------------------------------------- /csharp-arrays/CompareArrays/BenchmarkRunner/Program.cs: -------------------------------------------------------------------------------- 1 | using BenchmarkRunner; 2 | 3 | BenchmarkDotNet.Running.BenchmarkRunner.Run(); 4 | -------------------------------------------------------------------------------- /csharp-basic-topics/TopLevelStatementsInCSharp/TopLevelStatementsInCSharp/TopLevelProgram.cs: -------------------------------------------------------------------------------- 1 | using KitchenEntities; 2 | 3 | Fridge.ApplianceFunctionality(); 4 | -------------------------------------------------------------------------------- /csharp-algorithms/SelectionSort/SelectionSort/Program.cs: -------------------------------------------------------------------------------- 1 | using BenchmarkDotNet.Running; 2 | using SelectionSort; 3 | 4 | var summary = BenchmarkRunner.Run(); -------------------------------------------------------------------------------- /csharp-arrays/InitializeArrays/InitializeArrays/Program.cs: -------------------------------------------------------------------------------- 1 | // See https://aka.ms/new-console-template for more information 2 | Console.WriteLine("Hello, World!"); 3 | -------------------------------------------------------------------------------- /json-csharp/README.md: -------------------------------------------------------------------------------- 1 | ## JSON manipulation in C# 2 | 3 | This section contains the topics related to JSON manipulation in C#. 4 | ### Relevant articles: 5 | 6 | - TBD 7 | -------------------------------------------------------------------------------- /aspnetcore-webapi/Minimal API/Minimal API/ArticleRequest.cs: -------------------------------------------------------------------------------- 1 | namespace Minimal_API; 2 | 3 | public record ArticleRequest(string? Title, string? Content, DateTime? PublishedAt); -------------------------------------------------------------------------------- /dotnet-datetime/DateTimeOperators/DateTimeOperators/Program.cs: -------------------------------------------------------------------------------- 1 | public class Program 2 | { 3 | static void Main(string[] args) 4 | { 5 | 6 | } 7 | } 8 | 9 | -------------------------------------------------------------------------------- /files-csharp/WriteToCsv/WriteToCsv/Program.cs: -------------------------------------------------------------------------------- 1 | // See https://aka.ms/new-console-template for more information 2 | using WritingCSV; 3 | 4 | WriteMethods.WritePersonsWithDoB(); -------------------------------------------------------------------------------- /csharp-intermediate-topics/CompositionVsInheritance/CompositionVsInheritance/Caravan.cs: -------------------------------------------------------------------------------- 1 | namespace CompositionVsInheritance 2 | { 3 | public class Caravan : House { } 4 | } 5 | -------------------------------------------------------------------------------- /strings-csharp/UsingVariablesInsideStrings/UsingVariablesInsideStrings/Program.cs: -------------------------------------------------------------------------------- 1 | // See https://aka.ms/new-console-template for more information 2 | Console.WriteLine("Hello, World!"); 3 | -------------------------------------------------------------------------------- /aspnetcore-features/README.md: -------------------------------------------------------------------------------- 1 | ## ASP.NET Core Features 2 | 3 | This section contains articles about specific ASP.NET Core Web API features. 4 | 5 | ### Relevant articles: 6 | 7 | - No articles yet 8 | -------------------------------------------------------------------------------- /csharp-basic-topics/InequalityVsIsNotInCSharp/InequalityVsIsNot/Brand.cs: -------------------------------------------------------------------------------- 1 | namespace InequalityVsIsNot 2 | { 3 | public enum Brand 4 | { 5 | Ford = 1, 6 | Toyota = 2 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /csharp-basic-topics/InequalityVsIsNotInCSharp/InequalityVsIsNot/Car.cs: -------------------------------------------------------------------------------- 1 | namespace InequalityVsIsNot 2 | { 3 | public class Car : Vehicle 4 | { 5 | public string? Model { get; set; } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /csharp-basic-topics/WhatsNewInCSharp10/WhatsNewInCSharp10/Usings.cs: -------------------------------------------------------------------------------- 1 | global using System.Diagnostics; 2 | global using System.Runtime.CompilerServices; 3 | global using System.Text; 4 | global using WhatsNewInCSharp10; -------------------------------------------------------------------------------- /json-csharp/JsonSerializationWriteToFile/JsonSerializationWriteToFile.Benchmark/Program.cs: -------------------------------------------------------------------------------- 1 | using BenchmarkDotNet.Running; 2 | using JsonSerializationWriteToFile.Benchmark; 3 | 4 | BenchmarkRunner.Run(); -------------------------------------------------------------------------------- /aspnetcore-webapi/Minimal API/Minimal API/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /csharp-basic-topics/WhatsNewInCSharp10/WhatsNewInCSharp10/CodeMazeArticle.cs: -------------------------------------------------------------------------------- 1 | namespace WhatsNewInCSharp10; 2 | 3 | public record CodeMazeArticle(string Author, string Title, string Comment) : Article(Author, Title); 4 | -------------------------------------------------------------------------------- /aspnetcore-webapi/ASPNETCoreRabbitMQ/Producer/RabbitMQ/IMessageProducer.cs: -------------------------------------------------------------------------------- 1 | namespace Producer.RabbitMQ 2 | { 3 | public interface IMessageProducer 4 | { 5 | void SendMessage (T message); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /aspnetcore-webapi/ASPNETCoreRabbitMQ/Producer/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /aspnetcore-webapi/MassTransitRabbitMQ/Producer/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /dotnet-projects/ProjectTemplates/codemazeapi/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /xml-csharp/README.md: -------------------------------------------------------------------------------- 1 | ## XML manipulation in C# 2 | 3 | This section contains the topics related to XML manipulation in C#. 4 | ### Relevant articles: 5 | 6 | - [Serializing Objects to XML in C#](csharp-xml-serialization) 7 | -------------------------------------------------------------------------------- /aspnetcore-webapi/VersioningRestAPI/VersioningRestAPI/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /csharp-intermediate-topics/RecordsInCSharp/RecordsInCSharpExample/Employee.cs: -------------------------------------------------------------------------------- 1 | namespace RecordsInCSharpExample; 2 | 3 | public record Employee(string FirstName, string LastName, string Job) : Person(FirstName, LastName); 4 | 5 | -------------------------------------------------------------------------------- /numbers-csharp/ParseAndTryParseInCSharp/ParseAndTryParseInCSharp/Program.cs: -------------------------------------------------------------------------------- 1 | namespace ParseAndTryParseInCSharp 2 | { 3 | public class Program 4 | { 5 | public static void Main(string[] args) { } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /threads-csharp/README.md: -------------------------------------------------------------------------------- 1 | ## Threads in C# 2 | 3 | This section contains the topics related to threads in C#. 4 | ### Relevant articles: 5 | 6 | - [How to Run Code in a New Thread in C#](https://code-maze.com/csharp-new-thread/) 7 | -------------------------------------------------------------------------------- /aspnetcore-features/InMemoryCaching/InMemoryCacheExample/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /aspnetcore-webapi/CreatingMultipleResourcesWithPOST/CreatingMultipleResourcesWithPOST/Models/BookModel.cs: -------------------------------------------------------------------------------- 1 | namespace CreatingMultipleResorcesWithPOST.Models 2 | { 3 | public record BookModel(int Id, string Name, string Isbn); 4 | } 5 | -------------------------------------------------------------------------------- /aspnetcore-webapi/CreatingMultipleResourcesWithPOST/CreatingMultipleResourcesWithPOST/Models/MultipleBooksBase.cs: -------------------------------------------------------------------------------- 1 | namespace CreatingMultipleResorcesWithPOST.Models 2 | { 3 | public record MultipleBooksBase(string Status); 4 | } 5 | -------------------------------------------------------------------------------- /aspnetcore-webapi/RateLimitingDemo/RateLimitingDemo.Common/Model/Product.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace RateLimitingDemo.Common.Model; 4 | 5 | public record Product(Guid Id, string Name, int Price, int Rating); 6 | 7 | 8 | -------------------------------------------------------------------------------- /files-csharp/README.md: -------------------------------------------------------------------------------- 1 | ## Working with Files in C# 2 | 3 | This section contains the topics related to files in C#. 4 | ### Relevant articles: 5 | 6 | - [Writing to a CSV File in C#](https://code-maze.com/csharp-writing-csv-file/) 7 | -------------------------------------------------------------------------------- /aspnetcore-webapi/CreatingMultipleResourcesWithPOST/CreatingMultipleResourcesWithPOST/Models/BookRequest.cs: -------------------------------------------------------------------------------- 1 | namespace CreatingMultipleResorcesWithPOST.Models 2 | { 3 | public record BookRequest(string Name, string Isbn); 4 | } 5 | 6 | -------------------------------------------------------------------------------- /aspnetcore-webapi/HealthChecksAspNetCore/HealthChecksAspNetCore/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /aspnetcore-webapi/WorkingWithRestSharp/WorkingWithRestSharp/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /csharp-advanced-topics/EventsInCsharp/EventsInCsharp/Model/Order.cs: -------------------------------------------------------------------------------- 1 | namespace EventsInCsharp.Model 2 | { 3 | public class Order 4 | { 5 | public string Item { get; set; } 6 | public string Ingredients { get; set; } 7 | } 8 | } -------------------------------------------------------------------------------- /csharp-intermediate-topics/CompositionVsInheritance/CompositionVsInheritance/Address.cs: -------------------------------------------------------------------------------- 1 | namespace CompositionVsInheritance 2 | { 3 | public class Address 4 | { 5 | public string GetAddress() => "Address"; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /aspnetcore-webapi/Minimal API/Minimal API/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*" 9 | } 10 | -------------------------------------------------------------------------------- /aspnetcore-webapi/SerializationDemo/SerializationDemo.EmployeeApi/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /csharp-algorithms/README.md: -------------------------------------------------------------------------------- 1 | ## Algorithms in C# 2 | 3 | This section contains source code for the articles about algorithms in C#. 4 | 5 | ### Relevant articles: 6 | 7 | - [Selection Sort in C#](https://code-maze.com/csharp-selection-sort/) 8 | -------------------------------------------------------------------------------- /csharp-intermediate-topics/CompositionVsInheritance/CompositionVsInheritance/Floor.cs: -------------------------------------------------------------------------------- 1 | namespace CompositionVsInheritance 2 | { 3 | public class Floor 4 | { 5 | public string BuildFloor() => "Building a floor..."; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /dotnet-datetime/DateTimeFormatInCSharp/DateTimeFormatInCSharp/Program.cs: -------------------------------------------------------------------------------- 1 | namespace DateTimeFormatInCSharp 2 | { 3 | public class Program 4 | { 5 | public static void Main(string[] args) 6 | { 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /aspnetcore-webapi/MassTransitRabbitMQ/Producer/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*" 9 | } 10 | -------------------------------------------------------------------------------- /aspnetcore-webapi/OptionalParameterinWebApi/OptionalParameterinWebApi/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /aspnetcore-webapi/RateLimitingDemo/RateLimitingDemo.UsingCustomMiddleware/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /csharp-arrays/SliceArrays/SliceArrays/SliceArrays.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /dotnet-projects/ProjectTemplates/codemazeapi/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*" 9 | } 10 | -------------------------------------------------------------------------------- /visual-studio/README.md: -------------------------------------------------------------------------------- 1 | ## Visual Studio Topics 2 | 3 | This section contains the topics related to Visual Studio. 4 | 5 | ### Relevant articles: 6 | 7 | - [Debugging C# in Visual Studio](https://code-maze.com/debugging-csharp-visual-studio/) 8 | -------------------------------------------------------------------------------- /aspnetcore-webapi/VersioningRestAPI/VersioningRestAPI/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*" 9 | } 10 | -------------------------------------------------------------------------------- /csharp-design-patterns/VisitorPattern/VisitorPatternTests/Structural Code Tests/Elements/IVisitableElement.cs: -------------------------------------------------------------------------------- 1 | namespace VisitorPatternTests 2 | { 3 | public interface IVisitableElement 4 | { 5 | void Accept(IVisitor visitor); 6 | } 7 | } -------------------------------------------------------------------------------- /csharp-intermediate-topics/CompositionVsInheritance/CompositionVsInheritance/Ceiling.cs: -------------------------------------------------------------------------------- 1 | namespace CompositionVsInheritance 2 | { 3 | public class Ceiling 4 | { 5 | public string BuildCeiling() => "Building a ceiling..."; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /aspnetcore-webapi/CustomHeadersInASPNETCoreWebAPI/CustomHeadersInASPNETCoreWebAPI/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /aspnetcore-webapi/MandatoryQueryStringParameters/MandatoryQueryStringParameters/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /aspnetcore-webapi/RateLimitingDemo/RateLimitingDemo.UsingAspNetCoreRateLimitPackage/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /authorization-dotnet/UsingAuthorizationWithSwagger/UsingAuthorizationWithSwagger/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /aspnetcore-webapi/CreatingMultipleResourcesWithPOST/CreatingMultipleResourcesWithPOST/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /aspnetcore-webapi/SerializationDemo/SerializationDemo.Client/Clients/ClientBase.cs: -------------------------------------------------------------------------------- 1 | namespace SerializationDemo.Client.Clients 2 | { 3 | internal abstract class ClientBase 4 | { 5 | public string BaseUrl => "https://localhost:7181"; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /aspnetcore-webapi/WorkingWithRestSharp/WorkingWithRestSharp/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*" 9 | } 10 | -------------------------------------------------------------------------------- /dotnet-datetime/CheckDateTimeIsWeekend/CheckDateTime/CheckDateTime.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /aspnetcore-webapi/SerializationDemo/SerializationDemo.EmployeeApi/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*" 9 | } 10 | -------------------------------------------------------------------------------- /csharp-advanced-topics/DelegatesInCsharp/.idea/.idea.DelegatesInCsharp/.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /csharp-design-patterns/ObserverPattern/ObserverPattern/ObserverPattern.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net5.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /dotnet-dependency-injection/DependencyInjectionLifetimeScopes/DependencyInjectionLifetimeScopes/Services/Interfaces/IMyScopedService.cs: -------------------------------------------------------------------------------- 1 | namespace DependencyInjectionLifetimeScopes 2 | { 3 | public interface IMyScopedService : IMyService 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /aspnetcore-webapi/OptionalParameterinWebApi/OptionalParameterinWebApi/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*" 9 | } 10 | -------------------------------------------------------------------------------- /aspnetcore-webapi/RateLimitingDemo/RateLimitingDemo.UsingCustomMiddleware/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*" 9 | } 10 | -------------------------------------------------------------------------------- /collections-csharp/SortedListInCSharp/SortedListInCSharp/SortedListInCSharp.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /csharp-basic-topics/ExpressionBodiedMembersInCsharp/ExpressionBodiedMembersInCsharp/Program.cs: -------------------------------------------------------------------------------- 1 | namespace ExpressionBodiedMembersInCsharp 2 | { 3 | public class Program 4 | { 5 | public static void Main(string[] args) 6 | { 7 | } 8 | } 9 | } -------------------------------------------------------------------------------- /dotnet-client-libraries/README.md: -------------------------------------------------------------------------------- 1 | ## .NET Client Libraries 2 | 3 | This section contains the topics about the client libraries in .NET. 4 | 5 | ### Relevant articles: 6 | 7 | - [Google Sheets API with .NET Core](https://code-maze.com/google-sheets-api-with-net-core/) 8 | -------------------------------------------------------------------------------- /dotnet-dependency-injection/DependencyInjectionLifetimeScopes/DependencyInjectionLifetimeScopes/Services/Interfaces/IMySingletonService.cs: -------------------------------------------------------------------------------- 1 | namespace DependencyInjectionLifetimeScopes 2 | { 3 | public interface IMySingletonService : IMyService 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /dotnet-dependency-injection/DependencyInjectionLifetimeScopes/DependencyInjectionLifetimeScopes/Services/Interfaces/IMyTransientService .cs: -------------------------------------------------------------------------------- 1 | namespace DependencyInjectionLifetimeScopes 2 | { 3 | public interface IMyTransientService : IMyService 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /json-csharp/JsonSerializationOfEnumAsString/JsonSerialization.Native.EnumAsString.WebApi/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /aspnetcore-webapi/RateLimitingDemo/RateLimitingDemo.Common/RateLimitingDemo.Common.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /csharp-basic-topics/TypesOfInheritanceInCSharp/TypesOfInheritanceInCSharp/ILaptop.cs: -------------------------------------------------------------------------------- 1 | namespace TypesOfInheritanceInCSharp; 2 | 3 | public interface ILaptop 4 | { 5 | public int UsbPortNumbers { get; set; } 6 | 7 | public void WriteWithKeyboard(string message); 8 | } 9 | -------------------------------------------------------------------------------- /dependency-injection-tools/AutoFacImplementationWeb/AutoFacImplementationWeb/Interface/IStringBusiness.cs: -------------------------------------------------------------------------------- 1 | namespace AutoFacImplementationWeb.Interface 2 | { 3 | public interface IStringBusiness 4 | { 5 | string StringToUpper(string personName); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /dotnet-projects/ProjectTemplates/Test/CustomWebApplicationFactory.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc.Testing; 2 | 3 | namespace codemazeapi.Controllers 4 | { 5 | public class CustomWebApplicationFactory : WebApplicationFactory 6 | { 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /json-csharp/JsonSerializationOfEnumAsString/JsonSerialization.Native.EnumAsString.MinimalApi/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /json-csharp/JsonSerializationOfEnumAsString/JsonSerialization.Newtonsoft.EnumAsString.WebApi/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /strings-csharp/AddParametersToString/AddParametersToString/AddParametersToString.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net5.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /aspnetcore-webapi/CreatingMultipleResourcesWithPOST/CreatingMultipleResourcesWithPOST/Models/MultipleBooksModel.cs: -------------------------------------------------------------------------------- 1 | namespace CreatingMultipleResorcesWithPOST.Models 2 | { 3 | public record MultipleBooksModel(string Status, BookModel Message) : MultipleBooksBase(Status); 4 | } 5 | -------------------------------------------------------------------------------- /aspnetcore-webapi/CustomHeadersInASPNETCoreWebAPI/CustomHeadersInASPNETCoreWebAPI/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*" 9 | } 10 | -------------------------------------------------------------------------------- /aspnetcore-webapi/MandatoryQueryStringParameters/MandatoryQueryStringParameters/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*" 9 | } 10 | -------------------------------------------------------------------------------- /csharp-advanced-topics/DelegatesInCsharp/DelegatesInCsharp/DelegatesInCsharp.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net5.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /csharp-advanced-topics/EventsInCsharp/EventsInCsharp/EventsInCsharp.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /dotnet-dependency-injection/DependencyInjectionLifetimeScopes/DependencyInjectionLifetimeScopes/Services/Interfaces/IMyService.cs: -------------------------------------------------------------------------------- 1 | namespace DependencyInjectionLifetimeScopes 2 | { 3 | public interface IMyService 4 | { 5 | string InstanceId { get; } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /json-csharp/DeserializeComplexJsonObject/DeserializeComplexJSONObject/POCO/Cofounder.cs: -------------------------------------------------------------------------------- 1 | namespace DeserializeComplexJSONObject.POCO 2 | { 3 | public class Cofounder 4 | { 5 | public string? Id { get; set; } 6 | public string? Name { get; set; } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /strings-csharp/ConvertStringToBoolean/ConvertStringToBoolean/ConvertStringToBoolean.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net5.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /visual-studio/DebuggingBasicsInCSharp/DebuggingBasicsInCSharp/DebuggingBasicsInCSharp.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /xml-csharp/XMLSerializationInCsharp/XMLSerializationInCsharp/XMLSerializationInCsharp.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net5.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /aspnetcore-webapi/CreatingMultipleResourcesWithPOST/CreatingMultipleResourcesWithPOST/Models/MultipleBooksErrorModel.cs: -------------------------------------------------------------------------------- 1 | namespace CreatingMultipleResorcesWithPOST.Models 2 | { 3 | public record MultipleBooksErrorModel(string Status, string Message): MultipleBooksBase(Status); 4 | } 5 | -------------------------------------------------------------------------------- /aspnetcore-webapi/CreatingMultipleResourcesWithPOST/CreatingMultipleResourcesWithPOST/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*" 9 | } 10 | -------------------------------------------------------------------------------- /aspnetcore-webapi/WorkingWithRestSharp/WorkingWithRestSharp/DataTransferObject/Support.cs: -------------------------------------------------------------------------------- 1 | namespace WorkingWithRestSharp.DataTransferObject 2 | { 3 | public class Support 4 | { 5 | public string Url { get; set; } 6 | public string Text { get; set; } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /collections-csharp/HowToDetectIfADictionaryKeyExistsInCsharp/Test/HowToDetectIfADictionaryKeyExistsInCsharpUnitTest.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nirzaf/CodeMazeGuides/HEAD/collections-csharp/HowToDetectIfADictionaryKeyExistsInCsharp/Test/HowToDetectIfADictionaryKeyExistsInCsharpUnitTest.cs -------------------------------------------------------------------------------- /csharp-advanced-topics/DelegatesInCsharp/.idea/.idea.DelegatesInCsharp/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /csharp-advanced-topics/README.md: -------------------------------------------------------------------------------- 1 | ## Advanced Topics in C# 2 | 3 | This section contains the topics considered advanced level in C#. 4 | 5 | ### Relevant articles: 6 | 7 | - [C# Delegates](https://code-maze.com/delegates-charp/) 8 | - [Events in C#](https://code-maze.com/csharp-events/) 9 | -------------------------------------------------------------------------------- /csharp-intermediate-topics/PolymorphismInCsharp/PolymorphismInCsharp/PolymorphismInCsharp.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net5.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /dotnet-client-libraries/Google Sheets API/GoogleSheetsAPI/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /json-csharp/DeserializeComplexJsonObject/DeserializeComplexJSONObject/POCO/Position.cs: -------------------------------------------------------------------------------- 1 | namespace DeserializeComplexJSONObject.POCO 2 | { 3 | public class Position 4 | { 5 | public string? Id { get; set; } 6 | public string? Description { get; set; } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /numbers-csharp/ParseAndTryParseInCSharp/ParseAndTryParseInCSharp/ParseAndTryParseInCSharp.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /authorization-dotnet/README.md: -------------------------------------------------------------------------------- 1 | ## Authorization in .NET 2 | 3 | This section contains articles about authorization related topics in .NET. 4 | 5 | ### Relevant articles: 6 | 7 | - [Using Authorization with Swagger in ASP.NET Core](https://code-maze.com/swagger-authorization-aspnet-core/) 8 | -------------------------------------------------------------------------------- /csharp-arrays/SumUpArrayElements/BenchmarkRunner/Program.cs: -------------------------------------------------------------------------------- 1 | namespace BenchmarkRunner; 2 | 3 | public class Program 4 | { 5 | public static void Main(string[] args) 6 | { 7 | BenchmarkDotNet.Running.BenchmarkRunner.Run(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /csharp-basic-topics/WhatsNewInCSharp10/WhatsNewInCSharp10/Article.cs: -------------------------------------------------------------------------------- 1 | namespace WhatsNewInCSharp10; 2 | 3 | public record Article(string Author, string Title) 4 | { 5 | public sealed override string ToString() 6 | { 7 | return $"{Author}: {Title}"; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dotnet-logging/README.md: -------------------------------------------------------------------------------- 1 | ## Logging in .NET 2 | 3 | This section contains the topics related to logging and logging tools in .NET. 4 | ### Relevant articles: 5 | 6 | - [ILogger, ILoggerFactory, and ILoggerProvider in .NET](https://code-maze.com/dotnet-ilogger-iloggerfactory-iloggerprovider/) 7 | -------------------------------------------------------------------------------- /json-csharp/JsonSerializationOfEnumAsString/JsonSerialization.EnumAsString.Models/TextStyles.cs: -------------------------------------------------------------------------------- 1 | namespace JsonSerialization.EnumAsString.Models; 2 | 3 | [Flags] 4 | public enum TextStyles 5 | { 6 | None = 0, 7 | Bold = 1, 8 | Italic = 2, 9 | Underline = 4, 10 | } -------------------------------------------------------------------------------- /csharp-design-patterns/VisitorPattern/VisitorPatternTests/Structural Code Tests/Visitors/IVisitor.cs: -------------------------------------------------------------------------------- 1 | namespace VisitorPatternTests 2 | { 3 | public interface IVisitor 4 | { 5 | void Visit(ConcreteElementOne element); 6 | void Visit(ConcreteElementTwo element); 7 | } 8 | } -------------------------------------------------------------------------------- /csharp-intermediate-topics/CompositionVsInheritance/CompositionVsInheritance/CompositionVsInheritance.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /json-csharp/JsonSerializationOfEnumAsString/JsonSerialization.Native.EnumAsString.WebApi/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*" 9 | } 10 | -------------------------------------------------------------------------------- /aspnetcore-webapi/WorkingWithRestSharp/WorkingWithRestSharp/DataTransferObject/UserDetails.cs: -------------------------------------------------------------------------------- 1 | namespace WorkingWithRestSharp.DataTransferObject 2 | { 3 | public class UserDetails 4 | { 5 | public UserData Data { get; set; } 6 | public Support Support { get; set; } 7 | } 8 | 9 | } -------------------------------------------------------------------------------- /aspnetcore-webapi/WorkingWithRestSharp/WorkingWithRestSharp/DataTransferObject/UserForUpdate.cs: -------------------------------------------------------------------------------- 1 | namespace WorkingWithRestSharp.DataTransferObject 2 | { 3 | public class UserForUpdate 4 | { 5 | public string Name { get; set; } 6 | public string Job { get; set; } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /dotnet-client-libraries/Google Sheets API/GoogleSheetsAPI/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "AllowedHosts": "*" 10 | } 11 | -------------------------------------------------------------------------------- /json-csharp/JsonSerializationOfEnumAsString/JsonSerialization.Native.EnumAsString.MinimalApi/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*" 9 | } 10 | -------------------------------------------------------------------------------- /json-csharp/JsonSerializationOfEnumAsString/JsonSerialization.Newtonsoft.EnumAsString.WebApi/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*" 9 | } 10 | -------------------------------------------------------------------------------- /aspnetcore-features/InMemoryCaching/InMemoryCacheExample/Models/Repository/IDataRepository.cs: -------------------------------------------------------------------------------- 1 | namespace InMemoryCacheExample.Models.Repository 2 | { 3 | public interface IDataRepository 4 | { 5 | IEnumerable GetAll(); 6 | void Add(TEntity entity); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /aspnetcore-webapi/MassTransitRabbitMQ/Producer/OrderDto.cs: -------------------------------------------------------------------------------- 1 | namespace Producer 2 | { 3 | public class OrderDto 4 | { 5 | public string ProductName { get; set; } 6 | 7 | public decimal Price { get; set; } 8 | 9 | public int Quantity { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /aspnetcore-webapi/WorkingWithRestSharp/WorkingWithRestSharp/DataTransferObject/UserForCreation.cs: -------------------------------------------------------------------------------- 1 | namespace WorkingWithRestSharp.DataTransferObject 2 | { 3 | public class UserForCreation 4 | { 5 | public string Name { get; set; } 6 | public string Job { get; set; } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /csharp-design-patterns/VisitorPattern/TeamA.TestResults/ExtensibilityContract/AlertReport.cs: -------------------------------------------------------------------------------- 1 | namespace TeamA.TestResults.ExtensibilityContract 2 | { 3 | public enum AlertReport 4 | { 5 | NotAnalyzable = -1, 6 | LowRisk = 0, 7 | HighRisk = 1 8 | } 9 | 10 | 11 | } -------------------------------------------------------------------------------- /dependency-injection-tools/AutoFacImplementationWeb/AutoFacImplementationWeb/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dotnet-testing/NUnitProject/NUnitProject/NUnitProject.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /aspnetcore-webapi/Minimal API/Minimal API/Article.cs: -------------------------------------------------------------------------------- 1 | namespace Minimal_API; 2 | 3 | public class Article 4 | { 5 | public int Id { get; set; } 6 | 7 | public string? Title { get; set; } 8 | 9 | public string? Content { get; set; } 10 | 11 | public DateTime? PublishedAt { get; set; } 12 | } -------------------------------------------------------------------------------- /dependency-injection-tools/README.md: -------------------------------------------------------------------------------- 1 | ## Dependency Injection Tools in .NET 2 | 3 | This section contains the topics about the third-party Dependency Injection Tools available in .NET. 4 | 5 | ### Relevant articles: 6 | 7 | - [Using Autofac in a .NET (Core) Project](https://code-maze.com/using-autofac-dotnet/) 8 | -------------------------------------------------------------------------------- /aspnetcore-webapi/ASPNETCoreRabbitMQ/Producer/Data/IOrderDbContext.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | 3 | namespace Producer.Data 4 | { 5 | public interface IOrderDbContext 6 | { 7 | DbSet Order { get; set; } 8 | 9 | Task SaveChangesAsync(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /aspnetcore-webapi/ASPNETCoreRabbitMQ/Producer/Dtos/OrderDto.cs: -------------------------------------------------------------------------------- 1 | namespace Producer.Dtos 2 | { 3 | public class OrderDto 4 | { 5 | public string ProductName { get; set; } 6 | 7 | public decimal Price { get; set; } 8 | 9 | public int Quantity { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /aspnetcore-webapi/CustomHeadersInASPNETCoreWebAPI/ClientApplication/client-custom-header.js: -------------------------------------------------------------------------------- 1 | fetch('https://localhost:7026/api/custom-headers/middleware') 2 | .then(response => { 3 | response.headers.forEach(function(value,name) { 4 | console.log(name + ": " + value); 5 | }); 6 | }) -------------------------------------------------------------------------------- /aspnetcore-webapi/MassTransitRabbitMQ/SharedModels/SharedModels.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /authorization-dotnet/UsingAuthorizationWithSwagger/UsingAuthorizationWithSwagger/Models/Product.cs: -------------------------------------------------------------------------------- 1 | namespace UsingAuthorizationWithSwagger.Models 2 | { 3 | public class Product 4 | { 5 | public int Id { get; set; } 6 | public string? Name { get; set; } 7 | 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /collections-csharp/SortedListInCSharp/SortedListInCSharp/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SortedListInCSharp 4 | { 5 | class Program 6 | { 7 | static void Main(string[] args) 8 | { 9 | Console.WriteLine("Hello World!"); 10 | } 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /csharp-basic-topics/TopLevelStatementsInCSharp/TopLevelStatementsInCSharp/OldStyleProgram.cs: -------------------------------------------------------------------------------- 1 | namespace KitchenEntities 2 | { 3 | public class Program 4 | { 5 | public static void Main(string[] args) 6 | { 7 | Fridge.ApplianceFunctionality(); 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /dotnet-dependency-injection/README.md: -------------------------------------------------------------------------------- 1 | ## Dependency Injection in .NET 2 | 3 | This section contains the topics related to dependency injection mechanisms in .NET. 4 | ### Relevant articles: 5 | 6 | - [Dependency Injection Lifetimes in ASP.NET Core](https://code-maze.com/dependency-injection-lifetimes-aspnet-core/) 7 | -------------------------------------------------------------------------------- /aspnetcore-webapi/ASPNETCoreRabbitMQ/Subscriber/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "WSL": { 4 | "commandName": "WSL2", 5 | "environmentVariables": {}, 6 | "distributionName": "" 7 | }, 8 | "Subscriber": { 9 | "commandName": "Project" 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /aspnetcore-webapi/SerializationDemo/SerializationDemo.Client/Serialization/IByteSerializer.cs: -------------------------------------------------------------------------------- 1 | namespace SerializationDemo.Client.Serialization 2 | { 3 | internal interface IByteSerializer 4 | { 5 | T Deserialize(byte[] buffer); 6 | 7 | byte[] Serialize(object data); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /aspnetcore-webapi/WorkingWithRestSharp/WorkingWithRestSharp/DataTransferObject/UserList.cs: -------------------------------------------------------------------------------- 1 | namespace WorkingWithRestSharp.DataTransferObject 2 | { 3 | public class UserList : PagingInformation 4 | { 5 | public List Data { get; set; } 6 | public Support Support { get; set; } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /csharp-arrays/PopulateArrayWithTheSameValue/BenchmarkRunner/Program.cs: -------------------------------------------------------------------------------- 1 | namespace BenchmarkRunner 2 | { 3 | internal class Program 4 | { 5 | static void Main(string[] args) 6 | { 7 | BenchmarkDotNet.Running.BenchmarkRunner.Run(); 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /csharp-basic-topics/BreakAndContinueStatementsInCsharp/BreakAndContinueStatementsInCsharp/BreakAndContinueStatementsInCsharp.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /dependency-injection-tools/AutoFacImplementationWeb/AutoFacImplementationWeb/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "AllowedHosts": "*" 10 | } 11 | -------------------------------------------------------------------------------- /xml-csharp/XMLSerializationInCsharp/XMLSerializationInCsharp/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace XMLSerializationInCsharp 4 | { 5 | 6 | class Program 7 | { 8 | static void Main(string[] args) 9 | { 10 | Console.Write("hello world"); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /aspnetcore-webapi/SerializationDemo/SerializationDemo.Client/Serialization/IStringSerializer.cs: -------------------------------------------------------------------------------- 1 | namespace SerializationDemo.Client.Serialization 2 | { 3 | internal interface IStringSerializer 4 | { 5 | T Deserialize(string text); 6 | 7 | string Serialize(object data); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /authorization-dotnet/UsingAuthorizationWithSwagger/UsingAuthorizationWithSwagger/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "AllowedHosts": "*" 10 | 11 | } -------------------------------------------------------------------------------- /csharp-basic-topics/TopLevelStatementsInCSharp/TopLevelStatementsInCSharp/Fridge.cs: -------------------------------------------------------------------------------- 1 | namespace KitchenEntities 2 | { 3 | public static class Fridge 4 | { 5 | public static void ApplianceFunctionality() 6 | { 7 | Console.WriteLine("I freeze your food!"); 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /csharp-design-patterns/VisitorPattern/TeamA.TestResults/ExtensibilityContract/ISicknessAlertVisitable.cs: -------------------------------------------------------------------------------- 1 | using TeamA.TestResults.ExtensibilityContract; 2 | 3 | namespace TeamA.TestResults 4 | { 5 | public interface ISicknessAlertVisitable 6 | { 7 | AlertReport Accept(ISicknessAlertVisitor visitor); 8 | } 9 | } -------------------------------------------------------------------------------- /csharp-design-patterns/VisitorPattern/TeamA.TestResults/TeamA.TestResults.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /dependency-injection-tools/AutoFacImplementationWeb/AutoFacImplementationWeb/Interface/IPersonBusiness.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace AutoFacImplementationWeb.Interface 4 | { 5 | public interface IPersonBusiness 6 | { 7 | public List GetPersonList(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dotnet-dependency-injection/DependencyInjectionLifetimeScopes/DependencyInjectionLifetimeScopes/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dotnet-client-libraries/Google Sheets API/GoogleSheetsAPITest/CustomWebApplicationFactory.cs: -------------------------------------------------------------------------------- 1 | using GoogleSheetsAPI; 2 | using Microsoft.AspNetCore.Mvc.Testing; 3 | 4 | namespace GoogleSheetsAPITest 5 | { 6 | public class CustomWebApplicationFactory : WebApplicationFactory 7 | { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /json-csharp/DeserializeComplexJsonObject/BenchmarkRunner/Program.cs: -------------------------------------------------------------------------------- 1 | namespace BenchmarkRunner 2 | { 3 | public class Program 4 | { 5 | public static void Main(string[] args) 6 | { 7 | BenchmarkDotNet.Running.BenchmarkRunner.Run(); 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /aspnetcore-webapi/OptionalParameterinWebApi/OptionalParameterinWebApi/Product.cs: -------------------------------------------------------------------------------- 1 | namespace OptionalParameterinWebApi 2 | { 3 | 4 | public class Product 5 | { 6 | public int Id { get; set; } 7 | public string? Name { get; set; } 8 | 9 | public string? Price { get; set; } 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /aspnetcore-webapi/OptionalParameterinWebApi/Test/WeatherForecastControllerTest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Test 8 | { 9 | internal class WeatherForecastControllerTest 10 | { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /aspnetcore-webapi/MassTransitRabbitMQ/SharedModels/OrderCreated.cs: -------------------------------------------------------------------------------- 1 | namespace SharedModels 2 | { 3 | public interface OrderCreated 4 | { 5 | int Id { get; set; } 6 | 7 | string ProductName { get; set; } 8 | 9 | decimal Price { get; set; } 10 | 11 | int Quantity { get; set; } 12 | } 13 | } -------------------------------------------------------------------------------- /collections-csharp/HowToDetectIfADictionaryKeyExistsInCsharp/HowToDetectIfADictionaryKeyExistsInCsharp/HowToDetectIfADictionaryKeyExistsInCsharp.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /csharp-arrays/CopyArrayElements/BenchmarkRunner/Program.cs: -------------------------------------------------------------------------------- 1 | using BenchmarkRunner; 2 | 3 | namespace BenchmarkRunner 4 | { 5 | public class Program 6 | { 7 | static void Main(string[] args) 8 | { 9 | BenchmarkDotNet.Running.BenchmarkRunner.Run(); 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /dotnet-client-libraries/Google Sheets API/GoogleSheetsAPI/Item.cs: -------------------------------------------------------------------------------- 1 | namespace GoogleSheetsAPI 2 | { 3 | public class Item 4 | { 5 | public string Id { get; set; } 6 | public string Name { get; set; } 7 | public string Category { get; set; } 8 | public string Price { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /dotnet-dependency-injection/DependencyInjectionLifetimeScopes/DependencyInjectionLifetimeScopes/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "AllowedHosts": "*" 10 | } 11 | -------------------------------------------------------------------------------- /strings-csharp/StringBuilderType/BenchmarkRunner/Program.cs: -------------------------------------------------------------------------------- 1 | using BenchmarkRunner; 2 | 3 | namespace BenchmarkRunner 4 | { 5 | public class Program 6 | { 7 | static void Main(string[] args) 8 | { 9 | BenchmarkDotNet.Running.BenchmarkRunner.Run(); 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /collections-csharp/CsharpLists/CsharpLists/CsharpLists.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /csharp-arrays/CompareArrays/CompareArrays/CompareArrays.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /csharp-arrays/FindTheMaximumValue/BenchmarkRunner/Program.cs: -------------------------------------------------------------------------------- 1 | using FindTheMaximumValue; 2 | 3 | namespace BenchmarkRunner 4 | { 5 | public class Program 6 | { 7 | static void Main(string[] args) 8 | { 9 | BenchmarkDotNet.Running.BenchmarkRunner.Run(); 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /csharp-design-patterns/VisitorPattern/TeamA.TestResults/Results/BloodSample.cs: -------------------------------------------------------------------------------- 1 | using TeamA.TestResults.ExtensibilityContract; 2 | 3 | namespace TeamA.TestResults.Results 4 | { 5 | public class BloodSample : ISicknessAlertVisitable 6 | { 7 | public AlertReport Accept(ISicknessAlertVisitor visitor) => visitor.Visit(this); 8 | } 9 | } -------------------------------------------------------------------------------- /csharp-design-patterns/VisitorPattern/TeamA.TestResults/Results/EcgReading.cs: -------------------------------------------------------------------------------- 1 | using TeamA.TestResults.ExtensibilityContract; 2 | 3 | namespace TeamA.TestResults.Results 4 | { 5 | public class EcgReading : ISicknessAlertVisitable 6 | { 7 | public AlertReport Accept(ISicknessAlertVisitor visitor) => visitor.Visit(this); 8 | } 9 | } -------------------------------------------------------------------------------- /csharp-design-patterns/VisitorPattern/TeamA.TestResults/Results/XRayImage.cs: -------------------------------------------------------------------------------- 1 | using TeamA.TestResults.ExtensibilityContract; 2 | 3 | namespace TeamA.TestResults.Results 4 | { 5 | public class XRayImage : ISicknessAlertVisitable 6 | { 7 | public AlertReport Accept(ISicknessAlertVisitor visitor) => visitor.Visit(this); 8 | } 9 | } -------------------------------------------------------------------------------- /json-csharp/DeserializeComplexJsonObject/DeserializeComplexJSONObject/POCO/Benefit.cs: -------------------------------------------------------------------------------- 1 | namespace DeserializeComplexJSONObject.POCO 2 | { 3 | public class Benefit 4 | { 5 | public string? Id { get; set; } 6 | public int Additional { get; set; } 7 | public string? Description { get; set; } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /numbers-csharp/MathInCSharp/MathInCSharp/MathInCSharp.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /aspnetcore-webapi/Minimal API/Minimal API/ApiContext.cs: -------------------------------------------------------------------------------- 1 | namespace Minimal_API; 2 | 3 | using Microsoft.EntityFrameworkCore; 4 | 5 | public class ApiContext : DbContext 6 | { 7 | public DbSet
Articles { get; set; } 8 | 9 | public ApiContext(DbContextOptions options) 10 | : base(options) 11 | { } 12 | } -------------------------------------------------------------------------------- /authorization-dotnet/UsingAuthorizationWithSwagger/Test/Helpers/Token.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Test.Helpers 8 | { 9 | public class Tokeen 10 | { 11 | public string Token { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /csharp-advanced-topics/QueueInCSharp/QueueInCSharp/QueueInCSharp.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /csharp-arrays/InitializeArrays/InitializeArrays/InitializeArrays.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /csharp-design-patterns/VisitorPattern/VisitorPatternTests/Structural Code Tests/Elements/ConcreteElementTwo.cs: -------------------------------------------------------------------------------- 1 | namespace VisitorPatternTests 2 | { 3 | public class ConcreteElementTwo : IVisitableElement 4 | { 5 | public int ElementTwoData { get; } = 42; 6 | 7 | public void Accept(IVisitor visitor) => visitor.Visit(this); 8 | } 9 | } -------------------------------------------------------------------------------- /files-csharp/ByteArrayToFile/ByteArrayToFile/ByteArrayToFile.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Library 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /aspnetcore-features/CustomAttributes/CustomAttributes/CustomAttributes.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /aspnetcore-features/CustomAttributes/CustomAttributes/Enums.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace CustomAttributes 8 | { 9 | public enum Priorities 10 | { 11 | High, 12 | Mid, 13 | Low 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /aspnetcore-webapi/SerializationDemo/SerializationDemo.Client/Clients/IClient.cs: -------------------------------------------------------------------------------- 1 | using SerializationDemo.Common.Models; 2 | 3 | namespace SerializationDemo.Client.Clients 4 | { 5 | internal interface IClient 6 | { 7 | Task> GetAllEmployees(); 8 | Task CreateEmployee(Employee employee); 9 | } 10 | } -------------------------------------------------------------------------------- /aspnetcore-webapi/VersioningRestAPI/VersioningRestAPI/Data.cs: -------------------------------------------------------------------------------- 1 | namespace VersioningRestAPI 2 | { 3 | public class Data 4 | { 5 | public static readonly string[] Summaries = new[] 6 | { 7 | "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" 8 | }; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /csharp-arrays/SumUpArrayElements/SumUpArrayElements/SumUpArrayElements.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /csharp-intermediate-topics/StaticClasses/StaticClasses/StaticClasses.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /csharp-intermediate-topics/TuplesInCsharp/TuplesInCsharp/TuplesInCsharp.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /dotnet-datetime/DateTimeOperators/DateTimeOperators/DateTimeOperators.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /dotnet-testing/NUnitProject/NUnitProject/Calculator.cs: -------------------------------------------------------------------------------- 1 | namespace NUnitProject 2 | { 3 | public class Calculator 4 | { 5 | public int Sum(int a, int b) 6 | { 7 | return a + b; 8 | } 9 | 10 | public double Divide(int a , int b) 11 | { 12 | return a / b; 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /numbers-csharp/ConvertString2Int/ConvertString2Int/ConvertString2Int.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /strings-csharp/ConvertInt2String/ConvertInt2String/ConvertInt2String.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /strings-csharp/StringBuilderType/StringBuilderType/StringBuilderType.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /aspnetcore-webapi/MandatoryQueryStringParameters/MandatoryQueryStringParameters/MandatoryQueryStringParameters.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /csharp-basic-topics/WhatsNewInCSharp10/WhatsNewInCSharp10/WhatsNewInCSharp10.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /csharp-design-patterns/README.md: -------------------------------------------------------------------------------- 1 | ## Design Patterns in C# 2 | 3 | This section contains articles about popular and useful Design Patterns in C# 4 | 5 | ### Relevant articles: 6 | 7 | - [Observer Design Pattern in C#](https://code-maze.com/csharp-observer-design-pattern/) 8 | - [Visitor Design Pattern in C#](https://code-maze.com/csharp-visitor-design-pattern/) 9 | -------------------------------------------------------------------------------- /aspnetcore-webapi/CustomHeadersInASPNETCoreWebAPI/CustomHeadersInASPNETCoreWebAPI/CustomHeadersInASPNETCoreWebAPI.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /aspnetcore-webapi/RateLimitingDemo/RateLimitingDemo.UsingCustomMiddleware/Decorators/LimitRequests.cs: -------------------------------------------------------------------------------- 1 | namespace RateLimitingDemo.UsingCustomMiddleware.Decorators; 2 | 3 | [AttributeUsage(AttributeTargets.Method)] 4 | public class LimitRequests : Attribute 5 | { 6 | public int TimeWindow { get; set; } 7 | public int MaxRequests { get; set; } 8 | } 9 | 10 | -------------------------------------------------------------------------------- /aspnetcore-webapi/SerializationDemo/SerializationDemo.EmployeeApi/Repositories/IEmployeeRepository.cs: -------------------------------------------------------------------------------- 1 | using SerializationDemo.Common.Models; 2 | 3 | namespace SerializationDemo.EmployeeApi.Repositories 4 | { 5 | public interface IEmployeeRepository 6 | { 7 | void Create(Employee employee); 8 | List GetAll(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /aspnetcore-webapi/WorkingWithRestSharp/WorkingWithRestSharp/DataTransferObject/UserUpdateResponse.cs: -------------------------------------------------------------------------------- 1 | namespace WorkingWithRestSharp.DataTransferObject 2 | { 3 | public class UserUpdateResponse 4 | { 5 | public string Name { get; set; } 6 | public string Job { get; set; } 7 | public string UpdatedAt { get; set; } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /csharp-basic-topics/InequalityVsIsNotInCSharp/InequalityVsIsNot/InequalityVsIsNot.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /dotnet-dependency-injection/DependencyInjectionLifetimeScopes/Test/CustomWebApplicationFactory.cs: -------------------------------------------------------------------------------- 1 | using DependencyInjectionLifetimeScopes; 2 | using Microsoft.AspNetCore.Mvc.Testing; 3 | 4 | namespace DependencyInjectionLifetimeScopesTest 5 | { 6 | public class CustomWebApplicationFactory : WebApplicationFactory 7 | { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /numbers-csharp/GenerateRandomDoubles/GenerateRandomDoubles/GenerateRandomDoubles.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /numbers-csharp/GenerateRandomNumbers/GenerateRandomNumbers/GenerateRandomNumbers.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /aspnetcore-features/InMemoryCaching/InMemoryCacheExample/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "ConnectionString": { 9 | "EmployeeDB": "Server=.;Initial Catalog=EmployeeDB;Integrated Security=true;" 10 | }, 11 | "AllowedHosts": "*" 12 | } -------------------------------------------------------------------------------- /collections-csharp/HowToDetectIfADictionaryKeyExistsInCsharp/HowToDetectIfADictionaryKeyExistsInCsharp/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace HowToDetectIfADictionaryKeyExistsInCsharp 4 | { 5 | class Program 6 | { 7 | static void Main(string[] args) 8 | { 9 | Console.WriteLine("Hello World!"); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /csharp-intermediate-topics/OperatorOverloading/OperatorOverloading/OperatorOverloading.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /dotnet-datetime/DateTimeFormatInCSharp/DateTimeFormatInCSharp/DateTimeFormatInCSharp.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /numbers-csharp/IntParseVsConvertToInt/IntParseVsConvertToInt/IntParseVsConvertToInt.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /strings-csharp/ConvertCharArray2String/ConvertCharArray2String/ConvertCharArray2String.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /strings-csharp/StringBuilderCheckEmpty/StringBuilderCheckEmpty/StringBuilderCheckEmpty.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /collections-csharp/IterateThroughDictionary/BenchmarkRunner/ProgramBenchmark.cs: -------------------------------------------------------------------------------- 1 | namespace ProgramBenchmarkRunner 2 | { 3 | public class ProgramBenchmark 4 | { 5 | static void Main(string[] args) 6 | { 7 | BenchmarkDotNet.Running.BenchmarkRunner.Run(); 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /csharp-intermediate-topics/RecordsInCSharp/RecordsInCSharpExample/RecordsInCSharpExample.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /dotnet-datetime/GetDatePartFromDateTime/GetDatePartFromDateTime/GetDatePartFromDateTime.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /exception-handling/CatchMultipleExceptions/CatchMultipleExceptions/CatchMultipleExceptions.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /json-csharp/JsonSerializationOfEnumAsString/JsonSerialization.EnumAsString.Models/JsonSerialization.EnumAsString.Models.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /collections-csharp/DictionaryGetValueByIndex/DictionaryGetValueByIndex/DictionaryGetValueByIndex.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /csharp-basic-topics/AsAndIsOperatorsInCSharp/AsAndIsOperatorsInCSharp/AsAndIsOperatorsInCSharp.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /csharp-basic-topics/SwitchCaseExpressions/SwitchCaseExpressions/SwitchCaseExpressions.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /exception-handling/README.md: -------------------------------------------------------------------------------- 1 | ## Exception Handling in C# 2 | 3 | This section contains the topics related to handling exceptions in C# 4 | ### Relevant articles: 5 | 6 | - [Difference Between “throw” vs “throw ex” in C#](https://code-maze.com/difference-between-throw-vs-throwex-csharp/) 7 | - [Catch Multiple Exceptions in C#](https://code-maze.com/csharp-catch-multiple-exceptions/) 8 | -------------------------------------------------------------------------------- /aspnetcore-webapi/CreatingMultipleResourcesWithPOST/CreatingMultipleResourcesWithPOST/Services/IBookService.cs: -------------------------------------------------------------------------------- 1 | using CreatingMultipleResorcesWithPOST.Models; 2 | 3 | namespace CreatingMultipleResorcesWithPOST.Services 4 | { 5 | public interface IBookService 6 | { 7 | IEnumerable CreateBooks(IEnumerable bookRequests); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /aspnetcore-webapi/MandatoryQueryStringParameters/MandatoryQueryStringParameters/QueryParameters.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc.ModelBinding; 2 | 3 | namespace MandatoryQueryStringParameters 4 | { 5 | public class QueryParameters 6 | { 7 | public int Id { get; set; } 8 | 9 | [BindRequired] 10 | public int Number { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /aspnetcore-webapi/RateLimitingDemo/RateLimitingDemo.Common/Repositories/IProductCatalogRepository.cs: -------------------------------------------------------------------------------- 1 | using RateLimitingDemo.Common.Model; 2 | using System; 3 | using System.Collections.Generic; 4 | 5 | namespace RateLimitingDemo.Common.Repositories; 6 | 7 | public interface IProductCatalogRepository 8 | { 9 | Product GetById(Guid id); 10 | List GetAll(); 11 | } 12 | -------------------------------------------------------------------------------- /csharp-advanced-topics/EventsInCsharp/EventsInCsharp/EventArguments/FoodPreparedEventArgs.cs: -------------------------------------------------------------------------------- 1 | using EventsInCsharp.Model; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace EventsInCsharp.EventArguments 7 | { 8 | public class FoodPreparedEventArgs : EventArgs 9 | { 10 | public Order Order { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /csharp-basic-topics/TopLevelStatementsInCSharp/TopLevelStatementsInCSharp/TopLevelStatementsInCSharp.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /csharp-basic-topics/TypesOfInheritanceInCSharp/TypesOfInheritanceInCSharp/TypesOfInheritanceInCSharp.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /csharp-basic-topics/WhatsNewInCSharp10/WhatsNewInCSharp10/Maze.cs: -------------------------------------------------------------------------------- 1 | namespace WhatsNewInCSharp10; 2 | 3 | public struct Maze 4 | { 5 | // Parameterless constructor with property initialization 6 | public Maze() 7 | { 8 | Size = 10; 9 | } 10 | 11 | // Initialization of the property at its declaration 12 | public int Size { get; set; } = 10; 13 | } 14 | -------------------------------------------------------------------------------- /csharp-design-patterns/VisitorPattern/VisitorPatternTests/Structural Code Tests/Elements/ConcreteElementOne.cs: -------------------------------------------------------------------------------- 1 | namespace VisitorPatternTests 2 | { 3 | public class ConcreteElementOne : IVisitableElement 4 | { 5 | public string ElementOneData { get; } = "The Ultimate Answer To Everything: "; 6 | public void Accept(IVisitor visitor) => visitor.Visit(this); 7 | } 8 | } -------------------------------------------------------------------------------- /dotnet-datetime/DateTimeNowVsDateTimeUtcNow/DateTimeNowVsDateTimeUtcNow/DateTimeNowVsDateTimeUtcNow.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /dotnet-dependency-injection/DependencyInjectionLifetimeScopes/DependencyInjectionLifetimeScopes/Services/MyService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace DependencyInjectionLifetimeScopes 4 | { 5 | public class MyService : IMyTransientService, IMyScopedService, IMySingletonService 6 | { 7 | public string InstanceId { get; } = Guid.NewGuid().ToString(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /numbers-csharp/ConvertString2Int/BenchmarkRunner/Program.cs: -------------------------------------------------------------------------------- 1 | using ConvertString2Int; 2 | 3 | namespace BenchmarkRunner 4 | { 5 | public class Program 6 | { 7 | static void Main(string[] args) 8 | { 9 | BenchmarkDotNet.Running.BenchmarkRunner.Run(); 10 | 11 | Console.ReadKey(); 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /strings-csharp/UsingVariablesInsideStrings/UsingVariablesInsideStrings/UsingVariablesInsideStrings.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /collections-csharp/IterateThroughDictionary/IterateThroughDictionary/IterateThroughDictionary.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /collections-csharp/RemoveFromListWhileIterating/RemoveFromListWhileIterating/RemoveFromListWhileIterating.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /csharp-advanced-topics/DelegatesInCsharp/.idea/.idea.DelegatesInCsharp/.idea/indexLayout.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ../../../CodeMazeGuides 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /csharp-basic-topics/ParamsKeyword/ParamsKeyword/ShoppingList.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ParamsKeyword 4 | { 5 | public class ShoppingList 6 | { 7 | public void Add(params string[] items) 8 | { 9 | foreach (var item in items) 10 | { 11 | Console.WriteLine($"Added: {item}"); 12 | } 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /strings-csharp/ConvertTitleCaseToCamelCase/ConvertTitleCaseToCamelCase/ConvertTitleCaseToCamelCase.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /csharp-basic-topics/ExpressionBodiedMembersInCsharp/ExpressionBodiedMembersInCsharp/ExpressionBodiedMembersInCsharp.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /csharp-intermediate-topics/RecordsInCSharp/RecordsInCSharpExample/Person.cs: -------------------------------------------------------------------------------- 1 | namespace RecordsInCSharpExample; 2 | 3 | public record Person 4 | { 5 | public Person(string firstName, string lastName) 6 | { 7 | FirstName = firstName; 8 | LastName = lastName; 9 | } 10 | public string LastName { get; set; } 11 | public string FirstName { get; set; } 12 | } 13 | 14 | -------------------------------------------------------------------------------- /dotnet-datetime/DateOnlyAndTimeOnlyInCSharp/DateOnlyAndTimeOnlyInCSharpExample/DateOnlyAndTimeOnlyInCSharpExample.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /dotnet-projects/README.md: -------------------------------------------------------------------------------- 1 | ## .NET Projects 2 | 3 | This section contains articles about working with projects in .NET (templates, CLI, NuGet, versioning...) 4 | 5 | ### Relevant articles: 6 | 7 | - [How to Create and Publish a NuGet Package with .NET CLI](https://code-maze.com/dotnet-nuget-create-publish/) 8 | - [Creating .NET Project Templates](https://code-maze.com/dotnet-project-templates-creation/) 9 | -------------------------------------------------------------------------------- /threads-csharp/MultithreadingInCsharp/RunCodeInNewThreadConsoleApplication/ThreadInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | 3 | namespace RunCodeInNewThreadConsoleApplication; 4 | 5 | public static class ThreadInfo 6 | { 7 | public static string Log() 8 | { 9 | return $"Thread [{Thread.CurrentThread.ManagedThreadId}] ThreadPool: {Thread.CurrentThread.IsThreadPoolThread}:"; 10 | } 11 | } -------------------------------------------------------------------------------- /csharp-basic-topics/ExpressionBodiedMembersInCsharp/ExpressionBodiedMembersInCsharp/Square.cs: -------------------------------------------------------------------------------- 1 | namespace ExpressionBodiedMembersInCsharp 2 | { 3 | public class Square 4 | { 5 | private double _side; 6 | 7 | public Square(double side) 8 | { 9 | _side = side; 10 | } 11 | 12 | public double CalculateArea() => Math.Pow(_side, 2); 13 | } 14 | } -------------------------------------------------------------------------------- /csharp-basic-topics/NamedAndOptionalArgumentsInCSharp/NamedAndOptionalArgumentsInCSharp/NamedAndOptionalArgumentsInCSharp.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /dotnet-datetime/ConvertDateTimeToIso8601String/ConvertDateTimeToIso8601String/ConvertDateTimeToIso8601String.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /json-csharp/DeserializeComplexJsonObject/DeserializeComplexJSONObject/POCO/Company.cs: -------------------------------------------------------------------------------- 1 | namespace DeserializeComplexJSONObject.POCO 2 | { 3 | public class Company 4 | { 5 | public string? Id { get; set; } 6 | public string? Name { get; set; } 7 | public List? Cofounders { get; set; } 8 | public List? Employees { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /aspnetcore-webapi/WorkingWithRestSharp/WorkingWithRestSharp/DataTransferObject/UserCreationResponse.cs: -------------------------------------------------------------------------------- 1 | namespace WorkingWithRestSharp.DataTransferObject 2 | { 3 | public class UserCreationResponse 4 | { 5 | public string Name { get; set; } 6 | public string Job { get; set; } 7 | public string Id { get; set; } 8 | public string CreatedAt { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /csharp-advanced-topics/DelegatesInCsharp/ActionAndFuncDelegatesInCsharp/ActionAndFuncDelegatesInCsharp.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /csharp-arrays/CopyArrayElements/CopyArrayElements/Article.cs: -------------------------------------------------------------------------------- 1 | namespace CopyArrayElements 2 | { 3 | public class Article 4 | { 5 | public string? Title { get; set; } 6 | public DateTime LastUpdate { get; set; } 7 | 8 | public override string ToString() 9 | { 10 | return $" Title: { Title} | Last update:{LastUpdate}"; 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /aspnetcore-features/InMemoryCaching/InMemoryCacheExample/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "InMemoryCacheExample": { 4 | "commandName": "Project", 5 | "launchBrowser": false, 6 | "environmentVariables": { 7 | "ASPNETCORE_ENVIRONMENT": "Development" 8 | }, 9 | "applicationUrl": "https://localhost:5001;http://localhost:5000" 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /async-csharp/README.md: -------------------------------------------------------------------------------- 1 | ## Asynchronous Programming in C#. 2 | 3 | This section contains articles about asynchronous programming in C#. 4 | 5 | ### Relevant articles: 6 | 7 | - [Difference Between Asynchronous Programming and Multithreading](https://code-maze.com/csharp-async-vs-multi-threading/) 8 | - [Cancellation Tokens with IAsyncEnumerable](https://code-maze.com/csharp-cancellation-tokens-with-iasyncenumerable/) 9 | -------------------------------------------------------------------------------- /csharp-arrays/PopulateArrayWithTheSameValue/PopulateArrayWithTheSameValue/PopulateArrayWithTheSameValue.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | 10 7 | enable 8 | enable 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /csharp-basic-topics/AsAndIsOperatorsInCSharp/AsAndIsOperatorsInCSharp/Cow.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace AsAndIsOperatorsInCSharp 8 | { 9 | public class Cow : Animal 10 | { 11 | public Cow() : base(eatingHabits: "herbivore") 12 | { 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /csharp-basic-topics/ExpressionBodiedMembersInCsharp/ExpressionBodiedMembersInCsharp/SquareRefactored.cs: -------------------------------------------------------------------------------- 1 | namespace ExpressionBodiedMembersInCsharp 2 | { 3 | public class SquareRefactored 4 | { 5 | private double _side; 6 | 7 | public SquareRefactored(double side) 8 | { 9 | _side = side; 10 | } 11 | 12 | public double Area => Math.Pow(_side, 2); 13 | } 14 | } -------------------------------------------------------------------------------- /dotnet-dependency-injection/DependencyInjectionLifetimeScopes/DependencyInjectionLifetimeScopes/DependencyInjectionLifetimeScopes.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /aspnetcore-webapi/Minimal API/Minimal API/IArticleService.cs: -------------------------------------------------------------------------------- 1 | namespace Minimal_API; 2 | 3 | public interface IArticleService 4 | { 5 | Task GetArticles(); 6 | 7 | Task GetArticleById(int id); 8 | 9 | Task CreateArticle(ArticleRequest article); 10 | 11 | Task UpdateArticle(int id, ArticleRequest article); 12 | 13 | Task DeleteArticle(int id); 14 | } 15 | -------------------------------------------------------------------------------- /xml-csharp/XMLSerializationInCsharp/XMLSerializationInCsharp/XMLSerialization_v1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace XMLSerializationInCsharp_v1 4 | { 5 | public class Patient 6 | { 7 | public int ID { get; set; } 8 | public string FirstName { get; set; } 9 | public string LastName { get; set; } 10 | public DateTime Birthday { get; set; } 11 | public int RoomNo { get; set; } 12 | } 13 | 14 | 15 | } 16 | -------------------------------------------------------------------------------- /csharp-advanced-topics/DelegatesInCsharp/.idea/.idea.DelegatesInCsharp/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Rider ignored files 5 | /.idea.DelegatesInCsharp.iml 6 | /projectSettingsUpdater.xml 7 | /modules.xml 8 | /contentModel.xml 9 | # Editor-based HTTP Client requests 10 | /httpRequests/ 11 | # Datasource local storage ignored files 12 | /dataSources/ 13 | /dataSources.local.xml 14 | -------------------------------------------------------------------------------- /csharp-advanced-topics/QueueInCSharp/QueueInCSharp/Models/Order.cs: -------------------------------------------------------------------------------- 1 | namespace QueueInCSharp.Models; 2 | 3 | public class Order 4 | { 5 | public Order(string clientName, string[] productNames, int totalPrice) => (ClientName, ProductNames, TotalPrice) = (clientName, productNames, totalPrice); 6 | public string ClientName { get; set; } 7 | public string[] ProductNames { get; set; } 8 | public int TotalPrice { get; set; } 9 | } -------------------------------------------------------------------------------- /csharp-intermediate-topics/CompositionVsInheritance/CompositionVsInheritance/BrickHouse.cs: -------------------------------------------------------------------------------- 1 | namespace CompositionVsInheritance 2 | { 3 | public class BrickHouse : House 4 | { 5 | private readonly Address _address; 6 | 7 | public BrickHouse() 8 | { 9 | _address = new Address(); 10 | } 11 | 12 | public string GetAddress() => _address.GetAddress(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /dependency-injection-tools/AutoFacImplementationWeb/AutoFacImplementationWeb/Implementation/StringBusiness.cs: -------------------------------------------------------------------------------- 1 | using AutoFacImplementationWeb.Interface; 2 | 3 | namespace AutoFacImplementationWeb.Implementation 4 | { 5 | public class StringBusiness : IStringBusiness 6 | { 7 | public string StringToUpper(string personName) 8 | { 9 | return personName.ToUpper(); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /dotnet-projects/ProjectTemplates/codemazeapi/codemazeapi.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /strings-csharp/ConvertTitleCaseToCamelCase/ConvertTitleCaseToCamelCase/Program.cs: -------------------------------------------------------------------------------- 1 | using ConvertTitleCaseToCamelCase; 2 | 3 | var inputs = new[] 4 | { 5 | "Welcome to the Maze", 6 | "Welcome To The Maze", 7 | "WelcomeToTheMaze", 8 | "Welcome_To_The_Maze", 9 | "ISODate", 10 | "IOStream" 11 | }; 12 | 13 | foreach (var x in inputs) 14 | { 15 | Console.WriteLine($"{x} => {x.ToCamelCase()}"); 16 | } -------------------------------------------------------------------------------- /csharp-arrays/PopulateArrayWithTheSameValue/PopulateArrayWithTheSameValue/Article.cs: -------------------------------------------------------------------------------- 1 | namespace PopulateArrayWithTheSameValue 2 | { 3 | public class Article 4 | { 5 | public string? Title { get; set; } 6 | public DateTime LastUpdate { get; set; } 7 | 8 | public override string ToString() 9 | { 10 | return $" Title: {Title} | Last update: {LastUpdate}"; 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /csharp-basic-topics/TypesOfInheritanceInCSharp/TypesOfInheritanceInCSharp/MobileDevice.cs: -------------------------------------------------------------------------------- 1 | namespace TypesOfInheritanceInCSharp; 2 | 3 | public class MobileDevice 4 | { 5 | public string OperatingSystem { get; set; } = null!; 6 | 7 | public double Inches { get; set; } 8 | 9 | public bool IsConnected { get; set; } 10 | 11 | public virtual bool DeviceCanMakePhoneCall() 12 | { 13 | return false; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /csharp-design-patterns/ObserverPattern/ObserverPattern/Application.cs: -------------------------------------------------------------------------------- 1 | 2 | namespace ObserverPattern 3 | { 4 | public class Application 5 | { 6 | public int JobId { get; set; } 7 | public string ApplicantName { get; set; } 8 | 9 | public Application(int jobId, string applicantName) 10 | { 11 | JobId = jobId; 12 | ApplicantName = applicantName; 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /csharp-intermediate-topics/DifferencesBetweenValueTupleAndTupleInCSharp/DifferencesBetweenValueTupleAndTupleInCSharp/DifferencesBetweenValueTupleAndTupleInCSharp.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /dotnet-client-libraries/Google Sheets API/GoogleSheetsAPI/GoogleSheetsAPI.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /files-csharp/WriteToCsv/WriteToCsv/WriteToCsv.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /aspnetcore-webapi/ASPNETCoreRabbitMQ/Producer/Data/Order.cs: -------------------------------------------------------------------------------- 1 | using Producer.Dtos; 2 | using System.ComponentModel.DataAnnotations; 3 | 4 | namespace Producer.Data 5 | { 6 | public class Order 7 | { 8 | [Key] 9 | public int Id { get; set; } 10 | 11 | public string ProductName { get; set; } 12 | 13 | public decimal Price { get; set; } 14 | 15 | public int Quantity { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /aspnetcore-webapi/ASPNETCoreRabbitMQ/Producer/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*", 9 | "ConnectionStrings": { 10 | "OrderDbContext": "Server=(localdb)\\mssqllocaldb;Database=OrderDbContext-44e53e96-ac1f-4ba4-a87d-19422da84f38;Trusted_Connection=True;MultipleActiveResultSets=true" 11 | } 12 | } -------------------------------------------------------------------------------- /csharp-algorithms/MergeSort/MergeSort/MergeSort.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /csharp-design-patterns/VisitorPattern/TeamA.TestResults/ExtensibilityContract/ISicknessAlertVisitor.cs: -------------------------------------------------------------------------------- 1 | using TeamA.TestResults.ExtensibilityContract; 2 | using TeamA.TestResults.Results; 3 | 4 | namespace TeamA.TestResults 5 | { 6 | public interface ISicknessAlertVisitor 7 | { 8 | AlertReport Visit(BloodSample blood); 9 | AlertReport Visit(XRayImage rtg); 10 | AlertReport Visit(EcgReading sample); 11 | } 12 | } -------------------------------------------------------------------------------- /csharp-design-patterns/VisitorPattern/TeamB.Detectors/TeamB.Detectors.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /dependency-injection-tools/AutoFacImplementationWeb/Test.AutoFacImplementationWeb/StringBusinessTestImplementation.cs: -------------------------------------------------------------------------------- 1 | using AutoFacImplementationWeb.Interface; 2 | 3 | namespace Test.AutoFacImplementationWeb 4 | { 5 | public class StringBusinessTestImplementation : IStringBusiness 6 | { 7 | public string StringToUpper(string personName) 8 | { 9 | return personName.ToUpper(); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /json-csharp/DeserializeComplexJsonObject/DeserializeComplexJSONObject/POCO/Employee.cs: -------------------------------------------------------------------------------- 1 | namespace DeserializeComplexJSONObject.POCO 2 | { 3 | public class Employee 4 | { 5 | public string? Id { get; set; } 6 | public string? FullName { get; set; } 7 | public int AnualSalary { get; set; } 8 | public Position? Position { get; set; } 9 | public List? Benefits { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /csharp-algorithms/BubbleSort/BubbleSort/BubbleSort.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /aspnetcore-webapi/ASPNETCoreRabbitMQ/Subscriber/Subscriber.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /strings-csharp/UsingVariablesInsideStrings/UsingVariablesInsideStrings/MyClass.cs: -------------------------------------------------------------------------------- 1 | namespace UsingVariablesInsideStrings 2 | { 3 | public class MyClass 4 | { 5 | public int MyNumber { get; set; } 6 | 7 | public MyClass(int num) 8 | { 9 | MyNumber = num; 10 | } 11 | 12 | public override string ToString() 13 | { 14 | return MyNumber.ToString(); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /async-csharp/Asynchronous Programming vs Multithreading/Asynchronous Programming/AsynchronousProgramming.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | Asynchronous_Programming 7 | enable 8 | enable 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /csharp-algorithms/SelectionSort/SelectionSort/SelectionSort.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /csharp-basic-topics/ExpressionBodiedMembersInCsharp/ExpressionBodiedMembersInCsharp/Staff.cs: -------------------------------------------------------------------------------- 1 | namespace ExpressionBodiedMembersInCsharp 2 | { 3 | public class Staff { 4 | 5 | private readonly string[] _staff = { "John", "Mary", "Derrick", "Paul", "Lisa" }; 6 | 7 | public string this[int index] 8 | { 9 | get => _staff[index]; 10 | set => _staff[index] = value; 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /aspnetcore-webapi/OptionalParameterinWebApi/OptionalParameterinWebApi/OptionalParameterinWebApi.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /aspnetcore-webapi/SerializationDemo/SerializationDemo.Common/SerializationDemo.Common.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /csharp-arrays/CopyArrayElements/CopyArrayElements/CopyArrayElements.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /aspnetcore-webapi/MandatoryQueryStringParameters/MandatoryQueryStringParameters/Program.cs: -------------------------------------------------------------------------------- 1 | var builder = WebApplication.CreateBuilder(args); 2 | 3 | // Add services to the container. 4 | 5 | builder.Services.AddControllers(); 6 | builder.Services.AddEndpointsApiExplorer(); 7 | 8 | var app = builder.Build(); 9 | 10 | app.UseHttpsRedirection(); 11 | 12 | app.UseAuthorization(); 13 | 14 | app.MapControllers(); 15 | 16 | app.Run(); 17 | public partial class Program { } -------------------------------------------------------------------------------- /aspnetcore-webapi/OptionalParameterinWebApi/OptionalParameterinWebApi/WeatherForecast.cs: -------------------------------------------------------------------------------- 1 | namespace OptionalParameterinWebApi 2 | { 3 | public class WeatherForecast 4 | { 5 | public int Id { get; set; } 6 | 7 | public DateTime Date { get; set; } 8 | 9 | public int TemperatureC { get; set; } 10 | 11 | public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); 12 | 13 | public string? Summary { get; set; } 14 | } 15 | } -------------------------------------------------------------------------------- /aspnetcore-features/CustomAttributes/CustomAttributes/YourTasks.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace CustomAttributes 8 | { 9 | public class YourTasks : MyTasks 10 | { 11 | [DeveloperTask(Priorities.Mid, Description = "Mid level description")] 12 | public override void ScheduleInterview() 13 | { 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /csharp-basic-topics/PatternMatchingInCSharp/PropertyPatternsDemo/DataModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace PropertyPatternsTest 4 | { 5 | //let's declare a data model that is small, but contains enough property nesting to show our point 6 | record Order(Payment Payment, Customer Customer); 7 | record Payment(Price Price, DateTime? PaymentDate = null); 8 | record Price(string Currency, decimal Amount); 9 | record Customer(string Name, string Group); 10 | } -------------------------------------------------------------------------------- /aspnetcore-webapi/SerializationDemo/SerializationDemo.Common/Models/Employee.cs: -------------------------------------------------------------------------------- 1 | using ProtoBuf; 2 | 3 | namespace SerializationDemo.Common.Models 4 | { 5 | [ProtoContract] 6 | public class Employee 7 | { 8 | [ProtoMember(1)] 9 | public Guid Id { get; set; } 10 | 11 | [ProtoMember(2)] 12 | public string Name { get; set; } 13 | 14 | [ProtoMember(3)] 15 | public Address? Address { get; set; } 16 | } 17 | } -------------------------------------------------------------------------------- /authorization-dotnet/UsingAuthorizationWithSwagger/UsingAuthorizationWithSwagger/Models/LoginModel.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | 3 | namespace UsingAuthorizationWithSwagger.Models 4 | { 5 | public class LoginModel 6 | { 7 | [Required(ErrorMessage="Email Required")] 8 | public string UserName { get; set; } 9 | [Required(ErrorMessage = "Password Required")] 10 | public string Password { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /dotnet-projects/ProjectTemplates/codemazeapi/Controllers/ContactController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Http; 2 | using Microsoft.AspNetCore.Mvc; 3 | 4 | namespace codemazeapi.Controllers 5 | { 6 | [Route("api/[controller]")] 7 | [ApiController] 8 | public class ContactController : ControllerBase 9 | { 10 | public IActionResult Get() 11 | { 12 | return Ok("visit us at https://code-maze.com/contact/"); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /aspnetcore-webapi/RateLimitingDemo/RateLimitingDemo.UsingCustomMiddleware/Extensions/MiddlewareExtensions.cs: -------------------------------------------------------------------------------- 1 | using RateLimitingDemo.UsingCustomMiddleware.Middlewares; 2 | 3 | namespace RateLimitingDemo.UsingCustomMiddleware.Extensions; 4 | 5 | public static class MiddlewareExtensions 6 | { 7 | public static IApplicationBuilder UseRateLimiting(this IApplicationBuilder builder) 8 | { 9 | return builder.UseMiddleware(); 10 | } 11 | } 12 | 13 | -------------------------------------------------------------------------------- /aspnetcore-webapi/Minimal API/Minimal API/Minimal API.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | enable 7 | Minimal_API 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /async-csharp/CancellationTokensIAsyncEnumerable/CancellationIAsyncEnumerable/CancellationIAsyncEnumerable.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /collections-csharp/IterateThroughDictionary/BenchmarkRunner/BenchmarkRunner.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /threads-csharp/MultithreadingInCsharp/RunCodeInNewThreadApplication/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Configuration; 4 | using System.Data; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | 9 | namespace RunCodeInNewThreadApplication 10 | { 11 | /// 12 | /// Interaction logic for App.xaml 13 | /// 14 | public partial class App : Application 15 | { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /csharp-intermediate-topics/CompositionVsInheritance/CompositionVsInheritance/GlassHouse.cs: -------------------------------------------------------------------------------- 1 | namespace CompositionVsInheritance 2 | { 3 | public class GlassHouse : House 4 | { 5 | private readonly Address _address; 6 | 7 | public GlassHouse() 8 | { 9 | _address = new Address(); 10 | } 11 | 12 | public string GetAddress() => _address.GetAddress(); 13 | 14 | public string WarningSign() => "No rocks please!"; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /aspnetcore-webapi/RateLimitingDemo/RateLimitingDemo.UsingCustomMiddleware/RateLimitingDemo - Backup.UsingCustomMiddleware.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /csharp-basic-topics/AsAndIsOperatorsInCSharp/AsAndIsOperatorsInCSharp/Animal.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace AsAndIsOperatorsInCSharp 8 | { 9 | public class Animal 10 | { 11 | public string EatingHabits { get; set; } 12 | 13 | public Animal(string eatingHabits) 14 | { 15 | EatingHabits = eatingHabits; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /aspnetcore-features/CustomAttributes/CustomAttributes/ManagerTaskAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace CustomAttributes 8 | { 9 | [AttributeUsage(AttributeTargets.Method, Inherited = false)] 10 | public class ManagerTaskAttribute : Attribute 11 | { 12 | public Priorities Priority { get; set; } 13 | public bool NeedsReport { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /aspnetcore-webapi/CreatingMultipleResourcesWithPOST/CreatingMultipleResourcesWithPOST/CreatingMultipleResourcesWithPOST.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /aspnetcore-webapi/WorkingWithRestSharp/WorkingWithRestSharp/WorkingWithRestSharp.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | disable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /csharp-arrays/FindTheMaximumValue/FindTheMaximumValue/FindTheMaximumValue.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | 10 7 | enable 8 | enable 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /threads-csharp/MultithreadingInCsharp/RunCodeInNewThreadApplication/App.xaml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /csharp-design-patterns/VisitorPattern/VisitorPatternTests/Structural Code Tests/Visitors/ConcreteVisitorOne.cs: -------------------------------------------------------------------------------- 1 | namespace VisitorPatternTests 2 | { 3 | public class ConcreteVisitorOne : IVisitor 4 | { 5 | public void Visit(ConcreteElementOne element) 6 | { 7 | Console.Write(element.ElementOneData); 8 | } 9 | 10 | public void Visit(ConcreteElementTwo element) 11 | { 12 | Console.Write(element.ElementTwoData); 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /json-csharp/DeserializeComplexJsonObject/DeserializeComplexJSONObject/NewtonsoftDeserializer.cs: -------------------------------------------------------------------------------- 1 | using DeserializeComplexJSONObject.POCO; 2 | using Newtonsoft.Json; 3 | 4 | namespace DeserializeComplexJSONObject 5 | { 6 | public class NewtonsoftDeserializer 7 | { 8 | public Company? DeserializeUsingGenericNewtonsoftJson(string json) 9 | { 10 | var company = JsonConvert.DeserializeObject(json); 11 | 12 | return company; 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /csharp-basic-topics/ExpressionBodiedMembersInCsharp/ExpressionBodiedMembersInCsharp/Employee.cs: -------------------------------------------------------------------------------- 1 | namespace ExpressionBodiedMembersInCsharp 2 | { 3 | public class Employee 4 | { 5 | private string _name; 6 | 7 | public string Name 8 | { 9 | get => _name; 10 | set => _name = value; 11 | } 12 | 13 | public Employee(string name) => _name = name; 14 | 15 | ~Employee() => Console.WriteLine("Employee object has been finalized"); 16 | } 17 | } -------------------------------------------------------------------------------- /dotnet-projects/NugetUsingCLI/CodeMaze.Utilities.TemperatureConverter/Converter.cs: -------------------------------------------------------------------------------- 1 | namespace CodeMaze.Utilities.TemperatureConverter 2 | { 3 | public static class Converter 4 | { 5 | public static double ToFahrenheit(double degreeCelsiusTemp) 6 | { 7 | return (degreeCelsiusTemp * 9 / 5) + 32; 8 | } 9 | 10 | public static double ToDegreeCelsius(double fahrenheitTemp) 11 | { 12 | return (fahrenheitTemp - 32) * 5 / 9; 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /json-csharp/JsonSerializationOfEnumAsString/JsonSerialization.Newtonsoft.EnumAsString.WebApi/Program.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json.Converters; 2 | 3 | var builder = WebApplication.CreateBuilder(args); 4 | 5 | builder.Services.AddControllers() 6 | .AddNewtonsoftJson(options => 7 | { 8 | options.SerializerSettings.Converters.Add(new StringEnumConverter()); 9 | }); 10 | 11 | var app = builder.Build(); 12 | 13 | app.UseAuthorization(); 14 | 15 | app.MapControllers(); 16 | 17 | app.Run(); -------------------------------------------------------------------------------- /aspnetcore-webapi/VersioningRestAPI/VersioningRestAPI/V2/Controllers/StringListController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | 3 | namespace VersioningRestAPI.V2.Controllers 4 | { 5 | [ApiController] 6 | [Route("api/[controller]")] 7 | [ApiVersion("2.0")] 8 | public class StringListController : Controller 9 | { 10 | [HttpGet()] 11 | public IEnumerable Get() 12 | { 13 | return Data.Summaries.Where(x => x.StartsWith("S")); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /collections-csharp/HowToDetectIfADictionaryKeyExistsInCsharp/HowToDetectIfADictionaryKeyExistsInCsharp/MyClass.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace HowToDetectIfADictionaryKeyExistsInCsharp 8 | { 9 | public class MyClass 10 | { 11 | public int MyNumber { get; set; } 12 | 13 | public MyClass(int num) 14 | { 15 | MyNumber = num; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /json-csharp/JsonSerializationOfEnumAsString/JsonSerialization.Native.EnumAsString.WebApi/Program.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | var builder = WebApplication.CreateBuilder(args); 4 | 5 | builder.Services.AddControllers() 6 | .AddJsonOptions(options => 7 | { 8 | options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter()); 9 | }); 10 | 11 | var app = builder.Build(); 12 | 13 | app.UseAuthorization(); 14 | 15 | app.MapControllers(); 16 | 17 | app.Run(); -------------------------------------------------------------------------------- /aspnetcore-webapi/WorkingWithRestSharp/WorkingWithRestSharp/DataTransferObject/PagingInformation.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace WorkingWithRestSharp.DataTransferObject 4 | { 5 | public class PagingInformation 6 | { 7 | public int Page { get; set; } 8 | [JsonPropertyName("Per_Page")] 9 | public int PerPage { get; set; } 10 | public int Total { get; set; } 11 | [JsonPropertyName("Total_Pages")] 12 | public int TotalPages { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /aspnetcore-webapi/VersioningRestAPI/VersioningRestAPI/V3/Controllers/StringListController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | 3 | namespace VersioningRestAPI.V3.Controllers 4 | { 5 | [ApiController] 6 | [Route("api/v{version:apiVersion}/StringList")] 7 | [ApiVersion("3.0")] 8 | public class StringListController : Controller 9 | { 10 | [HttpGet()] 11 | public IEnumerable Get() 12 | { 13 | return Data.Summaries.Where(x => x.StartsWith("C")); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /collections-csharp/README.md: -------------------------------------------------------------------------------- 1 | ## Collections in C#/.NET 2 | 3 | This section contains articles about C#/.NET collections. 4 | 5 | ### Relevant articles: 6 | 7 | - [How to Get an Item by Index From Dictionary in C#](https://code-maze.com/csharp-get-item-by-index-from-dictionary/) 8 | - [How to Detect if a Dictionary Key Exists in C#](https://code-maze.com/csharp-detect-dictionary-key-exists/) 9 | - [SortedList in C#](https://code-maze.com/csharp-sortedlist/) 10 | - [List Collection in C#](https://code-maze.com/csharp-list-collection/) 11 | -------------------------------------------------------------------------------- /csharp-advanced-topics/QueueInCSharp/QueueInCSharp/Program.cs: -------------------------------------------------------------------------------- 1 | using QueueInCSharp; 2 | 3 | var (firstRemovedOrder, numberOfRemainingOrders) = QueueOperations.GetOrderAndRemove(); 4 | Console.WriteLine($"Dequeue the first order. Client: {firstRemovedOrder.ClientName}. Remaining orders: {numberOfRemainingOrders}"); 5 | 6 | var (firstPeekedOrder, numberOfOrders) = QueueOperations.GetOrderWithoutRemoving(); 7 | Console.WriteLine($"Peek the first order. Client: {firstPeekedOrder.ClientName}. Remaining orders: {numberOfOrders}"); 8 | 9 | 10 | -------------------------------------------------------------------------------- /threads-csharp/MultithreadingInCsharp/RunCodeInNewThreadConsoleApplication/RunCodeInNewThreadConsoleApplication.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | 7 | 8 | 9 | <_Parameter1>RunCodeInNewThreadApplicationTests 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /dependency-injection-tools/AutoFacImplementationWeb/AutoFacImplementationWeb/AutoFacImplementationWeb.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /json-csharp/JsonSerializationWriteToFile/JsonSerializationWriteToFile/JsonSerializationWriteToFile.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /json-csharp/JsonSerializationWriteToFile/JsonSerializationWriteToFile/College.cs: -------------------------------------------------------------------------------- 1 | namespace JsonSerializationWriteToFile; 2 | 3 | public record class College( 4 | string Name, 5 | int NoOfStudents, 6 | bool IsPublic, 7 | List? Teachers = null); 8 | 9 | public record class Teacher( 10 | string Name, 11 | int WorkHours, 12 | bool InProbation, 13 | List? Courses = null); 14 | 15 | public record class Course( 16 | string Name, 17 | int CreditHours, 18 | bool IsOptional); -------------------------------------------------------------------------------- /aspnetcore-webapi/VersioningRestAPI/VersioningRestAPI/VersioningRestAPI.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /csharp-advanced-topics/EventsInCsharp/EventsInCsharp/Services/AppService.cs: -------------------------------------------------------------------------------- 1 | using EventsInCsharp.EventArguments; 2 | using EventsInCsharp.Model; 3 | using System; 4 | 5 | namespace EventsInCsharp.Services 6 | { 7 | public class AppService 8 | { 9 | public Order Order { get; set; } 10 | 11 | public void OnFoodPrepared(object source, FoodPreparedEventArgs eventArgs) 12 | { 13 | Order = eventArgs.Order as Order; 14 | Console.WriteLine($"AppService: your food '{eventArgs.Order.Item}' is prepared."); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /json-csharp/JsonSerializationOfEnumAsString/JsonSerialization.EnumAsString.Models/ToggleControl.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.Serialization; 2 | 3 | namespace JsonSerialization.EnumAsString.Models; 4 | 5 | public record struct ToggleControl(string Name, ToggleType Type); 6 | 7 | public enum ToggleType 8 | { 9 | [EnumMember(Value = "Enable/Disable")] 10 | EnableDisable, 11 | 12 | [EnumMember(Value = "Visible/Hidden")] 13 | VisibleHidden, 14 | 15 | [EnumMember(Value = "Editable/Readonly")] 16 | EditableReadonly, 17 | } -------------------------------------------------------------------------------- /aspnetcore-webapi/CustomHeadersInASPNETCoreWebAPI/CustomHeadersInASPNETCoreWebAPI/CustomHeaderAttribute.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc.Filters; 2 | 3 | namespace CustomHeadersInASPNETCoreWebAPI 4 | { 5 | public class CustomHeaderAttribute : ResultFilterAttribute 6 | { 7 | public override void OnResultExecuting(ResultExecutingContext context) 8 | { 9 | context.HttpContext.Response.Headers.Add("x-my-custom-header", "attribute response"); 10 | base.OnResultExecuting(context); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /csharp-advanced-topics/EventsInCsharp/EventsInCsharp/Services/MailService.cs: -------------------------------------------------------------------------------- 1 | using EventsInCsharp.EventArguments; 2 | using EventsInCsharp.Model; 3 | using System; 4 | 5 | namespace EventsInCsharp.Services 6 | { 7 | public class MailService 8 | { 9 | public Order Order { get; set; } 10 | 11 | public void OnFoodPrepared(object source, FoodPreparedEventArgs eventArgs) 12 | { 13 | Order = eventArgs.Order as Order; 14 | Console.WriteLine($"MailService: your food '{eventArgs.Order.Item}' is prepared."); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /aspnetcore-webapi/ASPNETCoreRabbitMQ/Producer/Data/OrderDbContext.cs: -------------------------------------------------------------------------------- 1 | #nullable disable 2 | using Microsoft.EntityFrameworkCore; 3 | using Producer.Data; 4 | 5 | public class OrderDbContext : DbContext, IOrderDbContext 6 | { 7 | public OrderDbContext (DbContextOptions options) 8 | : base(options) 9 | { 10 | } 11 | 12 | public DbSet Order { get; set; } 13 | 14 | public Task SaveChangesAsync() 15 | { 16 | return base.SaveChangesAsync(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /aspnetcore-webapi/SerializationDemo/SerializationDemo.Common/Models/Address.cs: -------------------------------------------------------------------------------- 1 | using ProtoBuf; 2 | 3 | namespace SerializationDemo.Common.Models 4 | { 5 | [ProtoContract] 6 | public class Address 7 | { 8 | [ProtoMember(1)] 9 | public string AddressLine1 { get; set; } 10 | 11 | [ProtoMember(2)] 12 | public string? AddressLine2 { get; set; } 13 | 14 | [ProtoMember(3)] 15 | public string City { get; set; } 16 | 17 | [ProtoMember(4)] 18 | public string Country { get; set; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /csharp-arrays/README.md: -------------------------------------------------------------------------------- 1 | ## csharp-arrays 2 | 3 | This section contains the topics about arrays in C#. 4 | 5 | ### Relevant articles: 6 | - [How to Copy Array Elements to New Array in C#](https://code-maze.com/csharp-copy-array-elements-to-new-array/) 7 | - [How to Find the Maximum Value of an Array in C#](https://code-maze.com/csharp-array-maximum-value/) 8 | - [Different Ways to Initialize Arrays in C#](https://code-maze.com/csharp-initialize-arrays/) 9 | - [How to Populate an Array With the Same Value in C#](https://code-maze.com/csharp-populate-array-same-value/) 10 | -------------------------------------------------------------------------------- /threads-csharp/MultithreadingInCsharp/RunCodeInNewThreadApplication/RunCodeInNewThreadApplication.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | WinExe 5 | netcoreapp3.1 6 | true 7 | 8 | 9 | 10 | <_Parameter1>RunCodeInNewThreadApplicationTests 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /aspnetcore-webapi/VersioningRestAPI/VersioningRestAPI/V1/Controllers/StringListController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | 3 | namespace VersioningRestAPI.V1.Controllers 4 | { 5 | [ApiController] 6 | [Route("api/[controller]")] 7 | [ApiVersion("0.9", Deprecated = true)] 8 | [ApiVersion("1.0")] 9 | public class StringListController : ControllerBase 10 | { 11 | [HttpGet()] 12 | public IEnumerable Get() 13 | { 14 | return Data.Summaries.Where(x => x.StartsWith("B")); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /aspnetcore-webapi/WorkingWithRestSharp/WorkingWithRestSharp/DataTransferObject/UserData.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace WorkingWithRestSharp.DataTransferObject 4 | { 5 | public class UserData 6 | { 7 | public int Id { get; set; } 8 | public string Email { get; set; } 9 | [JsonPropertyName("First_Name")] 10 | public string FirstName { get; set; } 11 | [JsonPropertyName("Last_Name")] 12 | public string LastName { get; set; } 13 | public string Avatar { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /csharp-intermediate-topics/RecordsInCSharp/RecordsInCSharpExample/Program.cs: -------------------------------------------------------------------------------- 1 | namespace RecordsInCSharpExample; 2 | 3 | public class Program 4 | { 5 | public static void Main(string[] args) 6 | { 7 | var person1 = new Person("Joe", "Bloggs"); 8 | var person2 = new Person("Joe", "Bloggs"); 9 | var person3 = new Person("Jane", "Bloggs"); 10 | Console.WriteLine($"Person1 == Person2? {person1 == person2}"); 11 | Console.WriteLine($"Person1 == Person3? {person1 == person3}"); 12 | Console.ReadKey(); 13 | } 14 | } 15 | 16 | -------------------------------------------------------------------------------- /aspnetcore-webapi/MassTransitRabbitMQ/Producer/Program.cs: -------------------------------------------------------------------------------- 1 | using MassTransit; 2 | 3 | var builder = WebApplication.CreateBuilder(args); 4 | 5 | // Add services to the container. 6 | builder.Services.AddMassTransit(x => 7 | { 8 | x.UsingRabbitMq(); 9 | }); 10 | 11 | builder.Services.AddMassTransitHostedService(); 12 | 13 | builder.Services.AddControllers(); 14 | 15 | var app = builder.Build(); 16 | 17 | // Configure the HTTP request pipeline. 18 | 19 | app.UseHttpsRedirection(); 20 | 21 | app.UseAuthorization(); 22 | 23 | app.MapControllers(); 24 | 25 | app.Run(); 26 | -------------------------------------------------------------------------------- /csharp-arrays/CompareArrays/BenchmarkRunner/BenchmarkRunner.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | disable 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /visual-studio/DebuggingBasicsInCSharp/Tests/Tests.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | 3 | namespace DebuggingBasicsInCSharp.Tests 4 | { 5 | [TestClass] 6 | public class Tests 7 | { 8 | [TestMethod] 9 | public void WhenNumberIsPassedThenReturnMultiplicationTable() 10 | { 11 | var number = 7; 12 | 13 | var actual = Program.GetMultiplicationTable(number); 14 | 15 | Assert.IsNotNull(actual); 16 | 17 | StringAssert.Contains(actual, "7 X 1 = 7"); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /collections-csharp/CsharpLists/CsharpLists/ListOperations.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace CsharpLists 8 | { 9 | public class ListOperations 10 | { 11 | public List AddElements() 12 | { 13 | var countries = new List(); 14 | countries.Add("Mexico"); 15 | countries.Add("Mexico"); 16 | countries.Add("Italy"); 17 | return countries; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /csharp-basic-topics/ExpressionBodiedMembersInCsharp/ExpressionBodiedMembersInCsharp/EmployeeRefactored.cs: -------------------------------------------------------------------------------- 1 | namespace ExpressionBodiedMembersInCsharp 2 | { 3 | public class EmployeeRefactored 4 | { 5 | private string _position; 6 | private string _employer; 7 | 8 | public EmployeeRefactored(string position, string employer) 9 | { 10 | _position = position; 11 | _employer = employer; 12 | } 13 | 14 | public string Position => _employer != null ? $"{_position} at {_employer}" : "Unemployed"; 15 | } 16 | } -------------------------------------------------------------------------------- /csharp-basic-topics/TypesOfInheritanceInCSharp/TypesOfInheritanceInCSharp/ConvertibleNotebook.cs: -------------------------------------------------------------------------------- 1 | namespace TypesOfInheritanceInCSharp; 2 | 3 | public class ConvertibleNotebook : MobileDevice, ILaptop 4 | { 5 | public int UsbPortNumbers { get; set; } 6 | 7 | public override bool DeviceCanMakePhoneCall() 8 | { 9 | if (IsConnected) 10 | { 11 | return true; 12 | } 13 | 14 | return false; 15 | } 16 | 17 | public void WriteWithKeyboard(string message) 18 | { 19 | Console.WriteLine(message); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /csharp-arrays/CompareArrays/CompareArrays/Article.cs: -------------------------------------------------------------------------------- 1 | namespace CompareArrays 2 | { 3 | public class Article : IEqualityComparer
4 | { 5 | public string? Title { get; set; } 6 | public DateTime LastUpdate { get; set; } 7 | 8 | public bool Equals(Article? first, Article? second) 9 | { 10 | return first?.Title == second?.Title && first?.LastUpdate == second?.LastUpdate; 11 | } 12 | 13 | public int GetHashCode(Article obj) 14 | { 15 | return base.GetHashCode(); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /dependency-injection-tools/AutoFacImplementationWeb/AutoFacImplementationWeb/Program.cs: -------------------------------------------------------------------------------- 1 | 2 | using Microsoft.AspNetCore; 3 | using Microsoft.AspNetCore.Hosting; 4 | 5 | namespace AutoFacImplementationWeb 6 | { 7 | public class Program 8 | { 9 | public static void Main(string[] args) 10 | { 11 | CreateWebHostBuilder(args).Build().Run(); 12 | } 13 | 14 | public static IWebHostBuilder CreateWebHostBuilder(string[] args) => 15 | WebHost.CreateDefaultBuilder(args) 16 | .UseStartup(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /csharp-arrays/CopyArrayElements/BenchmarkRunner/BenchmarkRunner.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /csharp-arrays/SumUpArrayElements/BenchmarkRunner/BenchmarkRunner.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /numbers-csharp/ConvertString2Int/BenchmarkRunner/BenchmarkRunner.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /strings-csharp/StringBuilderType/BenchmarkRunner/BenchmarkRunner.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /async-csharp/CancellationTokensIAsyncEnumerable/CancellationIAsyncEnumerable/CancellationToken.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace CancellationIAsyncEnumerable 4 | { 5 | public class CancellationToken 6 | { 7 | public bool IsCancelled { get; set; } 8 | 9 | public void Cancel() 10 | { 11 | IsCancelled = true; 12 | } 13 | 14 | public void ThrowIfCancelled() 15 | { 16 | if (IsCancelled) 17 | { 18 | throw new OperationCanceledException(); 19 | } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /csharp-arrays/FindTheMaximumValue/BenchmarkRunner/BenchmarkRunner.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /csharp-intermediate-topics/CompositionVsInheritance/CompositionVsInheritance/House.cs: -------------------------------------------------------------------------------- 1 | namespace CompositionVsInheritance 2 | { 3 | public class House 4 | { 5 | private readonly Ceiling _ceiling; 6 | private readonly Floor _floor; 7 | public string Color { get; set; } 8 | 9 | public House() 10 | { 11 | _ceiling = new Ceiling(); 12 | _floor = new Floor(); 13 | } 14 | 15 | public string GetCeiling() => _ceiling.BuildCeiling(); 16 | 17 | public string GetFloor() => _floor.BuildFloor(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /dotnet-projects/NugetUsingCLI/Tests/ConverterTests.cs: -------------------------------------------------------------------------------- 1 | using CodeMaze.Utilities.TemperatureConverter; 2 | using Xunit; 3 | 4 | namespace Tests 5 | { 6 | public class ConverterTests 7 | { 8 | [Fact] 9 | public void WhenProvidedDegreeCelsiusValue_ReturnsFahrenheitValue() 10 | { 11 | Assert.Equal(77, Converter.ToFahrenheit(25)); 12 | } 13 | 14 | [Fact] 15 | public void WhenProvidedFahrenheitValue_ReturnsDegreeCelsiusValue() 16 | { 17 | Assert.Equal(25, Converter.ToDegreeCelsius(77)); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /dependency-injection-tools/AutoFacImplementationWeb/AutoFacImplementationWeb/Implementation/PersonBusiness.cs: -------------------------------------------------------------------------------- 1 | using AutoFacImplementationWeb.Interface; 2 | 3 | using System.Collections.Generic; 4 | 5 | namespace AutoFacImplementationWeb.Implementation 6 | { 7 | public class PersonBusiness : IPersonBusiness 8 | { 9 | public List GetPersonList() 10 | { 11 | List personList = new List(); 12 | personList.Add("Code Maze"); 13 | personList.Add("John Doe"); 14 | return personList; 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /aspnetcore-webapi/SerializationDemo/SerializationDemo.EmployeeApi/SerializationDemo.EmployeeApi.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /csharp-arrays/SliceArrays/SliceArrayTests/SliceArrayTests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /json-csharp/DeserializeComplexJsonObject/BenchmarkRunner/BenchmarkRunner.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | enable 7 | Exe 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /json-csharp/JsonSerializationOfEnumAsString/JsonSerialization.Native.EnumAsStringTests/PropertySelection/PropertySelectionUnitTest.cs: -------------------------------------------------------------------------------- 1 | namespace JsonSerialization.Native.EnumAsStringTests.PropertySelection; 2 | 3 | public class PropertySelectionUnitTest : UnitTestBase 4 | { 5 | [Fact] 6 | public void GivenEnumProperty_WhenDecoratedWithEnumConverter_ThenSerializeAsString() 7 | { 8 | var json = Serialize(Canvas.Poster); 9 | 10 | Assert.Equal("{\"Name\":\"Poster\",\"BackColor\":\"LightGray\",\"Medium\":0,\"Pen\":{\"Name\":\"Simple\",\"Color\":3}}", json); 11 | } 12 | } -------------------------------------------------------------------------------- /json-csharp/JsonSerializationOfEnumAsString/JsonSerialization.Native.EnumAsStringTests/TypeSelection/TypeSelectionUnitTest.cs: -------------------------------------------------------------------------------- 1 | namespace JsonSerialization.Native.EnumAsStringTests.TypeSelection; 2 | 3 | public class CustomSerializationUnitTest : UnitTestBase 4 | { 5 | [Fact] 6 | public void GivenEnumType_WhenDecoratedWithEnumConverter_ThenSerializeAllInstancesAsString() 7 | { 8 | var json = Serialize(Canvas.Poster); 9 | 10 | Assert.Equal("{\"Name\":\"Poster\",\"BackColor\":\"LightGray\",\"Medium\":0,\"Pen\":{\"Name\":\"Simple\",\"Color\":\"Red\"}}", json); 11 | } 12 | } -------------------------------------------------------------------------------- /json-csharp/JsonSerializationOfEnumAsString/JsonSerialization.Newtonsoft.EnumAsStringTests/PropertySelection/PropertySelectionUnitTest.cs: -------------------------------------------------------------------------------- 1 | namespace JsonSerialization.Newtonsoft.EnumAsStringTests.PropertySelection; 2 | 3 | public class PropertySelectionUnitTest : UnitTestBase 4 | { 5 | [Fact] 6 | public void GivenEnumProperty_WhenDecoratedWithEnumConverter_ThenSerializeAsString() 7 | { 8 | var json = Serialize(Canvas.Poster); 9 | 10 | Assert.Equal("{\"Name\":\"Poster\",\"BackColor\":\"LightGray\",\"Medium\":0,\"Pen\":{\"Name\":\"Simple\",\"Color\":3}}", json); 11 | } 12 | } -------------------------------------------------------------------------------- /numbers-csharp/ConvertString2Int/ConvertString2Int/CustomConvert.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace ConvertString2Int 8 | { 9 | public static class CustomConvert 10 | { 11 | public static int Parse(string strVal) 12 | { 13 | var num = 0; 14 | 15 | for (int i = 0; i < strVal.Length; i++) 16 | { 17 | num = num * 10 + (strVal[i] - '0'); 18 | } 19 | 20 | return num; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /aspnetcore-features/CustomAttributes/CustomAttributes/TaskDescriptorAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace CustomAttributes 8 | { 9 | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct)] 10 | public class TaskDescriptorAttribute : Attribute 11 | { 12 | public string? Name { get; set; } 13 | public string? Description { get; set; } 14 | public bool NeedsManager { get; set; } 15 | public int DeveloperCount { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /json-csharp/JsonSerializationOfEnumAsString/JsonSerialization.Native.EnumAsString.WebApi/Controllers/CanvasController.cs: -------------------------------------------------------------------------------- 1 | using JsonSerialization.EnumAsString.Models; 2 | using Microsoft.AspNetCore.Mvc; 3 | 4 | namespace JsonSerialization.Native.EnumAsString.WebApi.Controllers; 5 | 6 | [ApiController] 7 | [Route("[controller]")] 8 | public class CanvasController : ControllerBase 9 | { 10 | [HttpGet("poster")] 11 | public Canvas GetPoster() => Canvas.Poster; 12 | 13 | [HttpGet("schedule")] 14 | public object GetSchedule() => new { Description = "Exhibition", Day = DayOfWeek.Monday }; 15 | } -------------------------------------------------------------------------------- /json-csharp/JsonSerializationOfEnumAsString/JsonSerialization.Native.EnumAsStringTests/DefaultSerializationUnitTest.cs: -------------------------------------------------------------------------------- 1 | using JsonSerialization.EnumAsString.Models; 2 | 3 | namespace JsonSerialization.Native.EnumAsStringTests; 4 | 5 | public class DefaultSerializationUnitTest : UnitTestBase 6 | { 7 | [Fact] 8 | public void GivenEnum_WhenTreatedBySerializer_ThenByDefaultSerializeAsInteger() 9 | { 10 | var json = Serialize(Canvas.Poster); 11 | 12 | Assert.Equal("{\"Name\":\"Poster\",\"BackColor\":1,\"Medium\":0,\"Pen\":{\"Name\":\"Simple\",\"Color\":3}}", json); 13 | } 14 | } -------------------------------------------------------------------------------- /json-csharp/JsonSerializationOfEnumAsString/JsonSerialization.Newtonsoft.EnumAsStringTests/TypeSelection/TypeSelectionUnitTest.cs: -------------------------------------------------------------------------------- 1 | namespace JsonSerialization.Newtonsoft.EnumAsStringTests.TypeSelection; 2 | 3 | public class CustomSerializationUnitTest : UnitTestBase 4 | { 5 | [Fact] 6 | public void GivenEnumType_WhenDecoratedWithEnumConverter_ThenSerializeAllInstancesAsString() 7 | { 8 | var json = Serialize(Canvas.Poster); 9 | 10 | Assert.Equal("{\"Name\":\"Poster\",\"BackColor\":\"LightGray\",\"Medium\":0,\"Pen\":{\"Name\":\"Simple\",\"Color\":\"Red\"}}", json); 11 | } 12 | } -------------------------------------------------------------------------------- /aspnetcore-webapi/HealthChecksAspNetCore/HealthChecksAspNetCore/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "ConnectionStrings": { 3 | "DefaultConnection": "Data Source=localhost,1433;Initial Catalog=master;User Id=sa;Password=MyV3ryStrong@Passw0rd" 4 | }, 5 | "Logging": { 6 | "LogLevel": { 7 | "Default": "Information", 8 | "Microsoft.AspNetCore": "Warning" 9 | } 10 | }, 11 | "HealthChecksUI": { 12 | "HealthChecks": [ 13 | { 14 | "Name": "My Health Checks", 15 | "Uri": "/health" 16 | } 17 | ], 18 | "EvaluationTimeInSeconds": 5 19 | }, 20 | "AllowedHosts": "*" 21 | } 22 | -------------------------------------------------------------------------------- /dependency-injection-tools/AutoFacImplementationWeb/Test.AutoFacImplementationWeb/PersonBusinessTestImplementation.cs: -------------------------------------------------------------------------------- 1 | using AutoFacImplementationWeb.Interface; 2 | 3 | using System.Collections.Generic; 4 | 5 | namespace Test.AutoFacImplementationWeb 6 | { 7 | public class PersonBusinessTestImplementation : IPersonBusiness 8 | { 9 | public List GetPersonList() 10 | { 11 | List personList = new List(); 12 | personList.Add("Code Maze"); 13 | personList.Add("John Doe"); 14 | return personList; 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /json-csharp/JsonSerializationOfEnumAsString/JsonSerialization.Newtonsoft.EnumAsStringTests/DefaultSerializationUnitTest.cs: -------------------------------------------------------------------------------- 1 | using JsonSerialization.EnumAsString.Models; 2 | 3 | namespace JsonSerialization.Newtonsoft.EnumAsStringTests; 4 | 5 | public class DefaultSerializationUnitTest : UnitTestBase 6 | { 7 | [Fact] 8 | public void GivenEnum_WhenTreatedBySerializer_ThenByDefaultSerializeAsInteger() 9 | { 10 | var json = Serialize(Canvas.Poster); 11 | 12 | Assert.Equal("{\"Name\":\"Poster\",\"BackColor\":1,\"Medium\":0,\"Pen\":{\"Name\":\"Simple\",\"Color\":3}}", json); 13 | } 14 | } -------------------------------------------------------------------------------- /csharp-arrays/PopulateArrayWithTheSameValue/BenchmarkRunner/BenchmarkRunner.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /csharp-intermediate-topics/CompositionVsInheritance/CompositionVsInheritance/Program.cs: -------------------------------------------------------------------------------- 1 | namespace CompositionVsInheritance 2 | { 3 | public class Program 4 | { 5 | static void Main(string[] args) 6 | { 7 | var house1 = new GlassHouse(); 8 | house1.Color = "Transparent"; 9 | house1.GetCeiling(); 10 | house1.GetAddress(); 11 | house1.WarningSign(); 12 | 13 | var house2 = new BrickHouse(); 14 | house2.Color = "Red"; 15 | house2.GetFloor(); 16 | house2.GetAddress(); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /json-csharp/JsonSerializationOfEnumAsString/JsonSerialization.Newtonsoft.EnumAsString.WebApi/Controllers/CanvasController.cs: -------------------------------------------------------------------------------- 1 | using JsonSerialization.EnumAsString.Models; 2 | using Microsoft.AspNetCore.Mvc; 3 | 4 | namespace JsonSerialization.Newtonsoft.EnumAsString.WebApi.Controllers; 5 | 6 | [ApiController] 7 | [Route("[controller]")] 8 | public class CanvasController : ControllerBase 9 | { 10 | [HttpGet("poster")] 11 | public Canvas GetPoster() => Canvas.Poster; 12 | 13 | [HttpGet("schedule")] 14 | public object GetSchedule() => new { Description = "Exhibition", Day = DayOfWeek.Monday }; 15 | } -------------------------------------------------------------------------------- /dotnet-datetime/CheckDateTimeIsWeekend/CheckDateTime.Tests/CheckDateTime.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /authorization-dotnet/UsingAuthorizationWithSwagger/Test/Helpers/HelperClass.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using System.Net.Http; 3 | using System.Text; 4 | using System.Threading.Tasks; 5 | using UsingAuthorizationWithSwagger.Models; 6 | 7 | namespace Test.Helpers 8 | { 9 | public static class HelperClass 10 | { 11 | public static class ContentHelper 12 | { 13 | public static StringContent GetStringContent(object obj) 14 | => new StringContent(JsonConvert.SerializeObject(obj), Encoding.Default, "application/json"); 15 | } 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /csharp-basic-topics/ParamsKeyword/ParamsKeyword/ParamsKeyword.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | 7 | false 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /dotnet-datetime/DateTimeFormatInCSharp/Test/Test.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | 7 | false 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /numbers-csharp/IntParseVsConvertToInt/Tests/Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | 7 | false 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /aspnetcore-webapi/MassTransitRabbitMQ/Consumer/Consumer.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /files-csharp/WriteToCsv/WriteToCsv/Person.cs: -------------------------------------------------------------------------------- 1 | using CsvHelper.Configuration.Attributes; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace WritingCSV 9 | { 10 | public class Person 11 | { 12 | [Name("Identifier")] 13 | [Index(0)] 14 | public int Id { get; set; } 15 | [Index(2)] 16 | public string Name { get; set; } 17 | [Index(1)] 18 | public bool IsLiving { get; set; } 19 | [Format("yyyy-MM-dd")] 20 | public DateTime DateOfBirth { get; set; } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /strings-csharp/AddParametersToString/AddParametersToStringTests/AddParametersToStringTests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /csharp-design-patterns/VisitorPattern/.editorconfig: -------------------------------------------------------------------------------- 1 | [*.cs] 2 | 3 | # CS8509: The switch expression does not handle all possible values of its input type (it is not exhaustive). 4 | dotnet_diagnostic.CS8509.severity = error 5 | 6 | # IDE0008: Use explicit type 7 | csharp_style_var_elsewhere = true 8 | 9 | # IDE0008: Use explicit type 10 | dotnet_diagnostic.IDE0008.severity = error 11 | 12 | # IDE0008: Use explicit type 13 | csharp_style_var_when_type_is_apparent = true 14 | 15 | # IDE0007: Use implicit type 16 | dotnet_diagnostic.IDE0007.severity = warning 17 | 18 | # IDE0007: Use implicit type 19 | csharp_style_var_for_built_in_types = true 20 | -------------------------------------------------------------------------------- /strings-csharp/ConvertStringToBoolean/ConvertStringToBooleanTests/ConvertStringToBooleanTests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /aspnetcore-features/CustomAttributes/CustomAttributes/DeveloperTaskAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace CustomAttributes 8 | { 9 | [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] 10 | public class DeveloperTaskAttribute : Attribute 11 | { 12 | public DeveloperTaskAttribute(Priorities priority) 13 | { 14 | Priority = priority; 15 | } 16 | 17 | public Priorities Priority { get; set; } 18 | public string? Description { get; set; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /aspnetcore-webapi/SerializationDemo/SerializationDemo.Client/SerializationDemo.Client.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /csharp-basic-topics/PatternMatchingInCSharp/PropertyPatternsDemo/PropertyPatternsTest.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /json-csharp/JsonSerializationOfEnumAsString/JsonSerialization.Native.EnumAsString.MinimalApi/Program.cs: -------------------------------------------------------------------------------- 1 | using JsonSerialization.EnumAsString.Models; 2 | using Microsoft.AspNetCore.Http.Json; 3 | using System.Text.Json.Serialization; 4 | 5 | var builder = WebApplication.CreateBuilder(args); 6 | builder.Services.Configure(options => 7 | { 8 | options.SerializerOptions.Converters.Add(new JsonStringEnumConverter()); 9 | }); 10 | 11 | var app = builder.Build(); 12 | 13 | app.MapGet("/poster", () => Canvas.Poster); 14 | app.MapGet("/schedule", () => new { Description = "Exhibition", Day = DayOfWeek.Monday }); 15 | 16 | app.Run(); -------------------------------------------------------------------------------- /aspnetcore-webapi/RateLimitingDemo/RateLimitingDemo.UsingAspNetCoreRateLimitPackage/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*", 9 | "IpRateLimiting": { 10 | "EnableEndpointRateLimiting": true, 11 | "StackBlockedRequests": false, 12 | "RealIPHeader": "X-Real-IP", 13 | "ClientIdHeader": "X-ClientId", 14 | "HttpStatusCode": 429, 15 | "GeneralRules": [ 16 | { 17 | "Endpoint": "GET:/products", 18 | "Period": "5s", 19 | "Limit": 2 20 | } 21 | ] 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /authorization-dotnet/UsingAuthorizationWithSwagger/UsingAuthorizationWithSwagger/UsingAuthorizationWithSwagger.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /numbers-csharp/README.md: -------------------------------------------------------------------------------- 1 | ## Numbers in C# 2 | 3 | This section contains the topics related numbers (parsing, conversion, random numbers...) 4 | ### Relevant articles: 5 | 6 | - [Generate Random Double Numbers in a Range in C#](https://code-maze.com/csharp-random-double-range/) 7 | - [How to Generate Random Numbers From a Range in C#](https://code-maze.com/csharp-generate-random-numbers-range/) 8 | - [Difference Between int.Parse() and Convert.ToInt32() in C#](https://code-maze.com/int-parse-vs-convert-toint32-csharp/) 9 | - [Math Class in C#](https://code-maze.com/csharp-math/) 10 | - [Parse and TryParse in C#](https://code-maze.com/csharp-parse-tryparse/) 11 | -------------------------------------------------------------------------------- /collections-csharp/DictionaryGetValueByIndex/DictionaryTests/DictionaryTests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | 7 | false 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /dotnet-datetime/DateTimeNowVsDateTimeUtcNow/DateTimeNow.Tests/DateTimeNow.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | 7 | false 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /numbers-csharp/ConvertString2Int/ConvertString2IntTests/ConvertString2IntTests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | 7 | false 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /strings-csharp/ConvertInt2String/ConvertInt2StringTests/ConvertInt2StringTests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | 7 | false 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /strings-csharp/StringBuilderCheckEmpty/StringBuilderTests/StringBuilderTests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | 7 | false 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /dotnet-client-libraries/Google Sheets API/GoogleSheetsAPI/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Hosting; 2 | using Microsoft.Extensions.Hosting; 3 | 4 | namespace GoogleSheetsAPI 5 | { 6 | public class Program 7 | { 8 | public static void Main(string[] args) 9 | { 10 | CreateHostBuilder(args).Build().Run(); 11 | } 12 | 13 | public static IHostBuilder CreateHostBuilder(string[] args) => 14 | Host.CreateDefaultBuilder(args) 15 | .ConfigureWebHostDefaults(webBuilder => 16 | { 17 | webBuilder.UseStartup(); 18 | }); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /exception-handling/ThrowVsThrowEx/ThrowVsThrowEx/ThrowVsThrowEx.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | None 7 | false 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /aspnetcore-features/InMemoryCaching/InMemoryCacheExample/Models/Employee.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel.DataAnnotations; 2 | using System.ComponentModel.DataAnnotations.Schema; 3 | 4 | namespace InMemoryCacheExample.Models 5 | { 6 | public class Employee 7 | { 8 | [Key] 9 | [DatabaseGenerated(DatabaseGeneratedOption.Identity)] 10 | public long EmployeeId { get; set; } 11 | public string? FirstName { get; set; } 12 | public string? LastName { get; set; } 13 | public DateTime DateOfBirth { get; set; } 14 | public string? PhoneNumber { get; set; } 15 | public string? Email { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /csharp-advanced-topics/DelegatesInCsharp/Tests/Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /aspnetcore-webapi/MassTransitRabbitMQ/Producer/Producer.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /dotnet-datetime/GetDatePartFromDateTime/GetDatePartFromDateTime.Tests/GetDatePartFromDateTime.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | 7 | false 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /dotnet-projects/ProjectTemplates/codemazeapi/Controllers/ValuesController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Http; 2 | using Microsoft.AspNetCore.Mvc; 3 | 4 | namespace codemazeapi.Controllers 5 | { 6 | [Route("api/[controller]")] 7 | [ApiController] 8 | public class ValuesController : ControllerBase 9 | { 10 | public IActionResult Get() 11 | { 12 | return Ok("Hi from {DOMAIN} Web API Template"); 13 | } 14 | 15 | #if (EnableContactPage) 16 | [Route("about")] 17 | public IActionResult About() 18 | { 19 | return Ok("visit us at https://code-maze.com/about/"); 20 | } 21 | #endif 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /strings-csharp/ConvertCharArray2String/ConvertCharArray2StringTests/ConvertCharArray2StringTests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | 7 | false 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /dotnet-testing/NUnitProject/NUnitProject.Tests/NUnitProject.UnitTests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /csharp-basic-topics/TypesOfInheritanceInCSharp/TypesOfInheritanceInCSharp/AndroidSmartphone.cs: -------------------------------------------------------------------------------- 1 | namespace TypesOfInheritanceInCSharp; 2 | 3 | public class AndroidSmartphone : Smartphone 4 | { 5 | public AndroidSmartphone() : base(operatingSystem: "Android") 6 | { 7 | } 8 | 9 | public override sealed void GetDescription() 10 | { 11 | Console.WriteLine($"This Android smarphone is {Inches} inches big, and {InstalledApps.Count} apps downloaded from Google Store"); 12 | } 13 | 14 | public void DownloadAppFromStore(string app) 15 | { 16 | InstalledApps.Add(app); 17 | Console.WriteLine($"I downloaded {app} from Google Store"); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /threads-csharp/MultithreadingInCsharp/RunCodeInNewThreadApplication/PdfValidator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | 4 | namespace RunCodeInNewThreadApplication 5 | { 6 | public class PdfValidator 7 | { 8 | internal int DelaySeconds { get; set; } = 5; 9 | public ValidationResult ValidateFile() 10 | { 11 | //let's pretend this is a long, CPU-intensive work. 12 | Thread.Sleep(TimeSpan.FromSeconds(DelaySeconds)); 13 | return new ValidationResult(); 14 | } 15 | } 16 | 17 | public class ValidationResult 18 | { 19 | public string ResultCode { get; } = Guid.NewGuid().ToString(); 20 | } 21 | } -------------------------------------------------------------------------------- /aspnetcore-webapi/RateLimitingDemo/RateLimitingDemo.UsingCustomMiddleware/RateLimitingDemo.UsingCustomMiddleware.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /dotnet-logging/LoggingAPI/LoggingAPI/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Logging; 2 | 3 | namespace LoggingAPI 4 | { 5 | public class Program 6 | { 7 | static void Main(string[] args) 8 | { 9 | ILoggerFactory loggerFactory = LoggerFactory.Create(builder => 10 | { 11 | builder.AddConsole(); 12 | builder.AddDebug(); 13 | }); 14 | 15 | ILogger logger = loggerFactory.CreateLogger(); 16 | var student = new Student("John", "IT", logger); 17 | 18 | var department = new Department("IT", "Information Technology", loggerFactory); 19 | 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /aspnetcore-webapi/WorkingWithRestSharp/WorkingWithRestSharp/Program.cs: -------------------------------------------------------------------------------- 1 | var builder = WebApplication.CreateBuilder(args); 2 | 3 | // Add services to the container. 4 | 5 | builder.Services.AddControllers(); 6 | // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle 7 | builder.Services.AddEndpointsApiExplorer(); 8 | builder.Services.AddSwaggerGen(); 9 | 10 | var app = builder.Build(); 11 | 12 | // Configure the HTTP request pipeline. 13 | if (app.Environment.IsDevelopment()) 14 | { 15 | app.UseSwagger(); 16 | app.UseSwaggerUI(); 17 | } 18 | 19 | app.UseHttpsRedirection(); 20 | 21 | app.UseAuthorization(); 22 | 23 | app.MapControllers(); 24 | 25 | app.Run(); 26 | -------------------------------------------------------------------------------- /dotnet-projects/NugetUsingCLI/CodeMaze.Utilities.TemperatureConverter/CodeMaze.Utilities.TemperatureConverter.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | enable 7 | CodeMaze.Utilities.TemperatureConverter 8 | 1.0.0 9 | Muhammed Saleem 10 | Code-Maze 11 | Temperature,Converter 12 | This package will help in converting temperature between Fahrenheit and Degree Celsius 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /numbers-csharp/ConvertString2Int/ConvertString2Int/Program.cs: -------------------------------------------------------------------------------- 1 | using ConvertString2Int; 2 | 3 | var stringValue = "3"; 4 | var number = 0; 5 | 6 | number = int.Parse(stringValue); 7 | Console.WriteLine($"Converted '{stringValue}' to {number} using 'int.Parse()'"); 8 | 9 | int.TryParse(stringValue, out number); 10 | Console.WriteLine($"Converted '{stringValue}' to {number} using 'int.TryParse()'"); 11 | 12 | number = Convert.ToInt32(stringValue); 13 | Console.WriteLine($"Converted '{stringValue}' to {number} using 'Convert.ToInt32()'"); 14 | 15 | number = CustomConvert.Parse(stringValue); 16 | Console.Write($"Converted '{stringValue}' to {number} using 'CustomConvert.Parse()'"); 17 | 18 | Console.ReadKey(); -------------------------------------------------------------------------------- /aspnetcore-features/CustomAttributes/CustomAttributes/Program.cs: -------------------------------------------------------------------------------- 1 | using CustomAttributes; 2 | 3 | Console.WriteLine($"Calling {nameof(CustomAttributeHelper.GetAttribute)} method...\n"); 4 | CustomAttributeHelper.GetAttribute(typeof(MyTasks), typeof(TaskDescriptorAttribute)); 5 | 6 | Console.WriteLine(); 7 | 8 | Console.WriteLine($"Calling {nameof(CustomAttributeHelper.GetAttributesOfMethods)} method for the {nameof(MyTasks)} class...\n"); 9 | CustomAttributeHelper.GetAttributesOfMethods(typeof(MyTasks)); 10 | 11 | Console.WriteLine($"Calling {nameof(CustomAttributeHelper.GetAttributesOfMethods)} method for the {nameof(YourTasks)} class...\n"); 12 | CustomAttributeHelper.GetAttributesOfMethods(typeof(YourTasks)); -------------------------------------------------------------------------------- /threads-csharp/MultithreadingInCsharp/RunCodeInNewThreadApplication/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | [assembly: ThemeInfo( 4 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 5 | //(used if a resource is not found in the page, 6 | // or application resource dictionaries) 7 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 8 | //(used if a resource is not found in the page, 9 | // app, or any theme specific resource dictionaries) 10 | )] 11 | -------------------------------------------------------------------------------- /csharp-advanced-topics/EventsInCsharp/EventsInCsharp/Services/FoodOrderingService.cs: -------------------------------------------------------------------------------- 1 | using EventsInCsharp.EventArguments; 2 | using EventsInCsharp.Model; 3 | using System; 4 | 5 | namespace EventsInCsharp.Services 6 | { 7 | public class FoodOrderingService 8 | { 9 | public event EventHandler FoodPrepared; 10 | 11 | public void PrepareOrder(Order order) 12 | { 13 | Console.WriteLine($"Preparing your order '{order.Item}', please wait..."); 14 | 15 | OnFoodPrepared(order); 16 | } 17 | 18 | protected virtual void OnFoodPrepared(Order order) 19 | { 20 | FoodPrepared?.Invoke(this, new FoodPreparedEventArgs { Order = order }); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /csharp-design-patterns/ObserverPattern/Tests/Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /json-csharp/JsonSerializationOfEnumAsString/JsonSerialization.Newtonsoft.EnumAsStringTests/UnitTestBase.cs: -------------------------------------------------------------------------------- 1 | global using Xunit; 2 | global using Newtonsoft.Json; 3 | global using Newtonsoft.Json.Converters; 4 | global using Newtonsoft.Json.Serialization; 5 | 6 | namespace JsonSerialization.Newtonsoft.EnumAsStringTests; 7 | 8 | public abstract class UnitTestBase 9 | { 10 | public static string Serialize(object obj) 11 | { 12 | return JsonConvert.SerializeObject(obj); 13 | } 14 | 15 | public static string SerializeWithStringEnum(object obj) 16 | { 17 | var converter = new StringEnumConverter(); 18 | return JsonConvert.SerializeObject(obj, converter); 19 | } 20 | } -------------------------------------------------------------------------------- /collections-csharp/SortedListInCSharp/Tests/Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /dependency-injection-tools/AutoFacImplementationWeb/AutoFacImplementationWeb/Controllers/StringHelperController.cs: -------------------------------------------------------------------------------- 1 | using AutoFacImplementationWeb.Interface; 2 | 3 | using Microsoft.AspNetCore.Mvc; 4 | 5 | namespace AutoFacImplementationWeb.Controllers 6 | { 7 | [Route("api/[controller]")] 8 | [ApiController] 9 | public class StringHelperController : ControllerBase 10 | { 11 | public IStringBusiness StringBusiness { get; set; } 12 | 13 | [HttpGet] 14 | [Route("getUpperCase/{fullName}")] 15 | public string GetUpperCase(string fullName) 16 | { 17 | var upper = StringBusiness.StringToUpper(fullName); 18 | return upper; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /csharp-basic-topics/ExpressionBodiedMembersInCsharp/Test/SquareTests.cs: -------------------------------------------------------------------------------- 1 | using ExpressionBodiedMembersInCsharp; 2 | using Microsoft.VisualStudio.TestTools.UnitTesting; 3 | 4 | namespace Test 5 | { 6 | [TestClass] 7 | public class SquareTests 8 | { 9 | [TestMethod] 10 | public void WhenCalculateAreaMethodCalled_AreaIsReturned() 11 | { 12 | var square = new Square(2); 13 | Assert.AreEqual(4, square.CalculateArea()); 14 | } 15 | 16 | [TestMethod] 17 | public void WhenAreaPropertyIsGet_AreaIsReturned() 18 | { 19 | var square = new SquareRefactored(4); 20 | Assert.AreEqual(16, square.Area); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /csharp-intermediate-topics/README.md: -------------------------------------------------------------------------------- 1 | ## Intermediate Topics in C# 2 | 3 | This section contains the topics considered intermediate level in C#. 4 | 5 | ### Relevant articles: 6 | 7 | - [Composition vs Inheritance in C#](https://code-maze.com/csharp-composition-vs-inheritance/) 8 | - [Difference Between ValueTuple and Tuple in C#](https://code-maze.com/csharp-valuetuple-vs-tuple/) 9 | - [Operator Overloading in C#](https://code-maze.com/csharp-operator-overloading/) 10 | - [Polymorphism in C#](https://code-maze.com/csharp-polymorphism/) 11 | - [Records in C#](https://code-maze.com/csharp-records/) 12 | - [Static Classes in C#](https://code-maze.com/static-classes-csharp/) 13 | - [Tuple in C#](https://code-maze.com/csharp-tuple/) 14 | -------------------------------------------------------------------------------- /dotnet-logging/LoggingAPI/LoggingAPI/LoggingAPI.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /dotnet-projects/ProjectTemplates/codemazeapi/Program.cs: -------------------------------------------------------------------------------- 1 | var builder = WebApplication.CreateBuilder(args); 2 | 3 | // Add services to the container. 4 | 5 | builder.Services.AddControllers(); 6 | // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle 7 | builder.Services.AddEndpointsApiExplorer(); 8 | builder.Services.AddSwaggerGen(); 9 | 10 | var app = builder.Build(); 11 | 12 | // Configure the HTTP request pipeline. 13 | if (app.Environment.IsDevelopment()) 14 | { 15 | app.UseSwagger(); 16 | app.UseSwaggerUI(); 17 | } 18 | 19 | app.UseHttpsRedirection(); 20 | 21 | app.UseAuthorization(); 22 | 23 | app.MapControllers(); 24 | 25 | app.Run(); 26 | 27 | 28 | public partial class Program { } -------------------------------------------------------------------------------- /strings-csharp/README.md: -------------------------------------------------------------------------------- 1 | ## Strings in C# 2 | 3 | This section contains the topics related to strings (parsing, conversion, other string operations, StringBuilder...) 4 | ### Relevant articles: 5 | 6 | - [How to Convert Char Array to String in C#](https://code-maze.com/csharp-convert-char-array-to-string/) 7 | - [How to Convert Int to String in C#](https://code-maze.com/csharp-convert-int-to-string/) 8 | - [How to Convert String to Bool in C#](https://code-maze.com/csharp-convert-string-to-bool/) 9 | - [How to Convert String from Title Case to camelCase in C#](https://code-maze.com/csharp-convert-string-titlecase-camelcase/) 10 | - [How to Check if StringBuilder Is Empty](https://code-maze.com/csharp-stringbuilder-check-if-empty/) 11 | -------------------------------------------------------------------------------- /xml-csharp/XMLSerializationInCsharp/XMLSerializationInCsharp/XMLSerialization_v2.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace XMLSerializationInCsharp_v2 4 | { 5 | public class Patient 6 | { 7 | public int ID { get; set; } 8 | public string FirstName { get; set; } 9 | public string LastName { get; set; } 10 | public DateTime Birthday { get; set; } 11 | public int RoomNo { get; set; } 12 | public Address HomeAddress { get; set; } 13 | } 14 | 15 | public class Address 16 | { 17 | public string Street { get; set; } 18 | public string Zip { get; set; } 19 | public string City { get; set; } 20 | public string Country { get; set; } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /xml-csharp/XMLSerializationInCsharp/XMLSerializationInCsharp/XMLSerialization_v5.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Xml.Serialization; 3 | 4 | namespace XMLSerializationInCsharp_v5 5 | { 6 | [XmlInclude(typeof(Doctor))] 7 | [XmlInclude(typeof(Patient))] 8 | public class Person 9 | { 10 | public int ID { get; set; } 11 | public string FirstName { get; set; } 12 | public string LastName { get; set; } 13 | public DateTime Birthday { get; set; } 14 | } 15 | 16 | public class Doctor: Person 17 | { 18 | public string Specialization { get; set; } 19 | } 20 | 21 | public class Patient: Person 22 | { 23 | public int RoomNo { get; set; } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /json-csharp/JsonSerializationOfEnumAsString/JsonSerialization.EnumAsString.Models/Canvas.cs: -------------------------------------------------------------------------------- 1 | namespace JsonSerialization.EnumAsString.Models; 2 | 3 | public class Canvas 4 | { 5 | public static Canvas Poster 6 | => new() { Name = "Poster", BackColor = Color.LightGray, Pen = new("Simple", Color.Red) }; 7 | 8 | public string? Name { get; set; } 9 | 10 | public Color BackColor { get; set; } 11 | 12 | public Medium Medium { get; set; } 13 | 14 | public Pen? Pen { get; set; } 15 | } 16 | 17 | public record struct Pen(string Name, Color Color); 18 | 19 | public enum Color 20 | { 21 | White, LightGray, DarkGray, Red 22 | } 23 | 24 | public enum Medium 25 | { 26 | Water, Oil 27 | } -------------------------------------------------------------------------------- /json-csharp/JsonSerializationOfEnumAsString/JsonSerialization.Native.EnumAsStringTests/UnitTestBase.cs: -------------------------------------------------------------------------------- 1 | global using Xunit; 2 | global using System.Text.Json; 3 | global using System.Text.Json.Serialization; 4 | 5 | namespace JsonSerialization.Native.EnumAsStringTests; 6 | 7 | public abstract class UnitTestBase 8 | { 9 | public static string Serialize(object obj) 10 | { 11 | return JsonSerializer.Serialize(obj); 12 | } 13 | 14 | public static string SerializeWithStringEnum(object obj) 15 | { 16 | var options = new JsonSerializerOptions(); 17 | options.Converters.Add(new JsonStringEnumConverter()); 18 | 19 | return JsonSerializer.Serialize(obj, options); 20 | } 21 | } -------------------------------------------------------------------------------- /csharp-advanced-topics/EventsInCsharp/EventsInCsharp/Program.cs: -------------------------------------------------------------------------------- 1 | using EventsInCsharp.Model; 2 | using EventsInCsharp.Services; 3 | using System; 4 | 5 | namespace EventsInCsharp 6 | { 7 | class Program 8 | { 9 | static void Main(string[] args) 10 | { 11 | var order = new Order { Item = "Pizza with extra cheese" }; 12 | 13 | var orderingService = new FoodOrderingService(); 14 | var appService = new AppService(); 15 | var mailService = new MailService(); 16 | 17 | orderingService.FoodPrepared += appService.OnFoodPrepared; 18 | orderingService.FoodPrepared += mailService.OnFoodPrepared; 19 | 20 | orderingService.PrepareOrder(order); 21 | 22 | Console.ReadKey(); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /csharp-arrays/CompareArrays/Tests/Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | 7 | false 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /files-csharp/ByteArrayToFile/ByteArrayToFile/ByteArrayToFileConverter.cs: -------------------------------------------------------------------------------- 1 | namespace ByteArrayToFile; 2 | 3 | public static class ByteArrayToFileConverter 4 | { 5 | public static void SaveByteArrayToFileWithBinaryWriter(byte[] data, string filePath) 6 | { 7 | using var writer = new BinaryWriter(File.OpenWrite(filePath)); 8 | writer.Write(data); 9 | } 10 | public static void SaveByteArrayToFileWithFileStream(byte[] data, string filePath) 11 | { 12 | using var stream = File.Create(filePath); 13 | stream.Write(data, 0, data.Length); 14 | } 15 | 16 | public static void SaveByteArrayToFileWithStaticMethod(byte[] data, string filePath) 17 | => File.WriteAllBytes(filePath, data); 18 | } 19 | --------------------------------------------------------------------------------