This repository has been archived by the owner on Nov 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Veysel MUTLU changes #1756
Open
vmutlu
wants to merge
7
commits into
dotnet-architecture:dev
Choose a base branch
from
vmutlu:dev
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Veysel MUTLU changes #1756
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9fda3b5
Added use of short foreach
vmutlu d20232d
Added short switch usage with .net 5
vmutlu 79d81f5
Replaced ternary operator with switch
vmutlu 4814e1b
The startup.cs class was purified by writing the extensions method in…
vmutlu 7abd857
The repetitive fields in the configuration classes in the Ordering.In…
vmutlu 4bfa1c0
Example short usage patterns have been added. Example abbreviations a…
vmutlu 723bd12
Added editing for sending without writing bearer before token values …
vmutlu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,9 +6,12 @@ public static void FillProductUrl(this CatalogItem item, string picBaseUrl, bool | |
{ | ||
if (item != null) | ||
{ | ||
item.PictureUri = azureStorageEnabled | ||
? picBaseUrl + item.PictureFileName | ||
: picBaseUrl.Replace("[0]", item.Id.ToString()); | ||
// https://www.linkedin.com/feed/update/urn:li:activity:6841055191211491328/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we really need this link to the Linkedin post here? It didn't answer the question what is better to use |
||
item.PictureUri = azureStorageEnabled switch | ||
{ | ||
true => picBaseUrl + item.PictureFileName, | ||
_ => picBaseUrl.Replace("[0]", item.Id.ToString()) | ||
}; | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
src/Services/Identity/Identity.API/Extensions/StartupConfigurationExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
using IdentityServer4.Services; | ||
using Microsoft.AspNetCore.Identity; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.eShopOnContainers.Services.Identity.API; | ||
using Microsoft.eShopOnContainers.Services.Identity.API.Certificates; | ||
using Microsoft.eShopOnContainers.Services.Identity.API.Data; | ||
using Microsoft.eShopOnContainers.Services.Identity.API.Devspaces; | ||
using Microsoft.eShopOnContainers.Services.Identity.API.Models; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using System; | ||
using System.Reflection; | ||
using Microsoft.eShopOnContainers.Services.Identity.API.Services; | ||
|
||
namespace Identity.API.Extensions | ||
{ | ||
public static class StartupConfigurationExtensions | ||
{ | ||
public static void RegisterAppInsights(this IServiceCollection services, IConfiguration configuration) | ||
{ | ||
services.AddApplicationInsightsTelemetry(configuration); | ||
services.AddApplicationInsightsKubernetesEnricher(); | ||
} | ||
|
||
// Add framework services. | ||
public static void ConfigureDatabase(this IServiceCollection services, IConfiguration configuration) | ||
{ | ||
services.AddDbContext<ApplicationDbContext>(options => | ||
options.UseSqlServer(configuration["ConnectionString"], | ||
sqlServerOptionsAction: sqlOptions => | ||
{ | ||
sqlOptions.MigrationsAssembly(typeof(Startup).GetTypeInfo().Assembly.GetName().Name); | ||
//Configuring Connection Resiliency: https://docs.microsoft.com/en-us/ef/core/miscellaneous/connection-resiliency | ||
sqlOptions.EnableRetryOnFailure(maxRetryCount: 15, maxRetryDelay: TimeSpan.FromSeconds(30), errorNumbersToAdd: null); | ||
})); | ||
|
||
services.AddIdentity<ApplicationUser, IdentityRole>() | ||
.AddEntityFrameworkStores<ApplicationDbContext>() | ||
.AddDefaultTokenProviders(); | ||
} | ||
|
||
// Adds IdentityServer | ||
public static void ConfigureIdentityServer(this IServiceCollection services, IConfiguration configuration) | ||
{ | ||
var connectionString = configuration["ConnectionString"]; | ||
var migrationsAssembly = typeof(Startup).GetTypeInfo().Assembly.GetName().Name; | ||
|
||
services.AddIdentityServer(x => | ||
{ | ||
x.IssuerUri = "null"; | ||
x.Authentication.CookieLifetime = TimeSpan.FromHours(2); | ||
}) | ||
.AddDevspacesIfNeeded(configuration.GetValue("EnableDevspaces", false)) | ||
.AddSigningCredential(Certificate.Get()) | ||
.AddAspNetIdentity<ApplicationUser>() | ||
.AddConfigurationStore(options => | ||
{ | ||
options.ConfigureDbContext = builder => builder.UseSqlServer(connectionString, | ||
sqlServerOptionsAction: sqlOptions => | ||
{ | ||
sqlOptions.MigrationsAssembly(migrationsAssembly); | ||
//Configuring Connection Resiliency: https://docs.microsoft.com/en-us/ef/core/miscellaneous/connection-resiliency | ||
sqlOptions.EnableRetryOnFailure(maxRetryCount: 15, maxRetryDelay: TimeSpan.FromSeconds(30), errorNumbersToAdd: null); | ||
}); | ||
}) | ||
.AddOperationalStore(options => | ||
{ | ||
options.ConfigureDbContext = builder => builder.UseSqlServer(connectionString, | ||
sqlServerOptionsAction: sqlOptions => | ||
{ | ||
sqlOptions.MigrationsAssembly(migrationsAssembly); | ||
//Configuring Connection Resiliency: https://docs.microsoft.com/en-us/ef/core/miscellaneous/connection-resiliency | ||
sqlOptions.EnableRetryOnFailure(maxRetryCount: 15, maxRetryDelay: TimeSpan.FromSeconds(30), errorNumbersToAdd: null); | ||
}); | ||
}) | ||
.Services.AddTransient<IProfileService, ProfileService>(); | ||
} | ||
|
||
public static void ConfigureDependecyInjections(this IServiceCollection services) | ||
{ | ||
services.AddTransient<ILoginService<ApplicationUser>, EFLoginService>(); | ||
services.AddTransient<IRedirectService, RedirectService>(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,8 +63,4 @@ | |
</None> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Folder Include="Extensions\" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,8 @@ public ProfileService(UserManager<ApplicationUser> userManager) | |
_userManager = userManager; | ||
} | ||
|
||
//New Method ArgumentNullException.ThrowIfNull (obj) Added to .NET 6 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm sure this source code is not a guide for C# new features, it is more about architecture. |
||
//https://davidshergilashvili.space/2021/09/08/new-method-argumentnullexception-throwifnull-obj-added-to-net-6/ | ||
async public Task GetProfileDataAsync(ProfileDataRequestContext context) | ||
{ | ||
var subject = context.Subject ?? throw new ArgumentNullException(nameof(context.Subject)); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/Services/Ordering/Ordering.Infrastructure/EntityConfigurations/BaseConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
using Microsoft.eShopOnContainers.Services.Ordering.Domain.Seedwork; | ||
|
||
namespace Ordering.Infrastructure.EntityConfigurations | ||
{ | ||
public class BaseConfiguration<TEntity> : IEntityTypeConfiguration<TEntity> where TEntity : Entity | ||
{ | ||
public virtual void Configure(EntityTypeBuilder<TEntity> builder) | ||
{ | ||
builder.Ignore(b => b.DomainEvents); | ||
builder.HasKey(e => e.Id); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the point of the change?