我将C#域对象存储在RedisDB中进行缓存。这些对象具有private getter
和private setter
的属性。
Private setter
已使用自定义ContractResolver
修复,我将该属性设置为Writable = true
并且有效。
现在我遇到了与私有getter相同的问题。这些属性未序列化,因此不会存储。
是否有类似的方法使序列化的私有属性可读?
这里的类和枚举FIXED
[DataContract]
public class Customer
{
[DataMember]
public Applicability Applicability { get; set; }
[DataMember]
public string Name { get; set; }
[DataMember]
public CustomerRole Role { private get; set; }
}
[DataContract]
public enum CustomerRole
{
EmployeeOrAgent,
AircraftOperator,
NominatedRepairOrganization,
ThirdPartyRepairOrganization,
AirworthinessAuthority
}