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/FirebaseKeyGenerator.cs | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'dsa/FireBase/FirebaseKeyGenerator.cs') diff --git a/dsa/FireBase/FirebaseKeyGenerator.cs b/dsa/FireBase/FirebaseKeyGenerator.cs index 37beed5..2139b7a 100644 --- a/dsa/FireBase/FirebaseKeyGenerator.cs +++ b/dsa/FireBase/FirebaseKeyGenerator.cs @@ -1,14 +1,12 @@ using System; using System.Text; -namespace Firebase.Database -{ +namespace Firebase.Database { /// /// Offline key generator which mimics the official Firebase generators. /// Credit: https://github.com/bubbafat/FirebaseSharp/blob/master/src/FirebaseSharp.Portable/FireBasePushIdGenerator.cs /// - public class FirebaseKeyGenerator - { + public class FirebaseKeyGenerator { // Modeled after base64 web-safe chars, but ordered by ASCII. private const string PushCharsString = "-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz"; private static readonly char[] PushChars; @@ -20,8 +18,7 @@ namespace Firebase.Database // Timestamp of last push, used to prevent local collisions if you push twice in one ms. private static long lastPushTime; - static FirebaseKeyGenerator() - { + static FirebaseKeyGenerator() { PushChars = Encoding.UTF8.GetChars(Encoding.UTF8.GetBytes(PushCharsString)); } @@ -31,8 +28,7 @@ namespace Firebase.Database /// /// The . /// - public static string Next() - { + public static string Next() { // We generate 72-bits of randomness which get turned into 12 characters and // appended to the timestamp to prevent collisions with other clients. We store the last // characters we generated because in the event of a collision, we'll use those same @@ -43,8 +39,7 @@ namespace Firebase.Database lastPushTime = now; var timeStampChars = new char[8]; - for (var i = 7; i >= 0; i--) - { + for (var i = 7; i >= 0; i--) { var index = (int) (now % PushChars.Length); timeStampChars[i] = PushChars[index]; now = (long) Math.Floor((double) now / PushChars.Length); @@ -54,12 +49,10 @@ namespace Firebase.Database id.Append(timeStampChars); - if (!duplicateTime) - { + if (!duplicateTime) { for (var i = 0; i < 12; i++) lastRandChars[i] = (byte) random.Next(0, PushChars.Length); } - else - { + else { // If the timestamp hasn't changed since last push, use the same random number, // except incremented by 1. var lastIndex = 11; -- cgit v1.2.3-54-g00ecf