ShopPlatform.Web 1.0.0.0
농산물, 소프트웨어 라이선스와 개발 용역을 직접 판매하는 CodeMaru 직영 쇼핑몰입니다.
로딩중...
검색중...
일치하는것 없음
Program.cs 파일 참조

이 파일의 소스 코드 페이지로 가기

함수

builder.Configuration. AddUserSecrets ("codemaru-oauth-2ba4e1b2")
builder.Services. AddSingleton (shopOpts)
builder.Services. AddDreamineIdentityWeb (authOptions, usersDbPath)
builder.Services. AddSingleton< IShopTenantStore, JsonShopTenantStore > ()
builder.Services. AddScoped< TenantContext > ()
builder.Services. AddSingleton< PaymentKeyProtector > ()
builder.Services. AddSingleton< TenantDbContextFactory > ()
builder.Services. AddHttpClient ()
builder.Services. AddScoped< CartService > ()
builder.Services. AddScoped< ShopCustomerSession > ()
builder.Services. AddScoped< ShopUserContext > ()
builder.Services. AddSingleton< ShopCustomerProfileStore > ()
builder.Services. AddScoped< ShopCustomerLoginSync > ()
builder.Services. AddRazorComponents () .AddInteractiveServerComponents()
builder.Services. AddResponseCompression (o=> o.EnableForHttps=true)
 if (!app::Environment::IsDevelopment())
app. UseForwardedHeaders ()
app. UseResponseCompression ()
app. UseStaticFiles ()
app. UseStaticFiles (new StaticFileOptions { FileProvider=new Microsoft.Extensions.FileProviders.PhysicalFileProvider(shopOpts.ResolvedDataPath), RequestPath="/shop-img" })
app. UseMiddleware< TenantMiddleware > ()
app. UseAuthentication ()
app. UseAuthorization ()
app. UseAntiforgery ()
app. UseMiddleware< OgBotMiddleware > ()
app. MapGet ("/healthz",()=> Results.Text("OK", "text/plain"))
app. MapGet ("/pay/{slug}/return", async(string slug, string paymentKey, string orderId, int amount, IShopTenantStore store, PaymentKeyProtector protector, IHttpClientFactory httpFactory, TenantDbContextFactory dbFactory)=> { var config=await store.GetAsync(slug);if(config==null) return Results.NotFound();IPaymentGateway gateway=config.Payment.IsEnabled ? new TossPaymentGateway(httpFactory.CreateClient(), config.Payment, protector) :new DummyPaymentGateway();var result=await gateway.ConfirmAsync(paymentKey, orderId, amount);if(!result.Succeeded) return Results.Redirect($"/{slug}/checkout?error={Uri.EscapeDataString(result.Error ?? "결제 실패")}");using var db=dbFactory.Create(slug);var order=db.Orders .Include(o=> o.Lines) .FirstOrDefault(o=> o.OrderNo==orderId);if(order !=null) { order.Status="paid";order.TransactionId=result.TransactionId;DeductStock(db, order.Lines);await db.SaveChangesAsync();} return Results.Redirect($"/{slug}/order/{orderId}?paid=1");})
app. MapGet ("/pay/{slug}/fail",(string slug, string? code, string? message)=> Results.Redirect($"/{slug}/checkout?error={Uri.EscapeDataString(message ?? "결제가 취소되었습니다.")}"))
app. MapRazorComponents< ShopPlatform.Components.App > () .AddInteractiveServerRenderMode()
ShopPlatform.Services.OgImageGenerator. EnsureDefault (wwwroot)
await ShopPlatform.Data.ShopSeeder. SeedCodemaruAsync (app.Services.GetRequiredService< TenantDbContextFactory >(), app.Services.GetRequiredService< IShopTenantStore >(), app.Services.GetRequiredService< PaymentKeyProtector >())
app. Run ()
static void DeductStock (TenantDbContext db, IEnumerable< OrderLine > lines)
static string ResolvePath (string? configuredPath, string fallback)

변수

var builder = WebApplication.CreateBuilder(args)
var shopOpts = ShopOptions.From(builder.Configuration)
AuthOptions authOptions
string usersDbPath
var app = builder.Build()
var wwwroot = Path.Combine(app.Environment.ContentRootPath, "wwwroot")

함수 문서화

◆ AddDreamineIdentityWeb()

builder.Services. AddDreamineIdentityWeb ( authOptions ,
usersDbPath  )

다음을 참조함 : authOptions, builder, usersDbPath.

◆ AddHttpClient()

builder.Services. AddHttpClient ( )

다음을 참조함 : builder.

◆ AddRazorComponents()

builder.Services. AddRazorComponents ( )

다음을 참조함 : builder.

◆ AddResponseCompression()

builder.Services. AddResponseCompression ( o ,
o. EnableForHttps = true )

다음을 참조함 : builder.

◆ AddScoped< CartService >()

builder.Services. AddScoped< CartService > ( )

다음을 참조함 : builder.

◆ AddScoped< ShopCustomerLoginSync >()

builder.Services. AddScoped< ShopCustomerLoginSync > ( )

다음을 참조함 : builder.

◆ AddScoped< ShopCustomerSession >()

builder.Services. AddScoped< ShopCustomerSession > ( )

다음을 참조함 : builder.

◆ AddScoped< ShopUserContext >()

builder.Services. AddScoped< ShopUserContext > ( )

다음을 참조함 : builder.

◆ AddScoped< TenantContext >()

builder.Services. AddScoped< TenantContext > ( )

다음을 참조함 : builder.

◆ AddSingleton()

builder.Services. AddSingleton ( shopOpts )

다음을 참조함 : builder, shopOpts.

◆ AddSingleton< IShopTenantStore, JsonShopTenantStore >()

다음을 참조함 : builder.

◆ AddSingleton< PaymentKeyProtector >()

builder.Services. AddSingleton< PaymentKeyProtector > ( )

다음을 참조함 : builder.

◆ AddSingleton< ShopCustomerProfileStore >()

builder.Services. AddSingleton< ShopCustomerProfileStore > ( )

다음을 참조함 : builder.

◆ AddSingleton< TenantDbContextFactory >()

builder.Services. AddSingleton< TenantDbContextFactory > ( )

다음을 참조함 : builder.

◆ AddUserSecrets()

builder.Configuration. AddUserSecrets ( "codemaru-oauth-2ba4e1b2" )

다음을 참조함 : builder.

◆ DeductStock()

void DeductStock ( TenantDbContext db,
IEnumerable< OrderLine > lines )
static

Program.cs 파일의 171 번째 라인에서 정의되었습니다.

172{
173 foreach (var line in lines)
174 {
175 var product = db.Products.Find(line.ProductId);
176 if (product == null || product.IsUnlimitedStock) continue;
177 product.Stock = Math.Max(0, product.Stock - line.Quantity);
178 }
179}

다음에 의해서 참조됨 : MapGet().

이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ EnsureDefault()

ShopPlatform.Services.OgImageGenerator. EnsureDefault ( wwwroot )

다음을 참조함 : wwwroot.

◆ if()

if ( ! app::Environment::IsDevelopment())

Program.cs 파일의 55 번째 라인에서 정의되었습니다.

56{
57 app.UseExceptionHandler("/Error");
58 app.UseHsts();
59}
var app
Definition Program.cs:52

다음을 참조함 : app.

◆ MapGet() [1/3]

app. MapGet ( "/healthz" ,
() ,
Results. Text"OK", "text/plain" )

다음을 참조함 : app.

◆ MapGet() [2/3]

app. MapGet ( "/pay/{slug}/fail" ,
(string slug, string? code, string? message) ,
Results. Redirect$"/{slug}/checkout?error={Uri.EscapeDataString(message ?? "결제가 취소되었습니다.")}" )

다음을 참조함 : app.

◆ MapGet() [3/3]

app. MapGet ( "/pay/{slug}/return" ,
async(string slug, string paymentKey, string orderId, int amount, IShopTenantStore store, PaymentKeyProtector protector, IHttpClientFactory httpFactory, TenantDbContextFactory dbFactory) ,
{ var config=await store.GetAsync(slug);if(config==null) return Results.NotFound();IPaymentGateway gateway=config.Payment.IsEnabled ? new TossPaymentGateway(httpFactory.CreateClient(), config.Payment, protector) :new DummyPaymentGateway();var result=await gateway.ConfirmAsync(paymentKey, orderId, amount);if(!result.Succeeded) return Results.Redirect($"/{slug}/checkout?error={Uri.EscapeDataString(result.Error ?? "결제 실패")}");using var db=dbFactory.Create(slug);var order=db.Orders .Include(o=> o.Lines) .FirstOrDefault(o=> o.OrderNo==orderId);if(order !=null) { order.Status="paid";order.TransactionId=result.TransactionId;DeductStock(db, order.Lines);await db.SaveChangesAsync();} return Results.Redirect($"/{slug}/order/{orderId}?paid=1");}  )

다음을 참조함 : app, ShopPlatform.Payments.IPaymentGateway.ConfirmAsync(), ShopPlatform.Data.TenantDbContextFactory.Create(), DeductStock(), ShopPlatform.Services.IShopTenantStore.GetAsync().

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

◆ MapRazorComponents< ShopPlatform.Components.App >()

app. MapRazorComponents< ShopPlatform.Components.App > ( )

다음을 참조함 : app.

◆ ResolvePath()

string ResolvePath ( string? configuredPath,
string fallback )
static

Program.cs 파일의 218 번째 라인에서 정의되었습니다.

219{
220 if (string.IsNullOrWhiteSpace(configuredPath))
221 {
222 return fallback;
223 }
224
225 return Path.IsPathRooted(configuredPath)
226 ? configuredPath
227 : Path.GetFullPath(Path.Combine(AppContext.BaseDirectory, configuredPath));
228}

◆ Run()

app. Run ( )

다음을 참조함 : app.

◆ SeedCodemaruAsync()

await ShopPlatform.Data.ShopSeeder. SeedCodemaruAsync ( app.Services.GetRequiredService< TenantDbContextFactory > (),
app.Services.GetRequiredService< IShopTenantStore > (),
app.Services.GetRequiredService< PaymentKeyProtector > () )

다음을 참조함 : app.

◆ UseAntiforgery()

app. UseAntiforgery ( )

다음을 참조함 : app.

◆ UseAuthentication()

app. UseAuthentication ( )

다음을 참조함 : app.

◆ UseAuthorization()

app. UseAuthorization ( )

다음을 참조함 : app.

◆ UseForwardedHeaders()

app. UseForwardedHeaders ( )

다음을 참조함 : app.

◆ UseMiddleware< OgBotMiddleware >()

app. UseMiddleware< OgBotMiddleware > ( )

다음을 참조함 : app.

◆ UseMiddleware< TenantMiddleware >()

app. UseMiddleware< TenantMiddleware > ( )

다음을 참조함 : app.

◆ UseResponseCompression()

app. UseResponseCompression ( )

다음을 참조함 : app.

◆ UseStaticFiles() [1/2]

app. UseStaticFiles ( )

다음을 참조함 : app.

◆ UseStaticFiles() [2/2]

app. UseStaticFiles ( new StaticFileOptions { FileProvider=new Microsoft.Extensions.FileProviders.PhysicalFileProvider(shopOpts.ResolvedDataPath), RequestPath="/shop-img" } )

다음을 참조함 : app, shopOpts.

변수 문서화

◆ app

◆ authOptions

AuthOptions authOptions
초기값:
=
builder.Configuration.GetSection(AuthOptions.SectionName).Get<AuthOptions>() ?? new AuthOptions()
var builder
Definition Program.cs:10

Program.cs 파일의 18 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : AddDreamineIdentityWeb().

◆ builder

◆ shopOpts

var shopOpts = ShopOptions.From(builder.Configuration)

Program.cs 파일의 14 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : AddSingleton(), UseStaticFiles().

◆ usersDbPath

string usersDbPath
초기값:
builder.Configuration[$"{AuthOptions.SectionName}:UsersDbPath"],
Path.Combine(AppContext.BaseDirectory, "App_Data", "codemaru.db"))
static string ResolvePath(string? configuredPath, string fallback)
Definition Program.cs:218

Program.cs 파일의 20 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : AddDreamineIdentityWeb().

◆ wwwroot

var wwwroot = Path.Combine(app.Environment.ContentRootPath, "wwwroot")

Program.cs 파일의 132 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : EnsureDefault().