Esiste un modo per ignorare le proprietà get-only utilizzando il serializzatore Json.NET ma senza utilizzare gli attributi JsonIgnore
?Esiste un modo per ignorare le proprietà get-only in Json.NET senza utilizzare gli attributi JsonIgnore?
Per esempio, ho una classe con questi ottenere le proprietà:
public Keys Hotkey { get; set; }
public Keys KeyCode
{
get
{
return Hotkey & Keys.KeyCode;
}
}
public Keys ModifiersKeys
{
get
{
return Hotkey & Keys.Modifiers;
}
}
public bool Control
{
get
{
return (Hotkey & Keys.Control) == Keys.Control;
}
}
public bool Shift
{
get
{
return (Hotkey & Keys.Shift) == Keys.Shift;
}
}
public bool Alt
{
get
{
return (Hotkey & Keys.Alt) == Keys.Alt;
}
}
public Modifiers ModifiersEnum
{
get
{
Modifiers modifiers = Modifiers.None;
if (Alt) modifiers |= Modifiers.Alt;
if (Control) modifiers |= Modifiers.Control;
if (Shift) modifiers |= Modifiers.Shift;
return modifiers;
}
}
public bool IsOnlyModifiers
{
get
{
return KeyCode == Keys.ControlKey || KeyCode == Keys.ShiftKey || KeyCode == Keys.Menu;
}
}
public bool IsValidKey
{
get
{
return KeyCode != Keys.None && !IsOnlyModifiers;
}
}
Devo aggiungere [JsonIgnore]
a tutti loro (ho anche molte altre classi), o non c'è modo migliore per ignorare tutto proprietà get-only?
come ignorare solo le proprietà senza SET? E continua a serializzare quando si ha un set privato come una stringa pubblica Name {get; set privato; }? –