From c4d046858e0822b7c2c540ac2368b2c0e88e7a26 Mon Sep 17 00:00:00 2001 From: Dennis Kobert Date: Sun, 19 May 2019 17:00:02 +0200 Subject: general refectoring added 42 as dummy Token --- FireBase/Streaming/FirebaseCache.cs | 39 +++++++++++++-------------- FireBase/Streaming/FirebaseEvent.cs | 8 +++--- FireBase/Streaming/FirebaseEventSource.cs | 14 +++++----- FireBase/Streaming/FirebaseEventType.cs | 6 ++--- FireBase/Streaming/FirebaseSubscription.cs | 38 +++++++++++++------------- FireBase/Streaming/NonBlockingStreamReader.cs | 21 ++++++++------- 6 files changed, 63 insertions(+), 63 deletions(-) (limited to 'FireBase/Streaming') diff --git a/FireBase/Streaming/FirebaseCache.cs b/FireBase/Streaming/FirebaseCache.cs index 77fc622..66241e0 100644 --- a/FireBase/Streaming/FirebaseCache.cs +++ b/FireBase/Streaming/FirebaseCache.cs @@ -1,15 +1,15 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using Firebase.Database.Http; +using Newtonsoft.Json; + namespace Firebase.Database.Streaming { - using System; - using System.Collections; - using System.Collections.Generic; - using System.Linq; - using System.Reflection; - using Http; - using Newtonsoft.Json; - /// - /// The firebase cache. + /// The firebase cache. /// /// Type of top-level entities in the cache. public class FirebaseCache : IEnumerable> @@ -17,13 +17,13 @@ namespace Firebase.Database.Streaming private readonly IDictionary dictionary; private readonly bool isDictionaryType; - private readonly JsonSerializerSettings serializerSettings = new JsonSerializerSettings() + private readonly JsonSerializerSettings serializerSettings = new JsonSerializerSettings { ObjectCreationHandling = ObjectCreationHandling.Replace }; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// public FirebaseCache() : this(new Dictionary()) @@ -31,7 +31,7 @@ namespace Firebase.Database.Streaming } /// - /// Initializes a new instance of the class and populates it with existing data. + /// Initializes a new instance of the class and populates it with existing data. /// /// The existing items. public FirebaseCache(IDictionary existingItems) @@ -41,10 +41,10 @@ namespace Firebase.Database.Streaming } /// - /// The push data. + /// The push data. /// - /// The path of incoming data, separated by slash. - /// The data in json format as returned by firebase. + /// The path of incoming data, separated by slash. + /// The data in json format as returned by firebase. /// Collection of top-level entities which were affected by the push. public IEnumerable> PushData(string path, string data, bool removeEmptyEntries = true) { @@ -63,7 +63,7 @@ namespace Firebase.Database.Streaming var dictionary = obj as IDictionary; var valueType = obj.GetType().GenericTypeArguments[1]; - primitiveObjSetter = (d) => dictionary[element] = d; + primitiveObjSetter = d => dictionary[element] = d; objDeleter = () => dictionary.Remove(element); if (dictionary.Contains(element)) @@ -87,7 +87,7 @@ namespace Firebase.Database.Streaming element == p.GetCustomAttribute()?.PropertyName); objDeleter = () => property.SetValue(objParent, null); - primitiveObjSetter = (d) => property.SetValue(objParent, d); + primitiveObjSetter = d => property.SetValue(objParent, d); obj = property.GetValue(obj); if (obj == null) { @@ -138,7 +138,7 @@ namespace Firebase.Database.Streaming // firebase sends strings without double quotes var targetObject = valueType == typeof(string) - ? data.ToString() + ? data : JsonConvert.DeserializeObject(data, valueType); if ((valueType.GetTypeInfo().IsPrimitive || valueType == typeof(string)) && primitiveObjSetter != null) @@ -161,8 +161,7 @@ namespace Firebase.Database.Streaming { if (type == typeof(string)) return string.Empty; - else - return Activator.CreateInstance(type); + return Activator.CreateInstance(type); } #region IEnumerable diff --git a/FireBase/Streaming/FirebaseEvent.cs b/FireBase/Streaming/FirebaseEvent.cs index e4fd238..1761a72 100644 --- a/FireBase/Streaming/FirebaseEvent.cs +++ b/FireBase/Streaming/FirebaseEvent.cs @@ -1,13 +1,13 @@ namespace Firebase.Database.Streaming { /// - /// Firebase event which hold and the object affected by the event. + /// Firebase event which hold and the object affected by the event. /// /// Type of object affected by the event. public class FirebaseEvent : FirebaseObject { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The key of the object. /// The object. @@ -20,12 +20,12 @@ namespace Firebase.Database.Streaming } /// - /// Gets the source of the event. + /// Gets the source of the event. /// public FirebaseEventSource EventSource { get; } /// - /// Gets the event type. + /// Gets the event type. /// public FirebaseEventType EventType { get; } diff --git a/FireBase/Streaming/FirebaseEventSource.cs b/FireBase/Streaming/FirebaseEventSource.cs index 0a397ad..b1385ca 100644 --- a/FireBase/Streaming/FirebaseEventSource.cs +++ b/FireBase/Streaming/FirebaseEventSource.cs @@ -1,37 +1,37 @@ namespace Firebase.Database.Streaming { /// - /// Specifies the origin of given + /// Specifies the origin of given /// public enum FirebaseEventSource { /// - /// Event comes from an offline source. + /// Event comes from an offline source. /// Offline, /// - /// Event comes from online source fetched during initial pull (valid only for RealtimeDatabase). + /// Event comes from online source fetched during initial pull (valid only for RealtimeDatabase). /// OnlineInitial, /// - /// Event comes from online source received thru active stream. + /// Event comes from online source received thru active stream. /// OnlineStream, /// - /// Event comes from online source being fetched manually. + /// Event comes from online source being fetched manually. /// OnlinePull, /// - /// Event raised after successful online push (valid only for RealtimeDatabase which isn't streaming). + /// Event raised after successful online push (valid only for RealtimeDatabase which isn't streaming). /// OnlinePush, /// - /// Event comes from an online source. + /// Event comes from an online source. /// Online = OnlineInitial | OnlinePull | OnlinePush | OnlineStream } diff --git a/FireBase/Streaming/FirebaseEventType.cs b/FireBase/Streaming/FirebaseEventType.cs index d8c65b3..7606331 100644 --- a/FireBase/Streaming/FirebaseEventType.cs +++ b/FireBase/Streaming/FirebaseEventType.cs @@ -1,17 +1,17 @@ namespace Firebase.Database.Streaming { /// - /// The type of event. + /// The type of event. /// public enum FirebaseEventType { /// - /// Item was inserted or updated. + /// Item was inserted or updated. /// InsertOrUpdate, /// - /// Item was deleted. + /// Item was deleted. /// Delete } diff --git a/FireBase/Streaming/FirebaseSubscription.cs b/FireBase/Streaming/FirebaseSubscription.cs index acdc76c..fb0f403 100644 --- a/FireBase/Streaming/FirebaseSubscription.cs +++ b/FireBase/Streaming/FirebaseSubscription.cs @@ -1,30 +1,28 @@ +using System; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Threading; +using System.Threading.Tasks; +using Firebase.Database.Query; +using Newtonsoft.Json.Linq; + namespace Firebase.Database.Streaming { - using System; - using System.Diagnostics; - using System.Linq; - using System.Net.Http; - using System.Net.Http.Headers; - using System.Threading; - using System.Threading.Tasks; - using Query; - using Newtonsoft.Json.Linq; - using System.Net; - /// - /// The firebase subscription. + /// The firebase subscription. /// /// Type of object to be streaming back to the called. internal class FirebaseSubscription : IDisposable { + private static readonly HttpClient http; + private readonly FirebaseCache cache; private readonly CancellationTokenSource cancel; + private readonly FirebaseClient client; + private readonly string elementRoot; private readonly IObserver> observer; private readonly IFirebaseQuery query; - private readonly FirebaseCache cache; - private readonly string elementRoot; - private readonly FirebaseClient client; - - private static HttpClient http; static FirebaseSubscription() { @@ -43,7 +41,7 @@ namespace Firebase.Database.Streaming } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The observer. /// The query. @@ -59,13 +57,13 @@ namespace Firebase.Database.Streaming client = query.Client; } - public event EventHandler> ExceptionThrown; - public void Dispose() { cancel.Cancel(); } + public event EventHandler> ExceptionThrown; + public IDisposable Run() { Task.Run(() => ReceiveThread()); diff --git a/FireBase/Streaming/NonBlockingStreamReader.cs b/FireBase/Streaming/NonBlockingStreamReader.cs index ab01510..8228e32 100644 --- a/FireBase/Streaming/NonBlockingStreamReader.cs +++ b/FireBase/Streaming/NonBlockingStreamReader.cs @@ -1,21 +1,24 @@ -namespace Firebase.Database.Streaming -{ - using System.IO; - using System.Text; +using System.IO; +using System.Text; +namespace Firebase.Database.Streaming +{ /// - /// When a regular is used in a UWP app its method tends to take a long - /// time for data larger then 2 KB. This extremly simple implementation of can be used instead to boost performance - /// in your UWP app. Use to inject an instance of this class into your . + /// When a regular is used in a UWP app its method + /// tends to take a long + /// time for data larger then 2 KB. This extremly simple implementation of can be used + /// instead to boost performance + /// in your UWP app. Use to inject an instance of this class into your + /// . /// public class NonBlockingStreamReader : TextReader { private const int DefaultBufferSize = 16000; - - private readonly Stream stream; private readonly byte[] buffer; private readonly int bufferSize; + private readonly Stream stream; + private string cachedData; public NonBlockingStreamReader(Stream stream, int bufferSize = DefaultBufferSize) -- cgit v1.2.3-54-g00ecf