You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.5 KiB
C#

using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Flurl.Http;
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2026 WenJY
* CLR4.0.30319.42000
* T14-GEN3-7895
* Sln.Wcs.HikRoBotSdk.Config
* c1ac02e9-7ad4-4356-8043-2cf04a09ede8
*
* WenJY
*
* 2026-02-25 14:42:08
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
namespace Sln.Wcs.HikRoBotSdk.Config
{
public class HikRoBotConfig
{
public readonly string api = "";
public readonly string contentType = "";
public readonly string userAgent="";
public readonly string xlrRequestId="";//随机生成
public readonly string xlrVersion="";
/// <summary>
/// 注入海康 SDK 配置参数
/// </summary>
/// <param name="configuration"></param>
/// <exception cref="Exception"></exception>IConfiguration configuration
public HikRoBotConfig(IConfiguration configuration)
{
if (string.IsNullOrEmpty(configuration["HikRoBot_Url"]))
{
throw new Exception("HikRoBot_Url 配置不正确,请检查Apollo配置.");
}
if (string.IsNullOrEmpty(configuration["HikRoBot_Content-Type"]))
{
throw new Exception("HikRoBot_Content-Type 配置不正确,请检查Apollo配置.");
}
if (string.IsNullOrEmpty(configuration["HikRoBot_User-Agent"]))
{
throw new Exception("HikRoBot_User-Agent 配置不正确,请检查Apollo配置.");
}
if (string.IsNullOrEmpty(configuration["HikRoBot_X-lr-version"]))
{
throw new Exception("HikRoBot_X-lr-version 配置不正确,请检查Apollo配置.");
}
api = configuration["HikRoBot_Url"];
contentType = configuration["HikRoBot_ContentType"];
userAgent = configuration["HikRoBot_User-Agent"];
xlrVersion = configuration["HikRoBot_X-lr-version"];
}
}
}