namespace Fengling.Activity.Domain.ValueObjects; public class ConditionConfig : IEquatable { public string StrategyType { get; } public IReadOnlyDictionary Parameters { get; } private ConditionConfig(string strategyType, Dictionary parameters) { StrategyType = strategyType; Parameters = parameters; } public static ConditionConfig Create(string strategyType, Dictionary parameters) { if (string.IsNullOrWhiteSpace(strategyType)) throw new ArgumentException("Strategy type cannot be empty"); return new ConditionConfig(strategyType, parameters); } public T? GetParameter(string key) { if (Parameters.TryGetValue(key, out var value) && value is T typedValue) return typedValue; return default; } public bool Equals(ConditionConfig? other) { if (other is null) return false; if (StrategyType != other.StrategyType) return false; return Parameters.Count == other.Parameters.Count && Parameters.All(p => other.Parameters.TryGetValue(p.Key, out var ov) && (p.Value?.Equals(ov) ?? ov is null)); } public override bool Equals(object? obj) => Equals(obj as ConditionConfig); public override int GetHashCode() => HashCode.Combine(StrategyType, Parameters); public static bool operator ==(ConditionConfig a, ConditionConfig b) => a.Equals(b); public static bool operator !=(ConditionConfig a, ConditionConfig b) => !a.Equals(b); }