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#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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 保留所有权利。
* CLR版本4.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"];
}
}
}