示例#1
0
        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));
        }
示例#2
0
        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;
        }
示例#3
0
 private static T Create <T>(string json)
 {
     return(JSONUtils.FromJson <T>(json));
 }