26 lines
650 B
Plaintext
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}");
|