Serialize protected properties with XmlSerializer?

40 Views Asked by At

I would like to make 'Keys' and 'Data' protected but I think there is no way or at least not without a lot of trouble.

public class baseDB<T> 
{

/// <summary>
/// Should not be used... Made public for XML serializer (Should be protected)
/// Use GetKeys() instead
/// </summary>
public List<String> Keys { get;  set; }
/// <summary>
/// Should not be used... Made public for XML serializer (Should be protected)
/// Use GetData() instead
/// </summary>
public List<T> Data { get;  set; }

public List<String> GetKeys()
{
    return new List<String>(Keys);
}

public List<T> GetData()
{ 
    return new List<T>(Data); 
}
// .... rest truncated ...

´

0

There are 0 best solutions below