From 304437b834e8c87687f68333ae67a13ee1377a73 Mon Sep 17 00:00:00 2001 From: Dennis Kobert Date: Wed, 12 Jun 2019 21:47:51 +0200 Subject: Adjust Codestyle --- dsa/FireBase/Offline/OfflineDatabase.cs | 51 +++++++++++---------------------- 1 file changed, 17 insertions(+), 34 deletions(-) (limited to 'dsa/FireBase/Offline/OfflineDatabase.cs') diff --git a/dsa/FireBase/Offline/OfflineDatabase.cs b/dsa/FireBase/Offline/OfflineDatabase.cs index be0380b..5820dc6 100644 --- a/dsa/FireBase/Offline/OfflineDatabase.cs +++ b/dsa/FireBase/Offline/OfflineDatabase.cs @@ -5,13 +5,11 @@ using System.IO; using System.Linq; using LiteDB; -namespace Firebase.Database.Offline -{ +namespace Firebase.Database.Offline { /// /// The offline database. /// - public class OfflineDatabase : IDictionary - { + public class OfflineDatabase : IDictionary { private readonly IDictionary cache; private readonly LiteRepository db; @@ -20,8 +18,7 @@ namespace Firebase.Database.Offline /// /// The item type which is used to determine the database file name. /// Custom string which will get appended to the file name. - public OfflineDatabase(Type itemType, string filenameModifier) - { + public OfflineDatabase(Type itemType, string filenameModifier) { var fullName = GetFileName(itemType.ToString()); if (fullName.Length > 100) fullName = fullName.Substring(0, 100); @@ -73,12 +70,10 @@ namespace Firebase.Database.Offline /// /// The key of the element to get or set. /// The element with the specified key. - public OfflineEntry this[string key] - { + public OfflineEntry this[string key] { get => cache[key]; - set - { + set { cache[key] = value; db.Upsert(value); } @@ -88,13 +83,11 @@ namespace Firebase.Database.Offline /// Returns an enumerator that iterates through the collection. /// /// An enumerator that can be used to iterate through the collection. - public IEnumerator> GetEnumerator() - { + public IEnumerator> GetEnumerator() { return cache.GetEnumerator(); } - IEnumerator IEnumerable.GetEnumerator() - { + IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } @@ -102,16 +95,14 @@ namespace Firebase.Database.Offline /// Adds an item to the . /// /// The object to add to the . - public void Add(KeyValuePair item) - { + public void Add(KeyValuePair item) { Add(item.Key, item.Value); } /// /// Removes all items from the . /// - public void Clear() - { + public void Clear() { cache.Clear(); db.Delete(LiteDB.Query.All()); } @@ -124,8 +115,7 @@ namespace Firebase.Database.Offline /// True if is found in the ; /// otherwise, false. /// - public bool Contains(KeyValuePair item) - { + public bool Contains(KeyValuePair item) { return ContainsKey(item.Key); } @@ -139,8 +129,7 @@ namespace Firebase.Database.Offline /// zero-based indexing. /// /// The zero-based index in at which copying begins. - public void CopyTo(KeyValuePair[] array, int arrayIndex) - { + public void CopyTo(KeyValuePair[] array, int arrayIndex) { cache.CopyTo(array, arrayIndex); } @@ -154,8 +143,7 @@ namespace Firebase.Database.Offline /// ; otherwise, false. This method also returns false if /// is not found in the original . /// - public bool Remove(KeyValuePair item) - { + public bool Remove(KeyValuePair item) { return Remove(item.Key); } @@ -168,8 +156,7 @@ namespace Firebase.Database.Offline /// True if the contains an element with the key; /// otherwise, false. /// - public bool ContainsKey(string key) - { + public bool ContainsKey(string key) { return cache.ContainsKey(key); } @@ -178,8 +165,7 @@ namespace Firebase.Database.Offline /// /// The object to use as the key of the element to add. /// The object to use as the value of the element to add. - public void Add(string key, OfflineEntry value) - { + public void Add(string key, OfflineEntry value) { cache.Add(key, value); db.Insert(value); } @@ -192,8 +178,7 @@ namespace Firebase.Database.Offline /// True if the element is successfully removed; otherwise, false. This method also returns false if /// was not found in the original . /// - public bool Remove(string key) - { + public bool Remove(string key) { cache.Remove(key); return db.Delete(key); } @@ -211,13 +196,11 @@ namespace Firebase.Database.Offline /// True if the object that implements contains an /// element with the specified key; otherwise, false. /// - public bool TryGetValue(string key, out OfflineEntry value) - { + public bool TryGetValue(string key, out OfflineEntry value) { return cache.TryGetValue(key, out value); } - private string GetFileName(string fileName) - { + private string GetFileName(string fileName) { var invalidChars = new[] {'`', '[', ',', '='}; foreach (var c in invalidChars.Concat(Path.GetInvalidFileNameChars()).Distinct()) fileName = fileName.Replace(c, '_'); -- cgit v1.2.3-70-g09d2