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/ConcurrentOfflineDatabase.cs | 51 ++++++++--------------- 1 file changed, 17 insertions(+), 34 deletions(-) (limited to 'dsa/FireBase/Offline/ConcurrentOfflineDatabase.cs') diff --git a/dsa/FireBase/Offline/ConcurrentOfflineDatabase.cs b/dsa/FireBase/Offline/ConcurrentOfflineDatabase.cs index 1a9e607..724115f 100644 --- a/dsa/FireBase/Offline/ConcurrentOfflineDatabase.cs +++ b/dsa/FireBase/Offline/ConcurrentOfflineDatabase.cs @@ -6,13 +6,11 @@ using System.IO; using System.Linq; using LiteDB; -namespace Firebase.Database.Offline -{ +namespace Firebase.Database.Offline { /// /// The offline database. /// - public class ConcurrentOfflineDatabase : IDictionary - { + public class ConcurrentOfflineDatabase : IDictionary { private readonly ConcurrentDictionary ccache; private readonly LiteRepository db; @@ -21,8 +19,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 ConcurrentOfflineDatabase(Type itemType, string filenameModifier) - { + public ConcurrentOfflineDatabase(Type itemType, string filenameModifier) { var fullName = GetFileName(itemType.ToString()); if (fullName.Length > 100) fullName = fullName.Substring(0, 100); @@ -78,12 +75,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 => ccache[key]; - set - { + set { ccache.AddOrUpdate(key, value, (k, existing) => value); db.Upsert(value); } @@ -93,13 +88,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 ccache.GetEnumerator(); } - IEnumerator IEnumerable.GetEnumerator() - { + IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } @@ -107,16 +100,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() { ccache.Clear(); db.Delete(LiteDB.Query.All()); } @@ -129,8 +120,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); } @@ -144,8 +134,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) { ccache.ToList().CopyTo(array, arrayIndex); } @@ -159,8 +148,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); } @@ -173,8 +161,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 ccache.ContainsKey(key); } @@ -183,8 +170,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) { ccache.AddOrUpdate(key, value, (k, existing) => value); db.Upsert(value); } @@ -197,8 +183,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) { ccache.TryRemove(key, out _); return db.Delete(key); } @@ -216,13 +201,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 ccache.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-54-g00ecf