public ICommand Create(string unparsedCmd) { var cmd = JSONUtils.FromJson <CommandDTO>(unparsedCmd); if (!CommandTypes.ContainsKey(cmd.Name)) { throw new Exception($"Command type {cmd.Name} is not handled"); } return(CommandTypes[cmd.Name](cmd.Command)); }
public ShutdownHistoryStorage(Locations locations) { if (!File.Exists(locations.ShutdownHistoryFilePath)) { // Empty json array. File.WriteAllText(locations.ShutdownHistoryFilePath, "[]"); } dateTimes = JSONUtils.FromJson <HashSet <DateTime> >( File.ReadAllText(locations.ShutdownHistoryFilePath)); this.locations = locations; }
private static T Create <T>(string json) { return(JSONUtils.FromJson <T>(json)); }