-1
I’m creating an app restfull using the library Newtonsoft to send information through controllers. In my application, I have numerous classes such as user:
public class UsuarioModel
{
public int Id { get; set; }
public string Login { get; set; }
public string Senha { get; set; }
public string Email { get; set; }
public bool Visivel { get; set; }
public DateTime? CriadoEm { get; set; }
public DateTime? AtualizadoEm { get; set; }
}
So that no properties are sent null
or default
i want to overwrite the property static method within the class JObject.FromObject
thus:
public class JObject
{
public static JObject FromObject(object o)
{
return FromObject(o, new JsonSerializer()
{
NullValueHandling = NullValueHandling.Ignore,
DefaultValueHandling = DefaultValueHandling.Ignore
});
}
}
The intention of doing this is that I can write less code and standardize the entire application forever use this setting when calling the method.
The problem is that (as far as I know) there is no way to make a override
of a static method within a Extension class.
What should I do to implement this method?
I understand what you say, the question itself is the curiosity I had if in C# it was possible to do something of the kind or better.
– LeandroLuk