I'm trying to serialize an object that carries internally other objects with different properties, but when creating the file it only shows me the main attributes nombre y ubicacion
, instead it does not appear dispositivo
, which is in a List<Dispositivo>
with the rest of information that is inside this ...
Looking inside the object I see that dispositivos
has a lock. Do I have any problem accessing these? I have tried to set the Device and Type classes as Public
but the problem still has the same ...
The class Estacion
is the following, the list is private because I do not want it to be modified from the outside, unless its methods are used ... Can I do something to keep it private but through the JSON? see its properties?
namespace Proyecto
{
class Estacion
{
private string _nombre, _ubicacion;
private List<Dispositivo> dispositivos = new List<Dispositivo>();
public string nombre
{
get { return _nombre; }
set { _nombre = value; }
}
public string ubicacion
{
get { return _ubicacion; }
set { _ubicacion = value; }
}
public List<Dispositivo> getDispositivos()
{
return this.dispositivos;
}
public void añadirDispositivo(Dispositivo dispositivo)
{
this.dispositivos.Add(dispositivo);
}
public void eliminarDispositivo(Dispositivo dispositivo)
{
this.dispositivos.Remove(dispositivo);
}
}
}