/// <summary> /// 添加Sql的策略 /// </summary> /// <param name="policy"></param> public static void AddPolicy(this IConfigSqlInfoModifier info, ISqlConfigPolicy policy) { policy.CheckNull(nameof(policy)); info.Policies.Add(EFHelper.Services.EFCoreExUtility.GetSqlConfigPolicyName(policy.GetType()), policy); }
/// <summary> /// 设置全局策略对象 /// </summary> public static void SetGlobalPolicy(this ILuaSqlConfigManager mgr, ISqlConfigPolicy policy) { policy.CheckNull(nameof(policy)); var policyName = EFHelper.Services.EFCoreExUtility.GetSqlConfigPolicyName(policy.GetType()); if (string.IsNullOrEmpty(policyName)) { throw new ArgumentException($"Could not find {nameof(SqlConfigPolicyAttribute)} in {policy.GetType().Name} type"); } mgr.PolicyMgr.GlobalPolicies[policyName] = policy; }
/// <summary> /// 设置全局策略对象 /// </summary> /// <param name="mgr"></param> /// <param name="policyName"></param> /// <param name="policy"></param> public static void SetGlobalPolicy(this ILuaSqlConfigManager mgr, string policyName, ISqlConfigPolicy policy) { policy.CheckNull(nameof(policy)); policyName.CheckStringIsNullOrEmpty(nameof(policyName)); mgr.PolicyMgr.GlobalPolicies[policyName] = policy; }