Class AppSettings
Namespace: Tool.Utils
Assembly: Tool.Net.dll
获取配置文件数据 (允许修改原文件异步队列式更新)
public sealed class AppSettingsInheritance
Inherited Members
object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object?, object?), object.ToString()
Extension Methods
ObjectExtension.Add<T>(object, object, object), ObjectExtension.CopyEntity(object, object, params string[]), ObjectExtension.EntityToJson(object), ObjectExtension.EntityToJson(object, bool), ObjectExtension.EntityToJson(object, bool, string), DictionaryExtension.GetDictionary(object), TypeExtension.GetFieldKey(object, string, out bool), TypeExtension.GetFieldKey<T>(object, string, out bool), TypeExtension.GetFieldKey(object, Type, string, out bool), ObjectExtension.GetIntPtr(object), ObjectExtension.GetIntPtrInt(object), TypeExtension.GetPropertieFind(object, string, bool), TypeExtension.GetProperties(object), TypeExtension.GetPropertyKey(object, string, out bool), TypeExtension.GetPropertyKey<T>(object, string, out bool), TypeExtension.GetPropertyKey(object, Type, string, out bool), TypeExtension.GetValue(object, PropertyDescriptor), TypeExtension.GetValue(object, string, bool), TypeExtension.GetValue(object, string), ObjectExtension.Read<T>(object, object, int, int), ObjectExtension.Read<T>(object, int, object, int, int), DictionaryExtension.SetDictionary(object, IDictionary<string, object>), TypeExtension.SetFieldKey(object, string, object), TypeExtension.SetFieldKey<T>(object, string, object), TypeExtension.SetFieldKey(object, Type, string, object), TypeExtension.SetPropertyKey(object, string, object), TypeExtension.SetPropertyKey<T>(object, string, object), TypeExtension.SetPropertyKey(object, Type, string, object), TypeExtension.SetValue(object, PropertyDescriptor, object), TypeExtension.SetValue(object, string, object, bool), TypeExtension.SetValue(object, string, object), ObjectExtension.ToBase64String(object), ObjectExtension.ToBytes(object), ObjectExtension.ToBytes(object, out Type), DictionaryExtension.ToDictionary(object), DictionaryExtension.ToDictionary<T>(object), DictionaryExtension.ToIDictionary(object), DictionaryExtension.ToIDictionary<T>(object), ObjectExtension.ToJson(object), ObjectExtension.ToJson(object, JsonSerializerOptions), ObjectExtension.ToJsonWeb(object), ObjectExtension.ToJsonWeb(object, Action<JsonSerializerOptions>), ObjectExtension.ToTryVar<T>(object, T), ObjectExtension.ToVar<T>(object), ObjectExtension.ToVar(object, Type, bool), ObjectExtension.ToVar(object, string), ObjectExtension.ToXml(object)
Fields
FileName
主配置文件名
public const string FileName = "appsettings.json"Field Value
FileNameDevelopment
调试配置文件名
public const string FileNameDevelopment = "appsettings.Development.json"Field Value
Properties
Configuration
项目配置文件获取对象
public static IConfigurationRoot Configuration { get; }Property Value
CurrentDirectory
获取当前配置文件的路径
public static string CurrentDirectory { get; }Property Value
this[string]
获取key值
public string this[string key] { get; }Property Value
Methods
AddJsonFile(string)
根据你提供的地址获取配置文件信息
public static IConfiguration AddJsonFile(string filePath)Parameters
filePath string
配置文件路径
Returns
返回指定对象
Get(string, bool)
获取appSettings的value
public static string Get(string key, bool throwOnError = true)Parameters
key string
名称
throwOnError bool
true 表示在找不到该键值时引发异常;false 则表示返回 null。
Returns
返回值,如果键值名称不存在则返回
GetChildren()
获取直接子代配置子节。
public static IEnumerable<IConfigurationSection> GetChildren()Returns
IEnumerable<IConfigurationSection>
配置子部分。
GetInt(string, bool)
获取appSettings的value
public static int GetInt(string key, bool throwOnError = true)Parameters
key string
名称
throwOnError bool
true 表示在找不到该键值时引发异常;false 则表示返回 null。
Returns
返回值,如果键值名称不存在则返回0
GetReloadToken()
返回Microsoft.Extensions.Primitives.IChangeToken,可用于观察重新加载此配置时。
public static IChangeToken GetReloadToken()Returns
一个Microsoft.Extensions.Primitives.IChangeToken。
GetSection(string)
获取具有指定键的配置子节。
public static IConfigurationSection GetSection(string key)Parameters
key string
配置部分的键。
Returns
这个 Microsoft.Extensions.Configuration.IConfigurationSection
SetEvent
注册修改 IConfiguration 值的事件 (将取消默认实现的同步修改文件)
public static event Action<string, string> SetEvent