Example #1
0
        /// <summary>Creates a new set of items inside the repository.</summary>
        /// <param name="items">An <see cref="IDictionaryRange{TKey,TValue}"/> of items to add to the repository.</param>
        public void Create(IDictionaryRange <string, object> items)
        {
            string json = JsonConvert.SerializeObject(items, new JsonSerializerSettings {
                DefaultValueHandling = DefaultValueHandling.Include
            });

            File.WriteAllText(this.settingsFilePath, json);
        }
Example #2
0
        /// <summary>Updates a set of items in the repository.</summary>
        /// <param name="items">An <see cref="IDictionaryRange{TKey,TValue}"/> containing the items to update.</param>
        public void Update(IDictionaryRange <string, object> items)
        {
            if (!Directory.Exists(this.settingsFolderPath))
            {
                Directory.CreateDirectory(this.settingsFolderPath);
            }

            if (File.Exists(this.settingsFilePath))
            {
                File.Delete(this.settingsFilePath);
            }

            this.Create(items);
        }
        /// <summary>Updates a set of items in the repository.</summary>
        /// <param name="items">An <see cref="IDictionaryRange{TKey,TValue}"/> containing the items to update.</param>
        public void Update(IDictionaryRange<string, object> items)
        {
            if (!Directory.Exists(this.settingsFolderPath))
            {
                Directory.CreateDirectory(this.settingsFolderPath);
            }

            if (File.Exists(this.settingsFilePath))
            {
                File.Delete(this.settingsFilePath);
            }

            this.Create(items);
        }
        /// <summary>Creates a new set of items inside the repository.</summary>
        /// <param name="items">An <see cref="IDictionaryRange{TKey,TValue}"/> of items to add to the repository.</param>
        public void Create(IDictionaryRange <string, Solution> items)
        {
            if (!Directory.Exists(this.solutionPath))
            {
                Directory.CreateDirectory(this.solutionPath);
            }

            foreach (KeyValuePair <string, Solution> pair in items)
            {
                using (StreamWriter writer = File.CreateText(Path.Combine(this.solutionPath, pair.Key + ".smsln")))
                {
                    using (JsonWriter jsonWriter = new JsonTextWriter(writer))
                    {
                        jsonWriter.Formatting = Formatting.Indented;

                        new JsonSerializer().Serialize(jsonWriter, pair.Value);
                    }
                }
            }
        }
        /// <summary>Updates a set of items in the repository.</summary>
        /// <param name="items">An <see cref="IDictionaryRange{TKey,TValue}"/> containing the items to update.</param>
        public void Update(IDictionaryRange <string, Solution> items)
        {
            this.Delete(items.Keys);

            this.Create(items);
        }
        /// <summary>Creates a new set of items inside the repository.</summary>
        /// <param name="items">An <see cref="IDictionaryRange{TKey,TValue}"/> of items to add to the repository.</param>
        public void Create(IDictionaryRange<string, object> items)
        {
            string json = JsonConvert.SerializeObject(items, new JsonSerializerSettings { DefaultValueHandling = DefaultValueHandling.Include });

            File.WriteAllText(this.settingsFilePath, json);
        }