Files
thinkyu/報到系統客戶端/ConfigService_Usage_Example.cs.txt
T
sryang 577060bc78 chore: 首次簽入 Thinkyu ASP.NET 專案
- 加入 Visual Studio / ASP.NET .gitignore
- 排除建置輸出、IDE 設定、NuGet packages、大型 MSI 安裝檔
2026-09-10 09:42:37 +08:00

26 lines
650 B
Plaintext

// 使用 ConfigService 的示例
using System;
using 報到系統客戶端.Services;
// 1. 讀取 API 基礎 URL
string apiUrl = ConfigService.Instance.GetApiBaseUrl();
Console.WriteLine($"目前 API URL: {apiUrl}");
// 2. 設定新的 API 基礎 URL
bool success = ConfigService.Instance.SetApiBaseUrl("http://new-server:8080");
if (success)
{
Console.WriteLine("API URL 已更新");
// 更新 ApiService 的 BaseUrl
ApiService.Instance.SetBaseUrl("http://new-server:8080");
}
else
{
Console.WriteLine("API URL 更新失敗");
}
// 3. 取得設定檔路徑
string configPath = ConfigService.Instance.GetConfigFilePath();
Console.WriteLine($"設定檔路徑: {configPath}");