-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
in the public static bool Retrieve(out TSettings result, string namePreFix = null, string nameMarker = null) function
if (File.Exists(fileName))
{
result = new TSettings();
string text = null;
text = File.ReadAllText(fileName);
result = JsonConvert.DeserializeObject(text,
new JsonSerializerSettings
{
TypeNameHandling = TypeNameHandling.Auto,
TypeNameAssemblyFormatHandling = TypeNameAssemblyFormatHandling.Simple,
PreserveReferencesHandling = PreserveReferencesHandling.All,
CheckAdditionalContent = false
}) as TSettings;
if (result == null)
result = new TSettings();
return true;
}
- i think having:
result = new TSettings();
at the first line of the if, will lead to un-used object, as it will go to garbage collector if the 'DeserializeObject' works, and its enough to have the lines:
if (result == null)
result = new TSettings();
- I think that the line:
result = JsonConvert.DeserializeObject(text,
should be:
result = JsonConvert.DeserializeObject**<TSettings>**(text,
Regards.
Metadata
Metadata
Assignees
Labels
No labels