Problems with class and list<object> c#
This code it´s write in C# in visual studio 2012 I ´ve using winrt tool kit
Hi I tried create this loadGrupos to catch the file grupo.txt and read and load his content in to the class Grupos but I don´t know what´s happen the list grupos recive the content from the json but when I callend the loadGrupos the variable grupos don´t expose nothing. I really don´t know what´s going on. I tried debug and I didn´t found any error.
private List<Grupos> grupos;
public List<Grupos> loadGrupos()
{
leituraDeUmArquivo("grupo");
{
if (grupos != null)
{
messagem("grupo");
return grupos;
}
else
return null;
}
}
public async void leituraDeUmArquivo(String arquivoASerLido)
{
var a = "";
try
{
a = await StringIOExtensions.ReadFromFile(arquivoASerLido + ".txt", KnownFolders.DocumentsLibrary);
}
catch
{
}
String leitura = (String)a;
if (arquivoASerLido.Equals("data"))
{
anos = JsonConvert.DeserializeObject<List<Ano>>(leitura);
}
if (arquivoASerLido.Equals("grupo"))
{
List<Grupos> gruposAux = JsonConvert.DeserializeObject<List<Grupos>>(leitura);
grupos = gruposAux;
}
}
...
public class Grupos
{
public Grupos()
{
}
private List<string> gruposRegistrados = new List<string>();
public List<string> GruposRegistrados
{
get { return gruposRegistrados; }
set { gruposRegistrados = value; }
}
public Boolean adicionaNovoGrupo(string nomeDoGrupo)
{
foreach (string s in gruposRegistrados)
{
if (s.Equals(nomeDoGrupo))
{
return false;
}
}
gruposRegistrados.Add(nomeDoGrupo);
return true;
}
}
This code it´s write in C# in visual studio 2012 I ´ve using winrt tool kit
Hi I tried create this loadGrupos to catch the file grupo.txt and read and load his content in to the class Grupos but I don´t know what´s happen the list grupos recive the content from the json but when I callend the loadGrupos the variable grupos don´t expose nothing. I really don´t know what´s going on. I tried debug and I didn´t found any error.
private List<Grupos> grupos;
public List<Grupos> loadGrupos()
{
leituraDeUmArquivo("grupo");
{
if (grupos != null)
{
messagem("grupo");
return grupos;
}
else
return null;
}
}
public async void leituraDeUmArquivo(String arquivoASerLido)
{
var a = "";
try
{
a = await StringIOExtensions.ReadFromFile(arquivoASerLido + ".txt", KnownFolders.DocumentsLibrary);
}
catch
{
}
String leitura = (String)a;
if (arquivoASerLido.Equals("data"))
{
anos = JsonConvert.DeserializeObject<List<Ano>>(leitura);
}
if (arquivoASerLido.Equals("grupo"))
{
List<Grupos> gruposAux = JsonConvert.DeserializeObject<List<Grupos>>(leitura);
grupos = gruposAux;
}
}
...
public class Grupos
{
public Grupos()
{
}
private List<string> gruposRegistrados = new List<string>();
public List<string> GruposRegistrados
{
get { return gruposRegistrados; }
set { gruposRegistrados = value; }
}
public Boolean adicionaNovoGrupo(string nomeDoGrupo)
{
foreach (string s in gruposRegistrados)
{
if (s.Equals(nomeDoGrupo))
{
return false;
}
}
gruposRegistrados.Add(nomeDoGrupo);
return true;
}
}