diff options
author | Dennis Kobert <d-kobert@web.de> | 2019-06-12 21:47:51 +0200 |
---|---|---|
committer | Dennis Kobert <d-kobert@web.de> | 2019-06-12 21:47:51 +0200 |
commit | 304437b834e8c87687f68333ae67a13ee1377a73 (patch) | |
tree | 51dd246568e8a159627d9cb92e99890adb5cbef8 /dsa/FireBase/FirebaseKeyGenerator.cs | |
parent | 2fa4a0e50ebfc97059c8b84dbd17e79f9afc8a8d (diff) |
Adjust Codestyle
Diffstat (limited to 'dsa/FireBase/FirebaseKeyGenerator.cs')
-rw-r--r-- | dsa/FireBase/FirebaseKeyGenerator.cs | 21 |
1 files changed, 7 insertions, 14 deletions
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 { /// <summary> /// Offline key generator which mimics the official Firebase generators. /// Credit: https://github.com/bubbafat/FirebaseSharp/blob/master/src/FirebaseSharp.Portable/FireBasePushIdGenerator.cs /// </summary> - 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 /// <returns> /// The <see cref="string" />. /// </returns> - 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; |