- افزودن پروژه و pointer مربوط به xAiMcpServer به xSaherelmWorkspace.sln و root. - بهروزرسانی .vscode/launch.json و .vscode/tasks.json برای ساختار جدید. - بهروزرسانی Documents/Resources/Commands/AiApi.txtx برای تولید context مربوط به xAiMcpServer در کنار xAiApi، xAiModels و xAiService. - حذف contextهای قدیمی xDashboard-xAiApi/xAiModels/xAiService مربوط به 20261102 و ایجاد contextهای جدید 20261104 برای xAiApi، xAiMcpServer، xAiModels و xAiService.
600 lines
22 KiB
HTML
600 lines
22 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="fa" dir="rtl">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<title>پیادهسازی MCP Server با HTTP Transport در xAiMcpServer (netcoreapp3.1) — نسخه ۱.۴</title>
|
||
<style>
|
||
@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');
|
||
|
||
:root {
|
||
--primary: #1a365d;
|
||
--primary-light: #2c5282;
|
||
--accent: #c9a961;
|
||
--accent-dark: #a8893f;
|
||
--bg: #faf9f6;
|
||
--card-bg: #ffffff;
|
||
--text: #1a202c;
|
||
--text-muted: #4a5568;
|
||
--border: #e2e8f0;
|
||
--success: #38a169;
|
||
--danger: #e53e3e;
|
||
--warning: #dd6b20;
|
||
--code-bg: #1e293b;
|
||
--code-text: #e2e8f0;
|
||
--shadow: 0 4px 6px rgba(0,0,0,0.05), 0 10px 30px rgba(26,54,93,0.08);
|
||
}
|
||
|
||
* { box-sizing: border-box; margin: 0; padding: 0; }
|
||
|
||
body {
|
||
font-family: 'Vazirmatn', Tahoma, sans-serif;
|
||
background: var(--bg);
|
||
color: var(--text);
|
||
line-height: 1.9;
|
||
font-size: 15px;
|
||
padding: 30px 15px;
|
||
}
|
||
|
||
.document-container {
|
||
max-width: 1100px;
|
||
margin: 0 auto;
|
||
background: var(--card-bg);
|
||
box-shadow: var(--shadow);
|
||
border-radius: 12px;
|
||
overflow: hidden;
|
||
}
|
||
|
||
.document-header {
|
||
background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
|
||
color: white;
|
||
padding: 50px 40px 40px;
|
||
position: relative;
|
||
border-bottom: 4px solid var(--accent);
|
||
}
|
||
|
||
.document-header::before {
|
||
content: '';
|
||
position: absolute;
|
||
top: 0; right: 0;
|
||
width: 200px; height: 200px;
|
||
background: radial-gradient(circle, rgba(201,169,97,0.15) 0%, transparent 70%);
|
||
border-radius: 50%;
|
||
transform: translate(50%, -50%);
|
||
}
|
||
|
||
.header-top {
|
||
display: flex;
|
||
justify-content: space-between;
|
||
align-items: center;
|
||
margin-bottom: 30px;
|
||
position: relative;
|
||
z-index: 1;
|
||
}
|
||
|
||
.company-badge { display: flex; align-items: center; gap: 12px; }
|
||
|
||
.company-logo {
|
||
width: 60px; height: 60px;
|
||
background: var(--accent);
|
||
border-radius: 12px;
|
||
box-shadow: 0 4px 12px rgba(0,0,0,0.2);
|
||
}
|
||
|
||
.doc-meta { text-align: left; font-size: 12px; opacity: 0.9; }
|
||
.doc-meta div { margin-bottom: 3px; }
|
||
|
||
.document-title {
|
||
text-align: center;
|
||
position: relative;
|
||
z-index: 1;
|
||
padding: 20px 0;
|
||
}
|
||
|
||
.document-title .label {
|
||
display: inline-block;
|
||
background: rgba(201,169,97,0.2);
|
||
color: var(--accent);
|
||
padding: 4px 16px;
|
||
border-radius: 20px;
|
||
font-size: 12px;
|
||
font-weight: 600;
|
||
margin-bottom: 15px;
|
||
border: 1px solid rgba(201,169,97,0.4);
|
||
}
|
||
|
||
.document-title h1 {
|
||
font-size: 26px;
|
||
font-weight: 800;
|
||
margin-bottom: 10px;
|
||
letter-spacing: -0.5px;
|
||
}
|
||
|
||
.document-title h2 { font-size: 15px; font-weight: 400; opacity: 0.9; }
|
||
|
||
.document-body { padding: 40px; }
|
||
|
||
.intro-text {
|
||
background: linear-gradient(to left, #f7fafc, #edf2f7);
|
||
border-right: 4px solid var(--accent);
|
||
padding: 20px 25px;
|
||
border-radius: 8px;
|
||
margin-bottom: 35px;
|
||
font-size: 14px;
|
||
color: var(--text-muted);
|
||
}
|
||
|
||
.section { margin-bottom: 45px; page-break-inside: avoid; }
|
||
|
||
.section-header {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 15px;
|
||
padding-bottom: 12px;
|
||
border-bottom: 2px solid var(--border);
|
||
margin-bottom: 20px;
|
||
}
|
||
|
||
.section-number {
|
||
width: 50px; height: 50px;
|
||
background: linear-gradient(135deg, var(--primary), var(--primary-light));
|
||
color: white;
|
||
border-radius: 12px;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
font-weight: 800;
|
||
font-size: 20px;
|
||
flex-shrink: 0;
|
||
box-shadow: 0 4px 10px rgba(26,54,93,0.2);
|
||
}
|
||
|
||
.section-title { flex: 1; }
|
||
.section-title h3 { font-size: 19px; font-weight: 700; color: var(--primary); margin-bottom: 2px; }
|
||
.section-title .subtitle { font-size: 12px; color: var(--text-muted); font-family: 'JetBrains Mono', monospace; direction: ltr; text-align: right; }
|
||
|
||
.section-content { padding-right: 10px; }
|
||
.section-content p { margin-bottom: 12px; text-align: justify; text-indent: 20px; }
|
||
.section-content p.no-indent { text-indent: 0; }
|
||
|
||
.highlight-box, .info-box, .success-box, .warning-box, .danger-box {
|
||
padding: 18px 22px;
|
||
border-radius: 8px;
|
||
margin: 20px 0;
|
||
font-size: 14px;
|
||
}
|
||
|
||
.highlight-box {
|
||
background: linear-gradient(to left, #fffaf0, #fef5e7);
|
||
border: 1px solid #f6e05e;
|
||
border-right: 4px solid var(--accent);
|
||
}
|
||
.highlight-box strong { color: var(--accent-dark); }
|
||
|
||
.info-box {
|
||
background: linear-gradient(to left, #ebf8ff, #e6f6ff);
|
||
border: 1px solid #90cdf4;
|
||
border-right: 4px solid var(--primary-light);
|
||
}
|
||
|
||
.success-box {
|
||
background: linear-gradient(to left, #f0fff4, #e6fffa);
|
||
border: 1px solid #9ae6b4;
|
||
border-right: 4px solid var(--success);
|
||
}
|
||
|
||
.warning-box {
|
||
background: linear-gradient(to left, #fffaf0, #fef5e7);
|
||
border: 1px solid #fbd38d;
|
||
border-right: 4px solid var(--warning);
|
||
}
|
||
|
||
.danger-box {
|
||
background: linear-gradient(to left, #fff5f5, #fed7d7);
|
||
border: 1px solid #fc8181;
|
||
border-right: 4px solid var(--danger);
|
||
}
|
||
|
||
pre {
|
||
background: var(--code-bg);
|
||
color: var(--code-text);
|
||
padding: 20px 22px;
|
||
border-radius: 8px;
|
||
overflow-x: auto;
|
||
margin: 15px 0;
|
||
font-family: 'JetBrains Mono', 'Courier New', monospace;
|
||
font-size: 12.5px;
|
||
line-height: 1.7;
|
||
direction: ltr;
|
||
text-align: left;
|
||
border: 1px solid #334155;
|
||
position: relative;
|
||
}
|
||
|
||
pre::before {
|
||
content: attr(data-lang);
|
||
position: absolute;
|
||
top: 8px;
|
||
right: 12px;
|
||
font-size: 10px;
|
||
color: #64748b;
|
||
text-transform: uppercase;
|
||
letter-spacing: 1px;
|
||
font-weight: 600;
|
||
}
|
||
|
||
code {
|
||
font-family: 'JetBrains Mono', 'Courier New', monospace;
|
||
background: #f1f5f9;
|
||
color: #1e293b;
|
||
padding: 2px 6px;
|
||
border-radius: 4px;
|
||
font-size: 12.5px;
|
||
direction: ltr;
|
||
display: inline-block;
|
||
}
|
||
|
||
pre code { background: none; color: inherit; padding: 0; display: inline; }
|
||
|
||
.file-path {
|
||
background: #2c5282;
|
||
color: #bee3f8;
|
||
padding: 8px 14px;
|
||
border-radius: 6px 6px 0 0;
|
||
font-family: 'JetBrains Mono', monospace;
|
||
font-size: 11.5px;
|
||
direction: ltr;
|
||
text-align: left;
|
||
margin-top: 15px;
|
||
margin-bottom: -15px;
|
||
border-bottom: 2px solid #1a365d;
|
||
}
|
||
|
||
.file-path::before { content: '📄 '; margin-left: 4px; }
|
||
|
||
.styled-table {
|
||
width: 100%;
|
||
border-collapse: collapse;
|
||
margin: 20px 0;
|
||
background: white;
|
||
border-radius: 8px;
|
||
overflow: hidden;
|
||
box-shadow: 0 2px 8px rgba(0,0,0,0.05);
|
||
}
|
||
|
||
.styled-table thead {
|
||
background: linear-gradient(135deg, var(--primary), var(--primary-light));
|
||
color: white;
|
||
}
|
||
|
||
.styled-table th { padding: 14px 16px; text-align: right; font-weight: 600; font-size: 13px; }
|
||
.styled-table td { padding: 13px 16px; border-bottom: 1px solid var(--border); font-size: 13px; }
|
||
.styled-table tbody tr:last-child td { border-bottom: none; }
|
||
.styled-table tbody tr:nth-child(even) { background: #f8fafc; }
|
||
.styled-table .highlight-row { background: #fffaf0 !important; font-weight: 600; }
|
||
|
||
.file-tree {
|
||
background: #f8fafc;
|
||
border: 1px solid var(--border);
|
||
border-radius: 8px;
|
||
padding: 20px 25px;
|
||
margin: 15px 0;
|
||
font-family: 'JetBrains Mono', monospace;
|
||
font-size: 12.5px;
|
||
direction: ltr;
|
||
text-align: left;
|
||
line-height: 1.9;
|
||
color: var(--text-muted);
|
||
}
|
||
.file-tree .folder { color: var(--primary); font-weight: 600; }
|
||
.file-tree .new { color: var(--success); }
|
||
.file-tree .modify { color: var(--warning); }
|
||
|
||
.checklist { list-style: none; padding: 0; margin: 15px 0; }
|
||
.checklist li {
|
||
padding: 10px 15px;
|
||
background: #f8fafc;
|
||
border-right: 3px solid var(--primary-light);
|
||
margin-bottom: 8px;
|
||
border-radius: 6px;
|
||
font-size: 13.5px;
|
||
}
|
||
.checklist li::before {
|
||
content: '✓';
|
||
color: var(--success);
|
||
font-weight: 700;
|
||
margin-left: 10px;
|
||
display: inline-block;
|
||
}
|
||
|
||
.conclusion-box {
|
||
background: linear-gradient(135deg, var(--primary), var(--primary-light));
|
||
color: white;
|
||
padding: 30px;
|
||
border-radius: 12px;
|
||
margin: 30px 0;
|
||
text-align: center;
|
||
box-shadow: 0 8px 20px rgba(26,54,93,0.3);
|
||
}
|
||
.conclusion-box h3 { font-size: 22px; font-weight: 800; margin-bottom: 15px; color: var(--accent); }
|
||
.conclusion-box p { font-size: 14px; line-height: 1.8; text-indent: 0 !important; margin-bottom: 15px; }
|
||
|
||
.document-footer {
|
||
background: var(--primary);
|
||
color: white;
|
||
padding: 25px 40px;
|
||
text-align: center;
|
||
font-size: 12px;
|
||
margin-top: 40px;
|
||
}
|
||
.document-footer .footer-brand { font-weight: 700; color: var(--accent); margin-bottom: 5px; font-size: 14px; }
|
||
.footer-divider { width: 60px; height: 2px; background: var(--accent); margin: 10px auto; }
|
||
|
||
@media print { body { background: white; padding: 0; } .document-container { box-shadow: none; border-radius: 0; } .section { page-break-inside: avoid; } }
|
||
@media (max-width: 768px) { .document-body { padding: 25px 20px; } .document-header { padding: 30px 20px; } .header-top { flex-direction: column; gap: 15px; } .doc-meta { text-align: center; } }
|
||
</style>
|
||
</head>
|
||
<body>
|
||
|
||
<div class="document-container">
|
||
|
||
<header class="document-header">
|
||
<div class="header-top">
|
||
<div class="company-badge"><div class="company-logo"></div></div>
|
||
<div class="doc-meta">
|
||
<div>شماره مستند: ARCH-MCP-HTTP-1405-001-R4</div>
|
||
<div>نسخه: ۱.۴ (دسترسی به IConfiguration)</div>
|
||
<div>تاریخ تهیه: آبان ۱۴۰۵</div>
|
||
<div>طبقهبندی: فنی-داخلی</div>
|
||
</div>
|
||
</div>
|
||
<div class="document-title">
|
||
<span class="label">TECHNICAL DESIGN DOCUMENT — R4</span>
|
||
<h1>پیادهسازی MCP Server با HTTP Transport در xAiMcpServer (netcoreapp3.1)</h1>
|
||
<h2>دسترسی به IConfiguration و IServiceCollection در Program.cs</h2>
|
||
</div>
|
||
</header>
|
||
|
||
<div class="document-body">
|
||
|
||
<div class="intro-text">
|
||
<strong>هدف مستند (نسخه ۱.۴):</strong><br>
|
||
این نسخه، روش دسترسی به <code>IConfiguration</code> و <code>IServiceCollection</code> را در <code>Program.cs</code> هنگام استفاده از <code>Grapevine.RestServerBuilder</code> شرح میدهد. از آنجا که این Builder خودش <code>IConfiguration</code> را فراهم نمیکند، باید آن را بهصورت دستی با <code>ConfigurationBuilder</code> بسازید و در لامبدای <code>services</code> برای ثبت سرویسها استفاده کنید. همچنین الگوی <code>Startup</code> (توصیهشده) برای کد تمیزتر معرفی میشود.
|
||
</div>
|
||
|
||
<!-- SECTION 0: Why Manual Configuration -->
|
||
<div class="section">
|
||
<div class="section-header">
|
||
<div class="section-number">۰</div>
|
||
<div class="section-title">
|
||
<h3>چرا باید <code>IConfiguration</code> را دستی بسازیم؟</h3>
|
||
<div class="subtitle">Why Manual Configuration is Needed</div>
|
||
</div>
|
||
</div>
|
||
<div class="section-content">
|
||
<p>برخلاف ASP.NET Core که <code>WebApplication.CreateBuilder(args)</code> بهصورت خودکار <code>IConfiguration</code> را از <code>appsettings.json</code> بارگذاری میکند، <code>Grapevine.RestServerBuilder</code> این کار را انجام نمیدهد. بنابراین، برای دسترسی به تنظیمات (مانند <code>XAppConfiguration</code> یا <code>ConnectionStrings</code>)، باید:</p>
|
||
|
||
<ul style="padding-right: 20px; margin: 10px 0;">
|
||
<li><code>ConfigurationBuilder</code> را دستی بسازید.</li>
|
||
<li>فایل <code>appsettings.json</code> را با <code>AddJsonFile</code> بارگذاری کنید.</li>
|
||
<li>سپس در لامبدای <code>services</code>، از <code>configuration.GetSection().Get<T>()</code> برای ثبت سرویسها استفاده کنید.[reference:1]</li>
|
||
</ul>
|
||
|
||
<div class="info-box">
|
||
<strong>💡 نکته:</strong> بستههای <code>Microsoft.Extensions.Configuration.Json</code> و <code>Microsoft.Extensions.Configuration.FileExtensions</code> را به پروژه اضافه کنید تا <code>ConfigurationBuilder</code> در دسترس باشد.
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- SECTION 1: Manual Configuration in Program.cs -->
|
||
<div class="section">
|
||
<div class="section-header">
|
||
<div class="section-number">۱</div>
|
||
<div class="section-title">
|
||
<h3>روش اول: ساخت دستی <code>IConfiguration</code> در <code>Program.cs</code></h3>
|
||
<div class="subtitle">Manual IConfiguration in Program.cs</div>
|
||
</div>
|
||
</div>
|
||
<div class="section-content">
|
||
<p>کد زیر، <code>IConfiguration</code> را میسازد و در لامبدای <code>services</code> از آن استفاده میکند:</p>
|
||
|
||
<div class="file-path">Program.cs</div>
|
||
<pre data-lang="csharp"><code>using System;
|
||
using System.IO;
|
||
using Grapevine;
|
||
using Grapevine.Extensions.Mcp;
|
||
using Microsoft.Extensions.Configuration;
|
||
using Microsoft.Extensions.DependencyInjection;
|
||
using ModelContextProtocol.Server;
|
||
|
||
namespace xAiMcpServer
|
||
{
|
||
public class Program
|
||
{
|
||
public static void Main(string[] args)
|
||
{
|
||
// ۱. ساخت IConfiguration از appsettings.json
|
||
var configuration = new ConfigurationBuilder()
|
||
.SetBasePath(Directory.GetCurrentDirectory())
|
||
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
|
||
.Build();
|
||
|
||
// ۲. ساخت RestServerBuilder با دسترسی به configuration
|
||
var builder = new RestServerBuilder(
|
||
// لامبدای اول: ثبت سرویسها
|
||
services =>
|
||
{
|
||
// ثبت سرویسهای MCP
|
||
services.AddMcpServer()
|
||
.WithHttpTransport()
|
||
.WithToolsFromAssembly();
|
||
|
||
// ثبت IConfiguration بهعنوان Singleton (اختیاری)
|
||
services.AddSingleton<IConfiguration>(configuration);
|
||
|
||
// ثبت سرویسهای سفارشی با استفاده از configuration
|
||
// services.AddSingleton(
|
||
// configuration.GetSection("XAppConfiguration").Get<XAppConfiguration>()
|
||
// );
|
||
// services.AddScoped<XValidationProvider>();
|
||
},
|
||
|
||
// لامبدای دوم: تنظیمات IRestServer (نوع صریح)
|
||
(IRestServer server) =>
|
||
{
|
||
server.Prefixes.Add("http://localhost:5000/");
|
||
}
|
||
);
|
||
|
||
var server = builder.Build();
|
||
server.MapMcp("/mcp");
|
||
server.Start();
|
||
|
||
Console.WriteLine("MCP Server running on http://localhost:5000/mcp");
|
||
Console.ReadLine();
|
||
|
||
server.Stop();
|
||
}
|
||
}
|
||
}</code></pre>
|
||
|
||
<div class="success-box">
|
||
<strong>✓ نکات کلیدی:</strong>
|
||
<ul style="padding-right: 20px; margin-top: 10px;">
|
||
<li>با ثبت <code>services.AddSingleton<IConfiguration>(configuration)</code>، سایر سرویسها میتوانند <code>IConfiguration</code> را از طریق تزریق وابستگی دریافت کنند.</li>
|
||
<li>برای خواندن یک بخش خاص: <code>configuration.GetSection("XAppConfiguration").Get<XAppConfiguration>()</code>.</li>
|
||
<li>مطمئن شوید <code>appsettings.json</code> در پوشه خروجی (Output Directory) کپی میشود (تنظیم <code>CopyToOutputDirectory</code> در <code>.csproj</code>).</li>
|
||
</ul>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- SECTION 2: Startup Class Approach -->
|
||
<div class="section">
|
||
<div class="section-header">
|
||
<div class="section-number">۲</div>
|
||
<div class="section-title">
|
||
<h3>روش دوم (توصیهشده): الگوی <code>Startup</code> در Grapevine</h3>
|
||
<div class="subtitle">Recommended: Grapevine Startup Class</div>
|
||
</div>
|
||
</div>
|
||
<div class="section-content">
|
||
<p>نسخه ۵.۰ Grapevine از الگوی <code>Startup</code> پشتیبانی میکند که کد را تمیزتر و قابل نگهداریتر میکند. با استفاده از <code>RestServerBuilder.From<Startup>()</code>، میتوانید متدهای <code>ConfigureServices</code> و <code>ConfigureServer</code> را در یک کلاس جداگانه تعریف کنید.[reference:2]</p>
|
||
|
||
<div class="file-path">Startup.cs</div>
|
||
<pre data-lang="csharp"><code>using System;
|
||
using System.IO;
|
||
using Grapevine;
|
||
using Grapevine.Extensions.Mcp;
|
||
using Microsoft.Extensions.Configuration;
|
||
using Microsoft.Extensions.DependencyInjection;
|
||
using ModelContextProtocol.Server;
|
||
|
||
namespace xAiMcpServer
|
||
{
|
||
public class Startup
|
||
{
|
||
private readonly IConfiguration _configuration;
|
||
|
||
public Startup()
|
||
{
|
||
_configuration = new ConfigurationBuilder()
|
||
.SetBasePath(Directory.GetCurrentDirectory())
|
||
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
|
||
.Build();
|
||
}
|
||
|
||
// ثبت سرویسها
|
||
public void ConfigureServices(IServiceCollection services)
|
||
{
|
||
services.AddMcpServer()
|
||
.WithHttpTransport()
|
||
.WithToolsFromAssembly();
|
||
|
||
services.AddSingleton<IConfiguration>(_configuration);
|
||
// services.AddSingleton(_configuration.GetSection("XAppConfiguration").Get<XAppConfiguration>());
|
||
}
|
||
|
||
// تنظیم سرور
|
||
public void ConfigureServer(IRestServer server)
|
||
{
|
||
server.Prefixes.Add("http://localhost:5000/");
|
||
}
|
||
}
|
||
}</code></pre>
|
||
|
||
<div class="file-path">Program.cs</div>
|
||
<pre data-lang="csharp"><code>using System;
|
||
using Grapevine;
|
||
|
||
namespace xAiMcpServer
|
||
{
|
||
public class Program
|
||
{
|
||
public static void Main(string[] args)
|
||
{
|
||
var server = RestServerBuilder.From<Startup>().Build();
|
||
server.MapMcp("/mcp");
|
||
server.Start();
|
||
|
||
Console.WriteLine("MCP Server running on http://localhost:5000/mcp");
|
||
Console.ReadLine();
|
||
|
||
server.Stop();
|
||
}
|
||
}
|
||
}</code></pre>
|
||
|
||
<div class="info-box">
|
||
<strong>💡 نکته:</strong> نام متدها مهم نیست؛ فقط امضاهای <code>public void ConfigureServices(IServiceCollection)</code> و <code>public void ConfigureServer(IRestServer)</code> مهم هستند. Grapevine با Reflection آنها را کشف میکند.[reference:3]
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- SECTION 3: Summary -->
|
||
<div class="section">
|
||
<div class="section-header">
|
||
<div class="section-number">۳</div>
|
||
<div class="section-title">
|
||
<h3>جمعبندی و چکلیست</h3>
|
||
<div class="subtitle">Summary & Checklist</div>
|
||
</div>
|
||
</div>
|
||
<div class="section-content">
|
||
<p>برای دسترسی به <code>IConfiguration</code> و <code>IServiceCollection</code> در <code>Program.cs</code>:</p>
|
||
|
||
<ul class="checklist">
|
||
<li>بستههای <code>Microsoft.Extensions.Configuration.Json</code> و <code>Microsoft.Extensions.Configuration.FileExtensions</code> را نصب کنید.</li>
|
||
<li><code>ConfigurationBuilder</code> را در <code>Program.cs</code> (یا <code>Startup</code>) بسازید.</li>
|
||
<li>در لامبدای <code>services</code>، سرویسها را با <code>configuration.GetSection().Get<T>()</code> ثبت کنید.</li>
|
||
<li>برای کد تمیزتر، از الگوی <code>Startup</code> با <code>RestServerBuilder.From<Startup>()</code> استفاده کنید.</li>
|
||
<li>مطمئن شوید <code>appsettings.json</code> در پوشه خروجی کپی میشود.</li>
|
||
</ul>
|
||
|
||
<div class="conclusion-box">
|
||
<h3>🎯 نتیجه نهایی</h3>
|
||
<p>اکنون میتوانید <code>IConfiguration</code> را در <code>Program.cs</code> بسازید و سرویسهای سفارشی (مانند <code>XAppConfiguration</code>، <code>XValidationProvider</code> و...) را با استفاده از آن ثبت کنید.</p>
|
||
<div class="highlight" style="background: rgba(201,169,97,0.2); padding: 15px; border-radius: 8px; margin-top: 20px; border: 1px solid rgba(201,169,97,0.4);">
|
||
<strong>💎 ارزش پیشنهادی:</strong><br>
|
||
دسترسی کامل به تنظیمات + ثبت سرویسهای سفارشی + حفظ <code>netcoreapp3.1</code> + کد تمیز با الگوی Startup
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="page-info" style="text-align: center; padding: 15px; font-size: 11px; color: var(--text-muted); border-top: 1px solid var(--border); margin-top: 30px;">
|
||
این مستند محرمانه بوده و صرفاً جهت استفاده تیم توسعه xSaherelmWorkspace تهیه شده است.
|
||
</div>
|
||
|
||
</div>
|
||
|
||
<footer class="document-footer">
|
||
<div class="footer-brand">طراحی و مستندسازی: تیم معماری xSaherelmWorkspace</div>
|
||
<div class="footer-divider"></div>
|
||
<div>تاریخ تهیه: آبان ۱۴۰۵ | نسخه: ۱.۴ | طبقهبندی: فنی-داخلی</div>
|
||
</footer>
|
||
|
||
</div>
|
||
|
||
</body>
|
||
</html> |