I have generic static class:
public static class IsolatedStorageCacheManager<BagType>
{
}
and method:
public static BagType Retrieve()
{
BagType obj = default(BagType);
try
{
IsolatedStorageFile appStore = IsolatedStorageFile.GetUserStoreForApplication();
string fileName = string.Format(CultureInfo.InvariantCulture, "{0}.xml", obj.GetType().Name);
if (appStore.FileExists(fileName))
{
using (IsolatedStorageFileStream isoStream = new IsolatedStorageFileStream(fileName, FileMode.Open, appStore))
{
using (StreamReader sr = new StreamReader(isoStream))
{
System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(obj.GetType());
obj = (BagType)x.Deserialize(sr);
}
}
}
}
catch (Exception ex)
{
log.Error(ex.Message);
}
return obj;
}
How can I get specific type send as BagType in Retrive method? I try using reflection but no result ;/
I’m not quite sure what you want, but does this help?