Example #1
0
        public T LoadModel <T>(string fileName, bool useCache = true)
            where T : class
        {
            var key = typeof(T);

            if (_modelCache.ContainsKey(key))
            {
                if (useCache)
                {
                    return(_modelCache[key] as T);
                }

                //update
                var model = _ioService.DeserializeFileToJson <T>(fileName);
                _modelCache[key] = model;
                return(model);
            }

            //add
            var newModel = _ioService.DeserializeFileToJson <T>(fileName);

            _modelCache.Add(key, newModel);
            return(newModel);
        }