public IContext LoadContext(Type contextType)
        {
            JsonInit.InitConverter();

            IConfigProvider configProvider = Provider.Get();
            IConfigSection  section        = configProvider.LoadSingleSetting(SectionId, contextType.FullName);

            if (section.ContainsSetting(contextType.FullName))
            {
                var jsonString = section.GetSetting <string>(contextType.FullName, null).Value;
                try
                {
                    if (!string.IsNullOrEmpty(jsonString))
                    {
                        return((IContext)JsonConvert.DeserializeObject(jsonString, contextType));
                    }
                    return(null);
                }
                catch (JsonSerializationException e)
                {
                    throw new JsonSerializationException(string.Format("Error deserializing type {0}", contextType), e);
                }
            }
            return(null);
        }
        public void SaveContext(IContext context)
        {
            JsonInit.InitConverter();

            IConfigProvider configProvider = Provider.Get();
            IConfigSection  section        = configProvider.LoadSingleSetting(SectionId, context.GetType().FullName);

            section.GetSetting <string>(context.GetType().FullName, null, true).Value =
                JsonConvert.SerializeObject(context);
            configProvider.SaveSection(section);
        }
        public void SaveContext(IContext context)
        {
            string filename = Path.Combine(_path, GetJsonFilename(context.GetType()));

            using (StreamWriter file = File.CreateText(filename))
            {
                var serializer = new JsonSerializer();
                JsonInit.InitSerializer(serializer);
                serializer.Serialize(file, context);
            }
        }
        public IContext LoadContext(Type contextType)
        {
            string filename = Path.Combine(_path, GetJsonFilename(contextType));

            if (File.Exists(filename))
            {
                using (StreamReader file = File.OpenText(filename))
                {
                    var serializer = new JsonSerializer();
                    JsonInit.InitSerializer(serializer);
                    try
                    {
                        return((IContext)serializer.Deserialize(file, contextType));
                    }
                    catch (JsonSerializationException e)
                    {
                        throw new JsonSerializationException(
                                  string.Format("Error deserializing type {0}", contextType), e);
                    }
                }
            }

            return(null);
        }