From 323bf7047474057c3fde3b852990be5319533ea3 Mon Sep 17 00:00:00 2001 From: DHR60 Date: Wed, 21 Jan 2026 19:48:41 +0800 Subject: [PATCH] Refactor --- v2rayN/ServiceLib/Models/ProfileItem.cs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/v2rayN/ServiceLib/Models/ProfileItem.cs b/v2rayN/ServiceLib/Models/ProfileItem.cs index 847eab60..5e060b0b 100644 --- a/v2rayN/ServiceLib/Models/ProfileItem.cs +++ b/v2rayN/ServiceLib/Models/ProfileItem.cs @@ -3,6 +3,8 @@ namespace ServiceLib.Models; [Serializable] public class ProfileItem : ReactiveObject { + private ProtocolExtraItem _protocolExtraItem = new(); + public ProfileItem() { IndexId = string.Empty; @@ -127,16 +129,12 @@ public class ProfileItem : ReactiveObject public void SetProtocolExtra(ProtocolExtraItem extraItem) { - ProtoExtra = JsonUtils.Serialize(extraItem, false); + _protocolExtraItem = extraItem; } public ProtocolExtraItem GetProtocolExtra() { - if (ProtoExtra.IsNullOrEmpty()) - { - return new ProtocolExtraItem(); - } - return JsonUtils.Deserialize(ProtoExtra); + return _protocolExtraItem; } #endregion function @@ -174,7 +172,13 @@ public class ProfileItem : ReactiveObject public string CertSha { get; set; } public string EchConfigList { get; set; } public string EchForceQuery { get; set; } - public string ProtoExtra { get; set; } + + public string ProtoExtra + { + get => JsonUtils.Serialize(_protocolExtraItem, false); + set => _protocolExtraItem = JsonUtils.Deserialize(value); + } + [Obsolete("Use ProtocolExtraItem.Ports instead.")] public string Ports { get; set; } [Obsolete("Use ProtocolExtraItem.AlterId instead.")]