summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Kobert <d-kobert@web.de>2019-05-19 17:00:02 +0200
committerDennis Kobert <d-kobert@web.de>2019-05-19 17:00:02 +0200
commitc4d046858e0822b7c2c540ac2368b2c0e88e7a26 (patch)
tree8ff5cfd8646908784a45762a6148ebc150810160
parentf89f308c525e9deebc6d2cf6416e27dfe1a299dc (diff)
general refectoring
added 42 as dummy Token
-rw-r--r--DSACore/Auxiliary/Calculator/Argument.cs8
-rw-r--r--DSACore/Auxiliary/Calculator/ISolvable.cs2
-rw-r--r--DSACore/Auxiliary/Calculator/Operator.cs2
-rw-r--r--DSACore/Auxiliary/Calculator/Ops.cs2
-rw-r--r--DSACore/Auxiliary/Calculator/StringSolver.cs21
-rw-r--r--DSACore/Auxiliary/CommandInfo.cs6
-rw-r--r--DSACore/Auxiliary/SpellCorrect.cs10
-rw-r--r--DSACore/Auxiliary/TalentEnumerableExtension.cs4
-rw-r--r--DSACore/Auxiliary/WeaponImporter.cs10
-rw-r--r--DSACore/Commands/CommandHandler.cs4
-rw-r--r--DSACore/Commands/FileHandler.cs11
-rw-r--r--DSACore/Commands/Gm.cs9
-rw-r--r--DSACore/Commands/HeldList.cs2
-rw-r--r--DSACore/Commands/Help.cs27
-rw-r--r--DSACore/Commands/LebenUndAstral.cs4
-rw-r--r--DSACore/Commands/List.cs3
-rw-r--r--DSACore/Commands/MiscCommands.cs13
-rw-r--r--DSACore/Commands/NpcCommands.cs3
-rw-r--r--DSACore/Controllers/CommandsController.cs7
-rw-r--r--DSACore/Controllers/LobbyController.cs5
-rw-r--r--DSACore/Controllers/TokensController.cs11
-rw-r--r--DSACore/DSA_Game/Characters/Character.cs14
-rw-r--r--DSACore/DSA_Game/Characters/NPC.cs4
-rw-r--r--DSACore/DSA_Game/Dsa.cs15
-rw-r--r--DSACore/DSA_Game/Save/Properties.cs9
-rw-r--r--DSACore/DSA_Game/Save/SaveCommand.cs10
-rw-r--r--DSACore/DSA_Game/Save/Session.cs7
-rw-r--r--DSACore/FireBase/Database.cs55
-rw-r--r--DSACore/Hubs/Login.cs30
-rw-r--r--DSACore/Models/Database/DSA/DatabaseChar.cs3
-rw-r--r--DSACore/Models/Database/DSA/Weapon.cs18
-rw-r--r--DSACore/Models/Network/Command.cs4
-rw-r--r--DSACore/Models/Network/CommandResponse.cs7
-rw-r--r--DSACore/Models/Network/Group.cs2
-rw-r--r--DSACore/Models/Network/Token.cs10
-rw-r--r--DSACore/Models/Network/User.cs7
-rw-r--r--DSACore/Program.cs10
-rw-r--r--DSACore/Startup.cs9
-rw-r--r--DSALib/Characters/Being.cs4
-rw-r--r--DSALib/Characters/Critter.cs53
-rw-r--r--DSALib/Characters/ICombatant.cs8
-rw-r--r--DSALib/CritterAttack.cs8
-rw-r--r--FireBase/ExceptionEventArgs.cs10
-rw-r--r--FireBase/Extensions/ObservableExtensions.cs15
-rw-r--r--FireBase/Extensions/TaskExtensions.cs10
-rw-r--r--FireBase/FirebaseClient.cs34
-rw-r--r--FireBase/FirebaseException.cs16
-rw-r--r--FireBase/FirebaseKeyGenerator.cs15
-rw-r--r--FireBase/FirebaseObject.cs10
-rw-r--r--FireBase/FirebaseOptions.cs30
-rw-r--r--FireBase/Http/HttpClientExtensions.cs32
-rw-r--r--FireBase/Http/PostResult.cs4
-rw-r--r--FireBase/ObservableExtensions.cs16
-rw-r--r--FireBase/Offline/ConcurrentOfflineDatabase.cs128
-rw-r--r--FireBase/Offline/DatabaseExtensions.cs111
-rw-r--r--FireBase/Offline/ISetHandler.cs8
-rw-r--r--FireBase/Offline/InitialPullStrategy.cs10
-rw-r--r--FireBase/Offline/Internals/MemberAccessVisitor.cs16
-rw-r--r--FireBase/Offline/OfflineCacheAdapter.cs64
-rw-r--r--FireBase/Offline/OfflineDatabase.cs126
-rw-r--r--FireBase/Offline/OfflineEntry.cs43
-rw-r--r--FireBase/Offline/RealtimeDatabase.cs118
-rw-r--r--FireBase/Offline/SetHandler.cs8
-rw-r--r--FireBase/Offline/StreamingOptions.cs10
-rw-r--r--FireBase/Offline/SyncOptions.cs10
-rw-r--r--FireBase/Query/AuthQuery.cs14
-rw-r--r--FireBase/Query/ChildQuery.cs14
-rw-r--r--FireBase/Query/FilterQuery.cs38
-rw-r--r--FireBase/Query/FirebaseQuery.cs162
-rw-r--r--FireBase/Query/IFirebaseQuery.cs28
-rw-r--r--FireBase/Query/OrderQuery.cs12
-rw-r--r--FireBase/Query/ParameterQuery.cs18
-rw-r--r--FireBase/Query/QueryExtensions.cs68
-rw-r--r--FireBase/Query/QueryFactoryExtensions.cs85
-rw-r--r--FireBase/Query/SilentQuery.cs2
-rw-r--r--FireBase/Streaming/FirebaseCache.cs39
-rw-r--r--FireBase/Streaming/FirebaseEvent.cs8
-rw-r--r--FireBase/Streaming/FirebaseEventSource.cs14
-rw-r--r--FireBase/Streaming/FirebaseEventType.cs6
-rw-r--r--FireBase/Streaming/FirebaseSubscription.cs38
-rw-r--r--FireBase/Streaming/NonBlockingStreamReader.cs21
-rw-r--r--ZooBOTanica/CritCreate.cs11
-rw-r--r--ZooBOTanica/Program.cs5
-rw-r--r--ZooBOTanica/Properties/AssemblyInfo.cs1
84 files changed, 947 insertions, 932 deletions
diff --git a/DSACore/Auxiliary/Calculator/Argument.cs b/DSACore/Auxiliary/Calculator/Argument.cs
index 14982aa..5ed9ee3 100644
--- a/DSACore/Auxiliary/Calculator/Argument.cs
+++ b/DSACore/Auxiliary/Calculator/Argument.cs
@@ -1,9 +1,9 @@
-namespace DSACore.Auxiliary.Calculator
-{
- using System;
+using System;
+namespace DSACore.Auxiliary.Calculator
+{
/// <summary>
- /// Provides an ISolvable class to save numbers. The class handles Argument checking and conversion from string to int.
+ /// Provides an ISolvable class to save numbers. The class handles Argument checking and conversion from string to int.
/// </summary>
public class Argument : ISolvable
{
diff --git a/DSACore/Auxiliary/Calculator/ISolvable.cs b/DSACore/Auxiliary/Calculator/ISolvable.cs
index 2acbd11..7be4d19 100644
--- a/DSACore/Auxiliary/Calculator/ISolvable.cs
+++ b/DSACore/Auxiliary/Calculator/ISolvable.cs
@@ -1,7 +1,7 @@
namespace DSACore.Auxiliary.Calculator
{
/// <summary>
- /// Object has to be able to return an integer as it's value
+ /// Object has to be able to return an integer as it's value
/// </summary>
public interface ISolvable
{
diff --git a/DSACore/Auxiliary/Calculator/Operator.cs b/DSACore/Auxiliary/Calculator/Operator.cs
index ed46186..31b2a9b 100644
--- a/DSACore/Auxiliary/Calculator/Operator.cs
+++ b/DSACore/Auxiliary/Calculator/Operator.cs
@@ -4,7 +4,7 @@ using DSACorev.Auxiliary.Calculator;
namespace DSACore.Auxiliary.Calculator
{
/// <summary>
- /// The Operator Class represents a binary operator with tow Arguments and an Operation type
+ /// The Operator Class represents a binary operator with tow Arguments and an Operation type
/// </summary>
public class Operator : ISolvable
{
diff --git a/DSACore/Auxiliary/Calculator/Ops.cs b/DSACore/Auxiliary/Calculator/Ops.cs
index c804257..a5c9a2d 100644
--- a/DSACore/Auxiliary/Calculator/Ops.cs
+++ b/DSACore/Auxiliary/Calculator/Ops.cs
@@ -1,7 +1,7 @@
namespace DSACorev.Auxiliary.Calculator
{
/// <summary>
- /// The Different Operations, witch can be performed in execution-order
+ /// The Different Operations, witch can be performed in execution-order
/// </summary>
public enum Ops
{
diff --git a/DSACore/Auxiliary/Calculator/StringSolver.cs b/DSACore/Auxiliary/Calculator/StringSolver.cs
index 212f812..b2a7d83 100644
--- a/DSACore/Auxiliary/Calculator/StringSolver.cs
+++ b/DSACore/Auxiliary/Calculator/StringSolver.cs
@@ -5,28 +5,20 @@ using DSACorev.Auxiliary.Calculator;
namespace DSACore.Auxiliary.Calculator
{
- using System;
- using System.Collections.Generic;
- using System.Linq;
-
/// <summary>
- /// The StringSolver divides the calculation string into operations and SubStringSolvers if the string contains parentheses
+ /// The StringSolver divides the calculation string into operations and SubStringSolvers if the string contains
+ /// parentheses
/// </summary>
public class StringSolver : ISolvable
{
- private readonly string input;
private readonly List<object> arguments = new List<object>();
+ private readonly string input;
public StringSolver(string input)
{
this.input = input;
}
- public override string ToString()
- {
- return "(0+" + input.Replace(" ", string.Empty).ToLower() + ")";
- }
-
public int Solve()
{
var workInput = "0+" + input.Replace(" ", string.Empty).ToLower();
@@ -42,6 +34,11 @@ namespace DSACore.Auxiliary.Calculator
return ((ISolvable) arguments.First()).Solve();
}
+ public override string ToString()
+ {
+ return "(0+" + input.Replace(" ", string.Empty).ToLower() + ")";
+ }
+
private static string
GetInner(ref string input) // extract the inner bracket an remove the section from the input string
{
@@ -123,7 +120,7 @@ namespace DSACore.Auxiliary.Calculator
switch (c)
{
case ')':
- throw new ArgumentException($"Unmögliche Anordnung von Klammern");
+ throw new ArgumentException("Unmögliche Anordnung von Klammern");
case '(':
arguments.Add(new StringSolver(GetInner(ref workInput)));
index = -1;
diff --git a/DSACore/Auxiliary/CommandInfo.cs b/DSACore/Auxiliary/CommandInfo.cs
index 9afe6c0..1472587 100644
--- a/DSACore/Auxiliary/CommandInfo.cs
+++ b/DSACore/Auxiliary/CommandInfo.cs
@@ -1,8 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+using System.Linq;
namespace DSACore.Auxiliary
{
diff --git a/DSACore/Auxiliary/SpellCorrect.cs b/DSACore/Auxiliary/SpellCorrect.cs
index 3ef7bb6..77d1cf3 100644
--- a/DSACore/Auxiliary/SpellCorrect.cs
+++ b/DSACore/Auxiliary/SpellCorrect.cs
@@ -1,9 +1,9 @@
-namespace DSACore.Auxiliary
-{
- using System;
- using System.Diagnostics;
- using System.Linq;
+using System;
+using System.Diagnostics;
+using System.Linq;
+namespace DSACore.Auxiliary
+{
public class SpellCorrect : StringComparer
{
public const int ErrorThreshold = 94100;
diff --git a/DSACore/Auxiliary/TalentEnumerableExtension.cs b/DSACore/Auxiliary/TalentEnumerableExtension.cs
index 159480d..d83114c 100644
--- a/DSACore/Auxiliary/TalentEnumerableExtension.cs
+++ b/DSACore/Auxiliary/TalentEnumerableExtension.cs
@@ -1,7 +1,7 @@
-using DSACore.DSA_Game.Characters;
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Linq;
using System.Text;
+using DSACore.DSA_Game.Characters;
using DSALib;
namespace DSACore.Auxiliary
diff --git a/DSACore/Auxiliary/WeaponImporter.cs b/DSACore/Auxiliary/WeaponImporter.cs
index ab51efb..3375236 100644
--- a/DSACore/Auxiliary/WeaponImporter.cs
+++ b/DSACore/Auxiliary/WeaponImporter.cs
@@ -1,5 +1,4 @@
-using DSACore.Models.Database;
-using System;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
@@ -7,14 +6,13 @@ using System.Text.RegularExpressions;
using System.Threading.Tasks;
using DSACore.FireBase;
using DSACore.Models.Database.DSA;
-using Group = System.Text.RegularExpressions.Group;
namespace DSACore.Auxiliary
{
public class WeaponImporter
{
- private List<MeleeWeapon> Weapons = new List<MeleeWeapon>();
- private List<RangedWeapon> Range = new List<RangedWeapon>();
+ private readonly List<RangedWeapon> Range = new List<RangedWeapon>();
+ private readonly List<MeleeWeapon> Weapons = new List<MeleeWeapon>();
public async Task DownloadWeapons()
{
@@ -48,7 +46,7 @@ namespace DSACore.Auxiliary
{
var talent = lines[j];
- var values = await client.GetStringAsync($"http://diarium.eu/dsa4-forge/ajax/calculate/" + i + "/" +
+ var values = await client.GetStringAsync("http://diarium.eu/dsa4-forge/ajax/calculate/" + i + "/" +
ids[j] + "/0/0/0/0/0/10/0/0/0");
values = Regex.Unescape(values.Replace(@"\t", ""));
diff --git a/DSACore/Commands/CommandHandler.cs b/DSACore/Commands/CommandHandler.cs
index 6879045..f74f87f 100644
--- a/DSACore/Commands/CommandHandler.cs
+++ b/DSACore/Commands/CommandHandler.cs
@@ -1,7 +1,7 @@
using System;
using DSACore.Auxiliary;
+using DSACore.Auxiliary.Calculator;
using DSACore.DSA_Game;
-using DSACore.Models;
using DSACore.Models.Network;
namespace DSACore.Commands
@@ -49,7 +49,7 @@ namespace DSACore.Commands
res = RandomMisc.Roll(cmd.CmdText + " " + cmd.Cmdmodifier);
break;
case "solve":
- res = new Auxiliary.Calculator.StringSolver(cmd.CmdText + cmd.Cmdmodifier).Solve().ToString();
+ res = new StringSolver(cmd.CmdText + cmd.Cmdmodifier).Solve().ToString();
break;
case "npc":
res = NpcCommands.CreateNpc(cmd.CharId, cmd.CmdTexts, cmd.Cmdmodifier);
diff --git a/DSACore/Commands/FileHandler.cs b/DSACore/Commands/FileHandler.cs
index d8fb585..bce7c54 100644
--- a/DSACore/Commands/FileHandler.cs
+++ b/DSACore/Commands/FileHandler.cs
@@ -1,13 +1,12 @@
-using DSACore.DSA_Game;
+using System;
+using System.Linq;
+using System.Net;
+using DSACore.DSA_Game;
using DSACore.DSA_Game.Characters;
+using DSALib;
namespace DSACore.Commands
{
- using System;
- using System.Linq;
- using System.Net;
- using DSALib;
-
public class FileHandler
{
public static string AddChar(ulong id, string url)
diff --git a/DSACore/Commands/Gm.cs b/DSACore/Commands/Gm.cs
index 59b3129..98b62db 100644
--- a/DSACore/Commands/Gm.cs
+++ b/DSACore/Commands/Gm.cs
@@ -1,12 +1,5 @@
-using DSACore.Auxiliary;
-using DSACore.DSA_Game;
-
-namespace DSACore.Commands
+namespace DSACore.Commands
{
- using System.Linq;
- using System.Threading.Tasks;
- using DSALib.Characters;
-
/*public class Iam
{
diff --git a/DSACore/Commands/HeldList.cs b/DSACore/Commands/HeldList.cs
index 73861b7..370af34 100644
--- a/DSACore/Commands/HeldList.cs
+++ b/DSACore/Commands/HeldList.cs
@@ -1,9 +1,9 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
-using DSACore.DSA_Game.Characters;
using DSACore.Auxiliary;
using DSACore.DSA_Game;
+using DSACore.DSA_Game.Characters;
namespace DSACore.Commands
{
diff --git a/DSACore/Commands/Help.cs b/DSACore/Commands/Help.cs
index 6458c20..974c44c 100644
--- a/DSACore/Commands/Help.cs
+++ b/DSACore/Commands/Help.cs
@@ -1,39 +1,18 @@
using System.Linq;
-using System.Threading.Tasks;
using DSACore.Auxiliary;
+using DSACore.DSA_Game.Save;
namespace DSACore.Commands
{
public class Help
{
- static Help()
- {
- /*TextReader stream = new StreamReader(@"..\..\Help.json"); // Load command-description file
- var reader = new JsonTextReader(stream); // create stream reader
-
- reader.Read(); // step into structure, until the array starts
- reader.Read();
- reader.Read();
-
- try
- {
- var test = new JsonSerializer().Deserialize<List<CommandInfo>>(reader); // Deserialize Data and create CommandInfo Struct
-
- Commands.AddRange(test); // Add new CommandInfos to List
- }
- catch (Exception e)
- {
- // ignored
- }*/
- }
-
//public static List<CommandInfo> Commands { get; } = new List<CommandInfo>();
public static string Get_Specific_Help(string command)
{
// return command specific help
- var com = DSA_Game.Save.Properties.CommandInfos
+ var com = Properties.CommandInfos
.OrderBy(x => SpellCorrect.CompareEasy(x.Name, command.ToLower())).First(); // get best fit command
return com.GetDescription();
}
@@ -41,7 +20,7 @@ namespace DSACore.Commands
public static string Get_Generic_Help()
{
var res = "";
- foreach (var com in DSA_Game.Save.Properties.CommandInfos)
+ foreach (var com in Properties.CommandInfos)
{
var first_column_width = 8;
res += ("!" + com.Name + ": ").AddSpaces(first_column_width) + com.Brief;
diff --git a/DSACore/Commands/LebenUndAstral.cs b/DSACore/Commands/LebenUndAstral.cs
index 7e0cb5c..a671296 100644
--- a/DSACore/Commands/LebenUndAstral.cs
+++ b/DSACore/Commands/LebenUndAstral.cs
@@ -1,8 +1,6 @@
using System;
-using System.Linq;
-using System.Threading.Tasks;
-using DSACore.DSA_Game;
using DSACore.Auxiliary;
+using DSACore.DSA_Game;
using DSALib.Characters;
namespace DSACore.Commands
diff --git a/DSACore/Commands/List.cs b/DSACore/Commands/List.cs
index 2c8f3d0..7fc682f 100644
--- a/DSACore/Commands/List.cs
+++ b/DSACore/Commands/List.cs
@@ -1,9 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using System.Threading.Tasks;
-using DSACore.DSA_Game;
using DSACore.Audio;
+using DSACore.DSA_Game;
namespace DSACore.Commands
{
diff --git a/DSACore/Commands/MiscCommands.cs b/DSACore/Commands/MiscCommands.cs
index 36d5fb1..ebd1598 100644
--- a/DSACore/Commands/MiscCommands.cs
+++ b/DSACore/Commands/MiscCommands.cs
@@ -1,15 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Net.Http;
-using System.Text;
-using System.Threading.Tasks;
-using DSACore.DSA_Game;
-using DSACore.Auxiliary;
-using Microsoft.AspNetCore.Hosting.Internal;
-
-namespace DSACore.Commands
+namespace DSACore.Commands
{
public class MiscCommands
{
diff --git a/DSACore/Commands/NpcCommands.cs b/DSACore/Commands/NpcCommands.cs
index 9a27e6a..95243ca 100644
--- a/DSACore/Commands/NpcCommands.cs
+++ b/DSACore/Commands/NpcCommands.cs
@@ -1,12 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using System.Threading.Tasks;
using DSACore.Characters;
using DSACore.DSA_Game;
using DSACore.DSA_Game.Characters;
-using DSACore.Auxiliary;
-using Microsoft.AspNetCore.Mvc.Internal;
namespace DSACore.Commands
{
diff --git a/DSACore/Controllers/CommandsController.cs b/DSACore/Controllers/CommandsController.cs
index e9700ff..5addf82 100644
--- a/DSACore/Controllers/CommandsController.cs
+++ b/DSACore/Controllers/CommandsController.cs
@@ -1,8 +1,5 @@
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
-using DSACore.Models;
+using DSACore.Commands;
using DSACore.Models.Network;
using Microsoft.AspNetCore.Mvc;
@@ -33,7 +30,7 @@ namespace DSACore.Controllers
{
try
{
- return Commands.CommandHandler.ExecuteCommand(cmd).message;
+ return CommandHandler.ExecuteCommand(cmd).message;
}
catch (Exception e)
{
diff --git a/DSACore/Controllers/LobbyController.cs b/DSACore/Controllers/LobbyController.cs
index 100fb5b..df22607 100644
--- a/DSACore/Controllers/LobbyController.cs
+++ b/DSACore/Controllers/LobbyController.cs
@@ -1,5 +1,6 @@
-using DSACore.Models.Network;
using System;
+using DSACore.Commands;
+using DSACore.Models.Network;
using Microsoft.AspNetCore.Mvc;
namespace DSACore.Controllers
@@ -19,7 +20,7 @@ namespace DSACore.Controllers
{
try
{
- return Commands.CommandHandler.ExecuteCommand(cmd).message;
+ return CommandHandler.ExecuteCommand(cmd).message;
}
catch (Exception e)
{
diff --git a/DSACore/Controllers/TokensController.cs b/DSACore/Controllers/TokensController.cs
index 6a59db4..a85cabe 100644
--- a/DSACore/Controllers/TokensController.cs
+++ b/DSACore/Controllers/TokensController.cs
@@ -1,3 +1,4 @@
+using DSACore.Hubs;
using Microsoft.AspNetCore.Mvc;
namespace DSACore.Controllers
@@ -10,13 +11,15 @@ namespace DSACore.Controllers
[HttpGet("{token}")]
public ActionResult<string> Get(string token)
{
- if (!int.TryParse(token, out var inttoken))
+ if (!int.TryParse(token, out var intToken))
return BadRequest("The token has to be a 32 bit unsigned integer");
- if (!Hubs.Users.Tokens.Exists(x => x.GetHashCode() == inttoken)) return NotFound();
+ if (intToken == 42) return Ok("Scribble");
+
+ if (!Users.Tokens.Exists(x => x.GetHashCode() == intToken)) return NotFound();
- var group = Hubs.Users.Tokens.Find(x => x.GetHashCode() == inttoken);
- return Ok(group);
+ var group = Users.Tokens.Find(x => x.GetHashCode() == intToken);
+ return Ok(group.Group);
}
}
} \ No newline at end of file
diff --git a/DSACore/DSA_Game/Characters/Character.cs b/DSACore/DSA_Game/Characters/Character.cs
index 62d2e11..ac890cb 100644
--- a/DSACore/DSA_Game/Characters/Character.cs
+++ b/DSACore/DSA_Game/Characters/Character.cs
@@ -1,17 +1,15 @@
-using System.IO;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Xml;
using DSACore.Auxiliary;
using DSALib;
using DSALib.Characters;
namespace DSACore.DSA_Game.Characters
{
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Xml;
-
-
public class Character : Being, ICharacter
{
public Character()
diff --git a/DSACore/DSA_Game/Characters/NPC.cs b/DSACore/DSA_Game/Characters/NPC.cs
index e6b7bed..75c3fe9 100644
--- a/DSACore/DSA_Game/Characters/NPC.cs
+++ b/DSACore/DSA_Game/Characters/NPC.cs
@@ -4,10 +4,6 @@ using DSALib.Characters;
namespace DSACore.Characters
{
- using System;
- using Auxiliary;
- using DSACore.DSA_Game.Characters;
-
public class Npc : Being, ICharacter
{
private readonly int mean, stDv;
diff --git a/DSACore/DSA_Game/Dsa.cs b/DSACore/DSA_Game/Dsa.cs
index f2ffe48..18d0b81 100644
--- a/DSACore/DSA_Game/Dsa.cs
+++ b/DSACore/DSA_Game/Dsa.cs
@@ -1,18 +1,13 @@
using System;
-using DSACore.Auxiliary;
-using DSACore.FireBase;
+using System.Collections.Generic;
+using System.Linq;
+using DSACore.DSA_Game.Characters;
+using DSACore.DSA_Game.Save;
using DSALib;
using DSALib.Characters;
-using Microsoft.EntityFrameworkCore.Design;
namespace DSACore.DSA_Game
{
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using Characters;
- using Save;
-
public static class Dsa
{
#if DEBUG
@@ -59,7 +54,7 @@ namespace DSACore.DSA_Game
}
*/
- Properties.Deserialize(rootPath + "Properties");
+ Properties.Deserialize();
Properties.Serialize(rootPath + "Properties");
diff --git a/DSACore/DSA_Game/Save/Properties.cs b/DSACore/DSA_Game/Save/Properties.cs
index 50bd8fa..7eba911 100644
--- a/DSACore/DSA_Game/Save/Properties.cs
+++ b/DSACore/DSA_Game/Save/Properties.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@@ -8,10 +9,6 @@ using Newtonsoft.Json;
namespace DSACore.DSA_Game.Save
{
- using System.Collections;
- using System.IO;
- using Newtonsoft.Json;
-
public static class Properties
{
public static Dictionary<string, object> objects;
@@ -64,7 +61,7 @@ namespace DSACore.DSA_Game.Save
foreach (var o in objects)
{
var assembly = o.Value is IList list
- ? ((IList) list)[0]?.GetType().FullName
+ ? list[0]?.GetType().FullName
: o.Value.GetType().FullName;
var name = path + assembly.Replace('.', '-') + ".json";
@@ -76,7 +73,7 @@ namespace DSACore.DSA_Game.Save
catch (Exception e)
{
// ignored
- Console.WriteLine($"Speichern von Save-File fehlgeschlagen." + e);
+ Console.WriteLine("Speichern von Save-File fehlgeschlagen." + e);
}
}
}
diff --git a/DSACore/DSA_Game/Save/SaveCommand.cs b/DSACore/DSA_Game/Save/SaveCommand.cs
index 80d4426..f358047 100644
--- a/DSACore/DSA_Game/Save/SaveCommand.cs
+++ b/DSACore/DSA_Game/Save/SaveCommand.cs
@@ -1,18 +1,16 @@
using System;
+using System.IO;
using System.Linq;
-using System.Threading.Tasks;
namespace DSACore.DSA_Game.Save
{
- using System.IO;
-
public class SaveCommand
{
public void LoadSession(string name = "")
{
if (name.Equals("?") || name.Equals(string.Empty))
{
- Console.WriteLine($"Gespeicherte Sessions:");
+ Console.WriteLine("Gespeicherte Sessions:");
Console.WriteLine(ListSessions());
return;
}
@@ -32,7 +30,7 @@ namespace DSACore.DSA_Game.Save
if (name.Equals("?") || name.Equals(string.Empty))
{
- Console.WriteLine($"Gespeicherte Sessions:");
+ Console.WriteLine("Gespeicherte Sessions:");
Console.WriteLine(ListSessions());
return;
}
@@ -49,7 +47,7 @@ namespace DSACore.DSA_Game.Save
{
Directory.CreateDirectory(path);
Dsa.Session.SessionName = name;
- Dsa.Session.Save(path + "\\" + name + $"-0.json");
+ Dsa.Session.Save(path + "\\" + name + "-0.json");
}
Console.WriteLine($"{name} wurde gespeichert");
diff --git a/DSACore/DSA_Game/Save/Session.cs b/DSACore/DSA_Game/Save/Session.cs
index 595f0e8..6944fb1 100644
--- a/DSACore/DSA_Game/Save/Session.cs
+++ b/DSACore/DSA_Game/Save/Session.cs
@@ -1,12 +1,11 @@
using System;
using System.Collections.Generic;
+using System.IO;
+using DSACore.DSA_Game.Characters;
+using Newtonsoft.Json;
namespace DSACore.DSA_Game.Save
{
- using System.IO;
- using Characters;
- using Newtonsoft.Json;
-
public class Session
{
public static string DirectoryPath { get; set; } = Dsa.rootPath + @"sessions";
diff --git a/DSACore/FireBase/Database.cs b/DSACore/FireBase/Database.cs
index abe2b92..8946cf0 100644
--- a/DSACore/FireBase/Database.cs
+++ b/DSACore/FireBase/Database.cs
@@ -1,14 +1,13 @@
-using DSACore.DSA_Game.Characters;
-using DSACore.Models.Database;
-using Firebase.Database;
-using Firebase.Database.Query;
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
+using DSACore.DSA_Game;
+using DSACore.DSA_Game.Characters;
using DSACore.Models.Database.DSA;
-using DSACore.Models.Database.Groups;
-
+using DSACore.Models.Network;
+using Firebase.Database;
+using Firebase.Database.Query;
namespace DSACore.FireBase
{
@@ -16,9 +15,19 @@ namespace DSACore.FireBase
{
public static FirebaseClient firebase;
+ public static Dictionary<string, DatabaseChar> Chars = new Dictionary<string, DatabaseChar>();
+
+ public static Dictionary<string, MeleeWeapon> MeleeList = new Dictionary<string, MeleeWeapon>();
+
+ public static Dictionary<string, RangedWeapon> RangedWeapons = new Dictionary<string, RangedWeapon>();
+
+ public static Dictionary<string, Talent> Talents = new Dictionary<string, Talent>();
+
+ public static Dictionary<string, GeneralSpell> Spells = new Dictionary<string, GeneralSpell>();
+
static Database()
{
- var auth = File.ReadAllText(DSA_Game.Dsa.rootPath + "Token");
+ var auth = File.ReadAllText(Dsa.rootPath + "Token");
; // your app secret
firebase = new FirebaseClient(
"https://heldenonline-4d828.firebaseio.com/",
@@ -49,17 +58,7 @@ namespace DSACore.FireBase
foreach (var firebaseObject in temp) list.Add(firebaseObject.Key, firebaseObject.Object);
}
- public static Dictionary<string, DatabaseChar> Chars = new Dictionary<string, DatabaseChar>();
-
- public static Dictionary<string, MeleeWeapon> MeleeList = new Dictionary<string, MeleeWeapon>();
-
- public static Dictionary<string, RangedWeapon> RangedWeapons = new Dictionary<string, RangedWeapon>();
-
- public static Dictionary<string, Talent> Talents = new Dictionary<string, Talent>();
-
- public static Dictionary<string, GeneralSpell> Spells = new Dictionary<string, GeneralSpell>();
-
- public static async Task<int> AddChar(Character file, Models.Network.Group group)
+ public static async Task<int> AddChar(Character file, Group group)
{
DatabaseChar.LoadChar(file, out var groupChar, out var data);
@@ -216,36 +215,36 @@ namespace DSACore.FireBase
.OnceSingleAsync<Weapon>();
}
- public static async Task<List<Models.Network.Group>> GetGroups()
+ public static async Task<List<Group>> GetGroups()
{
var groups = await firebase
.Child("Groups")
.OrderByKey()
- .OnceAsync<Group>();
- var ret = new List<Models.Network.Group>();
+ .OnceAsync<Models.Database.Groups.Group>();
+ var ret = new List<Group>();
foreach (var firebaseObject in groups)
- ret.Add(new Models.Network.Group(firebaseObject.Object.Name, firebaseObject.Object.Password));
+ ret.Add(new Group(firebaseObject.Object.Name, firebaseObject.Object.Password));
return ret;
}
- public static async Task<Group> GetGroup(int id)
+ public static async Task<Models.Database.Groups.Group> GetGroup(int id)
{
var group = await firebase
.Child("Groups")
.Child("Group" + id)
- .OnceSingleAsync<Group>();
+ .OnceSingleAsync<Models.Database.Groups.Group>();
return group;
}
- public static async Task AddGroup(Group group)
+ public static async Task AddGroup(Models.Database.Groups.Group group)
{
var lastChar = await firebase
.Child("Groups")
.OrderByKey()
.LimitToLast(1)
- .OnceAsync<Group>();
+ .OnceAsync<Models.Database.Groups.Group>();
var id = group.Id = lastChar.First().Object.Id + 1;
await firebase
@@ -254,7 +253,7 @@ namespace DSACore.FireBase
.PutAsync(group);
}
- public static async void SetGroup(Group group)
+ public static async void SetGroup(Models.Database.Groups.Group group)
{
await firebase
.Child("Groups")
diff --git a/DSACore/Hubs/Login.cs b/DSACore/Hubs/Login.cs
index f589e49..1f6ca39 100644
--- a/DSACore/Hubs/Login.cs
+++ b/DSACore/Hubs/Login.cs
@@ -1,14 +1,14 @@
-using DSACore.DSA_Game.Characters;
-using DSACore.FireBase;
-using DSACore.Models.Network;
-using Microsoft.AspNetCore.SignalR;
-using System;
+using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
+using DSACore.Commands;
+using DSACore.DSA_Game.Characters;
+using DSACore.FireBase;
+using DSACore.Models.Network;
+using Microsoft.AspNetCore.SignalR;
namespace DSACore.Hubs
{
@@ -18,9 +18,6 @@ namespace DSACore.Hubs
private const string ReceiveMethod = "ReceiveMessage"; //receiveMethod;
- private static List<Group> DsaGroups { get; set; }
- public static List<Token> Tokens { get; } = new List<Token>();
-
static Users()
{
DsaGroups = Database.GetGroups().Result;
@@ -29,6 +26,9 @@ namespace DSACore.Hubs
//AddGroups();
}
+ private static List<Group> DsaGroups { get; }
+ public static List<Token> Tokens { get; } = new List<Token>();
+
[Obsolete]
private static async void AddGroups()
@@ -60,7 +60,7 @@ namespace DSACore.Hubs
var ident = args.First().Replace("/", "");
if (args.Count > 0) args.RemoveAt(0);
- var ret = Commands.CommandHandler.ExecuteCommand(new Command
+ var ret = CommandHandler.ExecuteCommand(new Command
{
CharId = 0,
CmdIdentifier = ident,
@@ -116,8 +116,8 @@ namespace DSACore.Hubs
var test = await Database.GetGroups();
foreach (var group in test)
- if (!DsaGroups.Exists(x => x.Name.Equals(@group.Name)))
- DsaGroups.Add(@group);
+ if (!DsaGroups.Exists(x => x.Name.Equals(group.Name)))
+ DsaGroups.Add(group);
await Clients.Caller.SendCoreAsync("ListGroups", new object[] {DsaGroups.Select(x => x.SendGroup())});
//throw new NotImplementedException("add database call to get groups");
@@ -128,7 +128,7 @@ namespace DSACore.Hubs
DsaGroups.Add(new Group(group, password));
var Dgroup = new Models.Database.Groups.Group {Name = group, Id = DsaGroups.Count - 1};
//Database.AddGroup(Dgroup);
- await Clients.Caller.SendCoreAsync(ReceiveMethod, new[] {$"group {@group} sucessfully added"});
+ await Clients.Caller.SendCoreAsync(ReceiveMethod, new[] {$"group {group} sucessfully added"});
//throw new NotImplementedException("add database call to add groups");
}
@@ -202,8 +202,8 @@ namespace DSACore.Hubs
await Clients.Caller.SendAsync("PlayerStatusChanged", new[] {user.Name, "offline"});
//await SendToGroup(user.Name + " disconnected from the Server");
- @group.Users.Remove(user);
- await Groups.RemoveFromGroupAsync(Context.ConnectionId, @group.Name);
+ group.Users.Remove(user);
+ await Groups.RemoveFromGroupAsync(Context.ConnectionId, group.Name);
}
catch (Exception e)
{
diff --git a/DSACore/Models/Database/DSA/DatabaseChar.cs b/DSACore/Models/Database/DSA/DatabaseChar.cs
index 6a57629..872b82e 100644
--- a/DSACore/Models/Database/DSA/DatabaseChar.cs
+++ b/DSACore/Models/Database/DSA/DatabaseChar.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using DSACore.DSA_Game.Characters;
namespace DSACore.Models.Database.DSA
{
@@ -40,7 +41,7 @@ namespace DSACore.Models.Database.DSA
public List<WeaponTalent> WeaponTalents { get; set; } = new List<WeaponTalent>();
- public static void LoadChar(DSA_Game.Characters.Character file, out GroupChar group, out DatabaseChar data)
+ public static void LoadChar(Character file, out GroupChar group, out DatabaseChar data)
{
group = new GroupChar();
data = new DatabaseChar();
diff --git a/DSACore/Models/Database/DSA/Weapon.cs b/DSACore/Models/Database/DSA/Weapon.cs
index d6d7999..58a44cd 100644
--- a/DSACore/Models/Database/DSA/Weapon.cs
+++ b/DSACore/Models/Database/DSA/Weapon.cs
@@ -26,27 +26,27 @@ namespace DSACore.Models.Database.DSA
public class MeleeWeapon : Weapon
{
- public string TpKK { get; set; }
- public int INI { get; set; }
- public string MW { get; set; }
-
public MeleeWeapon(string name, string damage, int weight, string weaponTalent, string price) : base(name,
damage, weight, weaponTalent, price)
{
}
+
+ public string TpKK { get; set; }
+ public int INI { get; set; }
+ public string MW { get; set; }
}
public class RangedWeapon : Weapon
{
+ public RangedWeapon(string name, string damage, int weight, string weaponTalent, string price) : base(name,
+ damage, weight, weaponTalent, price)
+ {
+ }
+
public int AtMod { get; set; }
public int KKMod { get; set; }
public string AtReach { get; set; }
public string TpReach { get; set; }
public int LoadTime { get; set; }
-
- public RangedWeapon(string name, string damage, int weight, string weaponTalent, string price) : base(name,
- damage, weight, weaponTalent, price)
- {
- }
}
} \ No newline at end of file
diff --git a/DSACore/Models/Network/Command.cs b/DSACore/Models/Network/Command.cs
index 316461e..00b00a6 100644
--- a/DSACore/Models/Network/Command.cs
+++ b/DSACore/Models/Network/Command.cs
@@ -1,7 +1,5 @@
-using System;
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Linq;
-using System.Threading.Tasks;
namespace DSACore.Models.Network
{
diff --git a/DSACore/Models/Network/CommandResponse.cs b/DSACore/Models/Network/CommandResponse.cs
index 7478397..c7a410a 100644
--- a/DSACore/Models/Network/CommandResponse.cs
+++ b/DSACore/Models/Network/CommandResponse.cs
@@ -1,7 +1,4 @@
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
namespace DSACore.Models.Network
{
@@ -13,8 +10,8 @@ namespace DSACore.Models.Network
ResponseType = responseType;
}
- public string message { get; private set; }
- public ResponseType ResponseType { get; private set; }
+ public string message { get; }
+ public ResponseType ResponseType { get; }
public override string ToString()
{
diff --git a/DSACore/Models/Network/Group.cs b/DSACore/Models/Network/Group.cs
index 3a8ce77..efe12ee 100644
--- a/DSACore/Models/Network/Group.cs
+++ b/DSACore/Models/Network/Group.cs
@@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
namespace DSACore.Models.Network
{
diff --git a/DSACore/Models/Network/Token.cs b/DSACore/Models/Network/Token.cs
index 0021317..451cafc 100644
--- a/DSACore/Models/Network/Token.cs
+++ b/DSACore/Models/Network/Token.cs
@@ -1,18 +1,18 @@
using System;
-using Microsoft.EntityFrameworkCore;
namespace DSACore.Models.Network
{
public class Token
{
- public string Group { get; set; }
- private DateTime creation = DateTime.Now;
+ private readonly DateTime creation = DateTime.Now;
- public Token(string @group)
+ public Token(string group)
{
- Group = @group;
+ Group = group;
}
+ public string Group { get; set; }
+
public bool IsValid()
{
return DateTime.Now - creation < TimeSpan.FromMinutes(1);
diff --git a/DSACore/Models/Network/User.cs b/DSACore/Models/Network/User.cs
index 97a9224..8b8008c 100644
--- a/DSACore/Models/Network/User.cs
+++ b/DSACore/Models/Network/User.cs
@@ -1,9 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
-
-namespace DSACore.Models.Network
+namespace DSACore.Models.Network
{
public class User
{
diff --git a/DSACore/Program.cs b/DSACore/Program.cs
index 357f919..46baf2d 100644
--- a/DSACore/Program.cs
+++ b/DSACore/Program.cs
@@ -1,13 +1,7 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Threading.Tasks;
+using DSACore.DSA_Game;
using DSACore.FireBase;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
-using Microsoft.Extensions.Configuration;
-using Microsoft.Extensions.Logging;
namespace DSACore
{
@@ -16,7 +10,7 @@ namespace DSACore
public static void Main(string[] args)
{
Database.GetGroup(0).Wait();
- DSA_Game.Dsa.Startup();
+ Dsa.Startup();
CreateWebHostBuilder(args).Build().Run();
}
diff --git a/DSACore/Startup.cs b/DSACore/Startup.cs
index 6f3ec79..372caca 100644
--- a/DSACore/Startup.cs
+++ b/DSACore/Startup.cs
@@ -1,16 +1,9 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
+using DSACore.Hubs;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
-using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.AspNetCore.Mvc;
-using DSACore.Hubs;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
-using Microsoft.Extensions.Logging;
-using Microsoft.Extensions.Options;
namespace DSACore
{
diff --git a/DSALib/Characters/Being.cs b/DSALib/Characters/Being.cs
index cf338f9..27879a1 100644
--- a/DSALib/Characters/Being.cs
+++ b/DSALib/Characters/Being.cs
@@ -1,6 +1,4 @@
-using DiscoBot.DSA_Game.Characters;
-
-namespace DSALib.Characters
+namespace DSALib.Characters
{
public class Being : Entity
{
diff --git a/DSALib/Characters/Critter.cs b/DSALib/Characters/Critter.cs
index c511090..d9f8b53 100644
--- a/DSALib/Characters/Critter.cs
+++ b/DSALib/Characters/Critter.cs
@@ -1,14 +1,32 @@
using System;
using System.Collections.Generic;
+using System.IO;
+using DiscoBot.DSA_Game.Characters;
+using Newtonsoft.Json;
namespace DSALib.Characters
{
- using System.IO;
- using DiscoBot.DSA_Game.Characters;
- using Newtonsoft.Json;
-
public class Critter : Being, ICombatant
{
+ public CritterAttack lastAttack;
+
+ public Critter(int gw, int gs, int rs, int mr, int ko, int pa, string ini, List<CritterAttack> critterAttacks)
+ {
+ Gw = gw;
+ Gs = gs;
+ Rs = rs;
+ Mr = mr;
+ Ko = ko;
+ Pa = pa;
+ Ini = ini;
+ CritterAttacks = critterAttacks;
+ lastAttack = CritterAttacks[new Random().Next(critterAttacks.Count)];
+ }
+
+ public Critter()
+ {
+ }
+
public int Rs { get; set; }
public int Mr { get; set; }
@@ -27,23 +45,14 @@ namespace DSALib.Characters
public List<CritterAttack> CritterAttacks { get; set; }
- public CritterAttack lastAttack;
-
- public Critter(int gw, int gs, int rs, int mr, int ko, int pa, string ini, List<CritterAttack> critterAttacks)
+ public string Angriff(string talent, int erschwernis = 0)
{
- Gw = gw;
- Gs = gs;
- Rs = rs;
- Mr = mr;
- Ko = ko;
- Pa = pa;
- Ini = ini;
- CritterAttacks = critterAttacks;
- lastAttack = CritterAttacks[new Random().Next(critterAttacks.Count)];
+ throw new NotImplementedException();
}
- public Critter()
+ public string Parade(string talent, int erschwernis = 0)
{
+ throw new NotImplementedException();
}
public static Critter Load(string path)
@@ -61,16 +70,6 @@ namespace DSALib.Characters
}
}
- public string Angriff(string talent, int erschwernis = 0)
- {
- throw new NotImplementedException();
- }
-
- public string Parade(string talent, int erschwernis = 0)
- {
- throw new NotImplementedException();
- }
-
public void Save(string path = @"..\..\Critters\")
{
try
diff --git a/DSALib/Characters/ICombatant.cs b/DSALib/Characters/ICombatant.cs
index 887893c..a4ce601 100644
--- a/DSALib/Characters/ICombatant.cs
+++ b/DSALib/Characters/ICombatant.cs
@@ -1,10 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace DiscoBot.DSA_Game.Characters
+namespace DiscoBot.DSA_Game.Characters
{
public interface ICombatant
{
diff --git a/DSALib/CritterAttack.cs b/DSALib/CritterAttack.cs
index 5fdcffa..3b0a11d 100644
--- a/DSALib/CritterAttack.cs
+++ b/DSALib/CritterAttack.cs
@@ -1,10 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace DSALib
+namespace DSALib
{
public class CritterAttack
{
diff --git a/FireBase/ExceptionEventArgs.cs b/FireBase/ExceptionEventArgs.cs
index 185c952..09c205a 100644
--- a/FireBase/ExceptionEventArgs.cs
+++ b/FireBase/ExceptionEventArgs.cs
@@ -1,16 +1,16 @@
-namespace Firebase.Database
-{
- using System;
+using System;
+namespace Firebase.Database
+{
/// <summary>
- /// Event args holding the <see cref="Exception"/> object.
+ /// Event args holding the <see cref="Exception" /> object.
/// </summary>
public class ExceptionEventArgs<T> : EventArgs where T : Exception
{
public readonly T Exception;
/// <summary>
- /// Initializes a new instance of the <see cref="ExceptionEventArgs"/> class.
+ /// Initializes a new instance of the <see cref="ExceptionEventArgs" /> class.
/// </summary>
/// <param name="exception"> The exception. </param>
public ExceptionEventArgs(T exception)
diff --git a/FireBase/Extensions/ObservableExtensions.cs b/FireBase/Extensions/ObservableExtensions.cs
index cb41bcc..0a672d7 100644
--- a/FireBase/Extensions/ObservableExtensions.cs
+++ b/FireBase/Extensions/ObservableExtensions.cs
@@ -1,19 +1,20 @@
-namespace Firebase.Database.Extensions
-{
- using System;
- using System.Reactive.Linq;
+using System;
+using System.Reactive.Linq;
+namespace Firebase.Database.Extensions
+{
public static class ObservableExtensions
{
/// <summary>
- /// Returns a cold observable which retries (re-subscribes to) the source observable on error until it successfully terminates.
+ /// Returns a cold observable which retries (re-subscribes to) the source observable on error until it successfully
+ /// terminates.
/// </summary>
/// <param name="source">The source observable.</param>
/// <param name="dueTime">How long to wait between attempts.</param>
/// <param name="retryOnError">A predicate determining for which exceptions to retry. Defaults to all</param>
/// <returns>
- /// A cold observable which retries (re-subscribes to) the source observable on error up to the
- /// specified number of times or until it successfully terminates.
+ /// A cold observable which retries (re-subscribes to) the source observable on error up to the
+ /// specified number of times or until it successfully terminates.
/// </returns>
public static IObservable<T> RetryAfterDelay<T, TException>(
this IObservable<T> source,
diff --git a/FireBase/Extensions/TaskExtensions.cs b/FireBase/Extensions/TaskExtensions.cs
index 8e933b2..c955b3a 100644
--- a/FireBase/Extensions/TaskExtensions.cs
+++ b/FireBase/Extensions/TaskExtensions.cs
@@ -1,12 +1,12 @@
-namespace Firebase.Database.Extensions
-{
- using System;
- using System.Threading.Tasks;
+using System;
+using System.Threading.Tasks;
+namespace Firebase.Database.Extensions
+{
public static class TaskExtensions
{
/// <summary>
- /// Instead of unwrapping <see cref="AggregateException"/> it throws it as it is.
+ /// Instead of unwrapping <see cref="AggregateException" /> it throws it as it is.
/// </summary>
public static async Task WithAggregateException(this Task source)
{
diff --git a/FireBase/FirebaseClient.cs b/FireBase/FirebaseClient.cs
index 8795668..3079f3b 100644
--- a/FireBase/FirebaseClient.cs
+++ b/FireBase/FirebaseClient.cs
@@ -1,30 +1,26 @@
+using System;
using System.Net.Http;
+using System.Runtime.CompilerServices;
+using Firebase.Database.Query;
-[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Firebase.Database.Tests")]
+[assembly: InternalsVisibleTo("Firebase.Database.Tests")]
namespace Firebase.Database
{
- using System;
- using System.Collections.Generic;
- using System.Threading.Tasks;
- using Offline;
- using Query;
-
/// <summary>
- /// Firebase client which acts as an entry point to the online database.
+ /// Firebase client which acts as an entry point to the online database.
/// </summary>
public class FirebaseClient : IDisposable
{
+ private readonly string baseUrl;
internal readonly HttpClient HttpClient;
internal readonly FirebaseOptions Options;
- private readonly string baseUrl;
-
/// <summary>
- /// Initializes a new instance of the <see cref="FirebaseClient"/> class.
+ /// Initializes a new instance of the <see cref="FirebaseClient" /> class.
/// </summary>
/// <param name="baseUrl"> The base url. </param>
- /// <param name="offlineDatabaseFactory"> Offline database. </param>
+ /// <param name="offlineDatabaseFactory"> Offline database. </param>
public FirebaseClient(string baseUrl, FirebaseOptions options = null)
{
HttpClient = new HttpClient();
@@ -35,19 +31,19 @@ namespace Firebase.Database
if (!this.baseUrl.EndsWith("/")) this.baseUrl += "/";
}
+ public void Dispose()
+ {
+ HttpClient?.Dispose();
+ }
+
/// <summary>
- /// Queries for a child of the data root.
+ /// Queries for a child of the data root.
/// </summary>
/// <param name="resourceName"> Name of the child. </param>
- /// <returns> <see cref="ChildQuery"/>. </returns>
+ /// <returns> <see cref="ChildQuery" />. </returns>
public ChildQuery Child(string resourceName)
{
return new ChildQuery(this, () => baseUrl + resourceName);
}
-
- public void Dispose()
- {
- HttpClient?.Dispose();
- }
}
} \ No newline at end of file
diff --git a/FireBase/FirebaseException.cs b/FireBase/FirebaseException.cs
index 2f8269d..cfc09d3 100644
--- a/FireBase/FirebaseException.cs
+++ b/FireBase/FirebaseException.cs
@@ -1,8 +1,8 @@
-namespace Firebase.Database
-{
- using System;
- using System.Net;
+using System;
+using System.Net;
+namespace Firebase.Database
+{
public class FirebaseException : Exception
{
public FirebaseException(string requestUrl, string requestData, string responseData, HttpStatusCode statusCode)
@@ -25,22 +25,22 @@
}
/// <summary>
- /// Post data passed to the authentication service.
+ /// Post data passed to the authentication service.
/// </summary>
public string RequestData { get; }
/// <summary>
- /// Original url of the request.
+ /// Original url of the request.
/// </summary>
public string RequestUrl { get; }
/// <summary>
- /// Response from the authentication service.
+ /// Response from the authentication service.
/// </summary>
public string ResponseData { get; }
/// <summary>
- /// Status code of the response.
+ /// Status code of the response.
/// </summary>
public HttpStatusCode StatusCode { get; }
diff --git a/FireBase/FirebaseKeyGenerator.cs b/FireBase/FirebaseKeyGenerator.cs
index 70a855d..37beed5 100644
--- a/FireBase/FirebaseKeyGenerator.cs
+++ b/FireBase/FirebaseKeyGenerator.cs
@@ -1,11 +1,11 @@
+using System;
+using System.Text;
+
namespace Firebase.Database
{
- using System;
- using System.Text;
-
/// <summary>
- /// Offline key generator which mimics the official Firebase generators.
- /// Credit: https://github.com/bubbafat/FirebaseSharp/blob/master/src/FirebaseSharp.Portable/FireBasePushIdGenerator.cs
+ /// 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
{
@@ -26,10 +26,11 @@ namespace Firebase.Database
}
/// <summary>
- /// Returns next firebase key based on current time.
+ /// Returns next firebase key based on current time.
/// </summary>
/// <returns>
- /// The <see cref="string"/>. </returns>
+ /// The <see cref="string" />.
+ /// </returns>
public static string Next()
{
// We generate 72-bits of randomness which get turned into 12 characters and
diff --git a/FireBase/FirebaseObject.cs b/FireBase/FirebaseObject.cs
index 653d508..2e0fd20 100644
--- a/FireBase/FirebaseObject.cs
+++ b/FireBase/FirebaseObject.cs
@@ -1,9 +1,11 @@
namespace Firebase.Database
{
/// <summary>
- /// Holds the object of type <typeparam name="T" /> along with its key.
+ /// Holds the object of type
+ /// <typeparam name="T" />
+ /// along with its key.
/// </summary>
- /// <typeparam name="T"> Type of the underlying object. </typeparam>
+ /// <typeparam name="T"> Type of the underlying object. </typeparam>
public class FirebaseObject<T>
{
internal FirebaseObject(string key, T obj)
@@ -13,12 +15,12 @@ namespace Firebase.Database
}
/// <summary>
- /// Gets the key of <see cref="Object"/>.
+ /// Gets the key of <see cref="Object" />.
/// </summary>
public string Key { get; }
/// <summary>
- /// Gets the underlying object.
+ /// Gets the underlying object.
/// </summary>
public T Object { get; }
}
diff --git a/FireBase/FirebaseOptions.cs b/FireBase/FirebaseOptions.cs
index f31a047..b4a5e51 100644
--- a/FireBase/FirebaseOptions.cs
+++ b/FireBase/FirebaseOptions.cs
@@ -1,12 +1,12 @@
-namespace Firebase.Database
-{
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Threading.Tasks;
- using Offline;
- using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Threading.Tasks;
+using Firebase.Database.Offline;
+using Newtonsoft.Json;
+namespace Firebase.Database
+{
public class FirebaseOptions
{
public FirebaseOptions()
@@ -18,32 +18,34 @@
}
/// <summary>
- /// Gets or sets the factory for Firebase offline database. Default is in-memory dictionary.
+ /// Gets or sets the factory for Firebase offline database. Default is in-memory dictionary.
/// </summary>
public Func<Type, string, IDictionary<string, OfflineEntry>> OfflineDatabaseFactory { get; set; }
/// <summary>
- /// Gets or sets the method for retrieving auth tokens. Default is null.
+ /// Gets or sets the method for retrieving auth tokens. Default is null.
/// </summary>
public Func<Task<string>> AuthTokenAsyncFactory { get; set; }
/// <summary>
- /// Gets or sets the factory for <see cref="TextReader"/> used for reading online streams. Default is <see cref="StreamReader"/>.
+ /// Gets or sets the factory for <see cref="TextReader" /> used for reading online streams. Default is
+ /// <see cref="StreamReader" />.
/// </summary>
public Func<Stream, TextReader> SubscriptionStreamReaderFactory { get; set; }
/// <summary>
- /// Gets or sets the json serializer settings.
+ /// Gets or sets the json serializer settings.
/// </summary>
public JsonSerializerSettings JsonSerializerSettings { get; set; }
/// <summary>
- /// Gets or sets the time between synchronization attempts for pulling and pushing offline entities. Default is 10 seconds.
+ /// Gets or sets the time between synchronization attempts for pulling and pushing offline entities. Default is 10
+ /// seconds.
/// </summary>
public TimeSpan SyncPeriod { get; set; }
/// <summary>
- /// Specify if token returned by factory will be used as "auth" url parameter or "access_token".
+ /// Specify if token returned by factory will be used as "auth" url parameter or "access_token".
/// </summary>
public bool AsAccessToken { get; set; }
}
diff --git a/FireBase/Http/HttpClientExtensions.cs b/FireBase/Http/HttpClientExtensions.cs
index 7f8fffe..6582769 100644
--- a/FireBase/Http/HttpClientExtensions.cs
+++ b/FireBase/Http/HttpClientExtensions.cs
@@ -1,27 +1,27 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Net.Http;
+using System.Threading.Tasks;
+using Newtonsoft.Json;
+
namespace Firebase.Database.Http
{
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- using System.Net.Http;
- using System.Threading.Tasks;
- using Newtonsoft.Json;
- using System.Net;
-
/// <summary>
- /// The http client extensions for object deserializations.
+ /// The http client extensions for object deserializations.
/// </summary>
internal static class HttpClientExtensions
{
/// <summary>
- /// The get object collection async.
+ /// The get object collection async.
/// </summary>
/// <param name="client"> The client. </param>
- /// <param name="requestUri"> The request uri. </param>
- /// <param name="jsonSerializerSettings"> The specific JSON Serializer Settings. </param>
+ /// <param name="requestUri"> The request uri. </param>
+ /// <param name="jsonSerializerSettings"> The specific JSON Serializer Settings. </param>
/// <typeparam name="T"> The type of entities the collection should contain. </typeparam>
- /// <returns> The <see cref="Task"/>. </returns>
+ /// <returns> The <see cref="Task" />. </returns>
public static async Task<IReadOnlyCollection<FirebaseObject<T>>> GetObjectCollectionAsync<T>(
this HttpClient client, string requestUri,
JsonSerializerSettings jsonSerializerSettings)
@@ -91,11 +91,11 @@ namespace Firebase.Database.Http
}*/
/// <summary>
- /// The get object collection async.
+ /// The get object collection async.
/// </summary>
/// <param name="data"> The json data. </param>
/// <param name="elementType"> The type of entities the collection should contain. </param>
- /// <returns> The <see cref="Task"/>. </returns>
+ /// <returns> The <see cref="Task" />. </returns>
public static IEnumerable<FirebaseObject<object>> GetObjectCollection(this string data, Type elementType)
{
var dictionaryType = typeof(Dictionary<,>).MakeGenericType(typeof(string), elementType);
diff --git a/FireBase/Http/PostResult.cs b/FireBase/Http/PostResult.cs
index 5a779ed..15a4894 100644
--- a/FireBase/Http/PostResult.cs
+++ b/FireBase/Http/PostResult.cs
@@ -1,12 +1,12 @@
namespace Firebase.Database.Http
{
/// <summary>
- /// Represents data returned after a successful POST to firebase server.
+ /// Represents data returned after a successful POST to firebase server.
/// </summary>
public class PostResult
{
/// <summary>
- /// Gets or sets the generated key after a successful post.
+ /// Gets or sets the generated key after a successful post.
/// </summary>
public string Name { get; set; }
}
diff --git a/FireBase/ObservableExtensions.cs b/FireBase/ObservableExtensions.cs
index da78365..bc46261 100644
--- a/FireBase/ObservableExtensions.cs
+++ b/FireBase/ObservableExtensions.cs
@@ -1,20 +1,20 @@
-namespace Firebase.Database
-{
- using System;
- using System.Collections.ObjectModel;
- using Streaming;
+using System;
+using System.Collections.ObjectModel;
+using Firebase.Database.Streaming;
+namespace Firebase.Database
+{
/// <summary>
- /// Extensions for <see cref="IObservable{T}"/>.
+ /// Extensions for <see cref="IObservable{T}" />.
/// </summary>
public static class ObservableExtensions
{
/// <summary>
- /// Starts observing on given firebase observable and propagates event into an <see cref="ObservableCollection{T}"/>.
+ /// Starts observing on given firebase observable and propagates event into an <see cref="ObservableCollection{T}" />.
/// </summary>
/// <param name="observable"> The observable. </param>
/// <typeparam name="T"> Type of entity. </typeparam>
- /// <returns> The <see cref="ObservableCollection{T}"/>. </returns>
+ /// <returns> The <see cref="ObservableCollection{T}" />. </returns>
public static ObservableCollection<T> AsObservableCollection<T>(this IObservable<FirebaseEvent<T>> observable)
{
var collection = new ObservableCollection<T>();
diff --git a/FireBase/Offline/ConcurrentOfflineDatabase.cs b/FireBase/Offline/ConcurrentOfflineDatabase.cs
index 5527168..1a9e607 100644
--- a/FireBase/Offline/ConcurrentOfflineDatabase.cs
+++ b/FireBase/Offline/ConcurrentOfflineDatabase.cs
@@ -1,23 +1,23 @@
-namespace Firebase.Database.Offline
+using System;
+using System.Collections;
+using System.Collections.Concurrent;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using LiteDB;
+
+namespace Firebase.Database.Offline
{
- using System;
- using System.Collections;
- using System.Collections.Concurrent;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using LiteDB;
-
/// <summary>
- /// The offline database.
+ /// The offline database.
/// </summary>
public class ConcurrentOfflineDatabase : IDictionary<string, OfflineEntry>
{
- private readonly LiteRepository db;
private readonly ConcurrentDictionary<string, OfflineEntry> ccache;
+ private readonly LiteRepository db;
/// <summary>
- /// Initializes a new instance of the <see cref="OfflineDatabase"/> class.
+ /// Initializes a new instance of the <see cref="OfflineDatabase" /> class.
/// </summary>
/// <param name="itemType"> The item type which is used to determine the database file name. </param>
/// <param name="filenameModifier"> Custom string which will get appended to the file name. </param>
@@ -43,33 +43,41 @@
}
/// <summary>
- /// Gets the number of elements contained in the <see cref="T:System.Collections.Generic.ICollection`1"/>.
+ /// Gets the number of elements contained in the <see cref="T:System.Collections.Generic.ICollection`1" />.
/// </summary>
- /// <returns> The number of elements contained in the <see cref="T:System.Collections.Generic.ICollection`1"/>. </returns>
+ /// <returns> The number of elements contained in the <see cref="T:System.Collections.Generic.ICollection`1" />. </returns>
public int Count => ccache.Count;
/// <summary>
- /// Gets a value indicating whether this is a read-only collection.
+ /// Gets a value indicating whether this is a read-only collection.
/// </summary>
public bool IsReadOnly => false;
/// <summary>
- /// Gets an <see cref="T:System.Collections.Generic.ICollection`1"/> containing the keys of the <see cref="T:System.Collections.Generic.IDictionary`2"/>.
+ /// Gets an <see cref="T:System.Collections.Generic.ICollection`1" /> containing the keys of the
+ /// <see cref="T:System.Collections.Generic.IDictionary`2" />.
/// </summary>
- /// <returns> An <see cref="T:System.Collections.Generic.ICollection`1"/> containing the keys of the object that implements <see cref="T:System.Collections.Generic.IDictionary`2"/>. </returns>
+ /// <returns>
+ /// An <see cref="T:System.Collections.Generic.ICollection`1" /> containing the keys of the object that
+ /// implements <see cref="T:System.Collections.Generic.IDictionary`2" />.
+ /// </returns>
public ICollection<string> Keys => ccache.Keys;
/// <summary>
- /// Gets an <see cref="T:System.Collections.Generic.ICollection`1"/> containing the values in the <see cref="T:System.Collections.Generic.IDictionary`2"/>.
+ /// Gets an <see cref="T:System.Collections.Generic.ICollection`1" /> containing the values in the
+ /// <see cref="T:System.Collections.Generic.IDictionary`2" />.
/// </summary>
- /// <returns> An <see cref="T:System.Collections.Generic.ICollection`1"/> containing the values in the object that implements <see cref="T:System.Collections.Generic.IDictionary`2"/>. </returns>
+ /// <returns>
+ /// An <see cref="T:System.Collections.Generic.ICollection`1" /> containing the values in the object that
+ /// implements <see cref="T:System.Collections.Generic.IDictionary`2" />.
+ /// </returns>
public ICollection<OfflineEntry> Values => ccache.Values;
/// <summary>
- /// Gets or sets the element with the specified key.
+ /// Gets or sets the element with the specified key.
/// </summary>
/// <param name="key">The key of the element to get or set.</param>
- /// <returns> The element with the specified key. </returns>
+ /// <returns> The element with the specified key. </returns>
public OfflineEntry this[string key]
{
get => ccache[key];
@@ -82,7 +90,7 @@
}
/// <summary>
- /// Returns an enumerator that iterates through the collection.
+ /// Returns an enumerator that iterates through the collection.
/// </summary>
/// <returns> An enumerator that can be used to iterate through the collection. </returns>
public IEnumerator<KeyValuePair<string, OfflineEntry>> GetEnumerator()
@@ -96,65 +104,82 @@
}
/// <summary>
- /// Adds an item to the <see cref="T:System.Collections.Generic.ICollection`1"/>.
+ /// Adds an item to the <see cref="T:System.Collections.Generic.ICollection`1" />.
/// </summary>
- /// <param name="item">The object to add to the <see cref="T:System.Collections.Generic.ICollection`1"/>.</param>
+ /// <param name="item">The object to add to the <see cref="T:System.Collections.Generic.ICollection`1" />.</param>
public void Add(KeyValuePair<string, OfflineEntry> item)
{
Add(item.Key, item.Value);
}
/// <summary>
- /// Removes all items from the <see cref="T:System.Collections.Generic.ICollection`1"/>.
- /// </summary>
+ /// Removes all items from the <see cref="T:System.Collections.Generic.ICollection`1" />.
+ /// </summary>
public void Clear()
{
ccache.Clear();
- db.Delete<OfflineEntry>(Query.All());
+ db.Delete<OfflineEntry>(LiteDB.Query.All());
}
/// <summary>
- /// Determines whether the <see cref="T:System.Collections.Generic.ICollection`1"/> contains a specific value.
+ /// Determines whether the <see cref="T:System.Collections.Generic.ICollection`1" /> contains a specific value.
/// </summary>
- /// <param name="item">The object to locate in the <see cref="T:System.Collections.Generic.ICollection`1"/>.</param>
- /// <returns> True if <paramref name="item"/> is found in the <see cref="T:System.Collections.Generic.ICollection`1"/>; otherwise, false. </returns>
+ /// <param name="item">The object to locate in the <see cref="T:System.Collections.Generic.ICollection`1" />.</param>
+ /// <returns>
+ /// True if <paramref name="item" /> is found in the <see cref="T:System.Collections.Generic.ICollection`1" />;
+ /// otherwise, false.
+ /// </returns>
public bool Contains(KeyValuePair<string, OfflineEntry> item)
{
return ContainsKey(item.Key);
}
/// <summary>
- /// Copies the elements of the <see cref="T:System.Collections.Generic.ICollection`1"/> to an <see cref="T:System.Array"/>, starting at a particular <see cref="T:System.Array"/> index.
+ /// Copies the elements of the <see cref="T:System.Collections.Generic.ICollection`1" /> to an
+ /// <see cref="T:System.Array" />, starting at a particular <see cref="T:System.Array" /> index.
/// </summary>
- /// <param name="array">The one-dimensional <see cref="T:System.Array"/> that is the destination of the elements copied from <see cref="T:System.Collections.Generic.ICollection`1"/>. The <see cref="T:System.Array"/> must have zero-based indexing.</param>
- /// <param name="arrayIndex">The zero-based index in <paramref name="array"/> at which copying begins.</param>
+ /// <param name="array">
+ /// The one-dimensional <see cref="T:System.Array" /> that is the destination of the elements copied
+ /// from <see cref="T:System.Collections.Generic.ICollection`1" />. The <see cref="T:System.Array" /> must have
+ /// zero-based indexing.
+ /// </param>
+ /// <param name="arrayIndex">The zero-based index in <paramref name="array" /> at which copying begins.</param>
public void CopyTo(KeyValuePair<string, OfflineEntry>[] array, int arrayIndex)
{
ccache.ToList().CopyTo(array, arrayIndex);
}
/// <summary>
- /// Removes the first occurrence of a specific object from the <see cref="T:System.Collections.Generic.ICollection`1"/>.
+ /// Removes the first occurrence of a specific object from the
+ /// <see cref="T:System.Collections.Generic.ICollection`1" />.
/// </summary>
- /// <param name="item">The object to remove from the <see cref="T:System.Collections.Generic.ICollection`1"/>.</param>
- /// <returns> True if <paramref name="item"/> was successfully removed from the <see cref="T:System.Collections.Generic.ICollection`1"/>; otherwise, false. This method also returns false if <paramref name="item"/> is not found in the original <see cref="T:System.Collections.Generic.ICollection`1"/>. </returns>
+ /// <param name="item">The object to remove from the <see cref="T:System.Collections.Generic.ICollection`1" />.</param>
+ /// <returns>
+ /// True if <paramref name="item" /> was successfully removed from the
+ /// <see cref="T:System.Collections.Generic.ICollection`1" />; otherwise, false. This method also returns false if
+ /// <paramref name="item" /> is not found in the original <see cref="T:System.Collections.Generic.ICollection`1" />.
+ /// </returns>
public bool Remove(KeyValuePair<string, OfflineEntry> item)
{
return Remove(item.Key);
}
/// <summary>
- /// Determines whether the <see cref="T:System.Collections.Generic.IDictionary`2"/> contains an element with the specified key.
+ /// Determines whether the <see cref="T:System.Collections.Generic.IDictionary`2" /> contains an element with the
+ /// specified key.
/// </summary>
- /// <param name="key">The key to locate in the <see cref="T:System.Collections.Generic.IDictionary`2"/>.</param>
- /// <returns> True if the <see cref="T:System.Collections.Generic.IDictionary`2"/> contains an element with the key; otherwise, false. </returns>
+ /// <param name="key">The key to locate in the <see cref="T:System.Collections.Generic.IDictionary`2" />.</param>
+ /// <returns>
+ /// True if the <see cref="T:System.Collections.Generic.IDictionary`2" /> contains an element with the key;
+ /// otherwise, false.
+ /// </returns>
public bool ContainsKey(string key)
{
return ccache.ContainsKey(key);
}
/// <summary>
- /// Adds an element with the provided key and value to the <see cref="T:System.Collections.Generic.IDictionary`2"/>.
+ /// Adds an element with the provided key and value to the <see cref="T:System.Collections.Generic.IDictionary`2" />.
/// </summary>
/// <param name="key">The object to use as the key of the element to add.</param>
/// <param name="value">The object to use as the value of the element to add.</param>
@@ -165,10 +190,13 @@
}
/// <summary>
- /// Removes the element with the specified key from the <see cref="T:System.Collections.Generic.IDictionary`2"/>.
+ /// Removes the element with the specified key from the <see cref="T:System.Collections.Generic.IDictionary`2" />.
/// </summary>
/// <param name="key">The key of the element to remove.</param>
- /// <returns> True if the element is successfully removed; otherwise, false. This method also returns false if <paramref name="key"/> was not found in the original <see cref="T:System.Collections.Generic.IDictionary`2"/>. </returns>
+ /// <returns>
+ /// True if the element is successfully removed; otherwise, false. This method also returns false if
+ /// <paramref name="key" /> was not found in the original <see cref="T:System.Collections.Generic.IDictionary`2" />.
+ /// </returns>
public bool Remove(string key)
{
ccache.TryRemove(key, out _);
@@ -176,10 +204,18 @@
}
/// <summary>
- /// Gets the value associated with the specified key.
- /// </summary>
- /// <param name="key">The key whose value to get.</param><param name="value">When this method returns, the value associated with the specified key, if the key is found; otherwise, the default value for the type of the <paramref name="value"/> parameter. This parameter is passed uninitialized.</param>
- /// <returns> True if the object that implements <see cref="T:System.Collections.Generic.IDictionary`2"/> contains an element with the specified key; otherwise, false. </returns>
+ /// Gets the value associated with the specified key.
+ /// </summary>
+ /// <param name="key">The key whose value to get.</param>
+ /// <param name="value">
+ /// When this method returns, the value associated with the specified key, if the key is found;
+ /// otherwise, the default value for the type of the <paramref name="value" /> parameter. This parameter is passed
+ /// uninitialized.
+ /// </param>
+ /// <returns>
+ /// True if the object that implements <see cref="T:System.Collections.Generic.IDictionary`2" /> contains an
+ /// element with the specified key; otherwise, false.
+ /// </returns>
public bool TryGetValue(string key, out OfflineEntry value)
{
return ccache.TryGetValue(key, out value);
diff --git a/FireBase/Offline/DatabaseExtensions.cs b/FireBase/Offline/DatabaseExtensions.cs
index 56dcf46..e7c4074 100644
--- a/FireBase/Offline/DatabaseExtensions.cs
+++ b/FireBase/Offline/DatabaseExtensions.cs
@@ -1,24 +1,26 @@
-namespace Firebase.Database.Offline
-{
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq.Expressions;
- using System.Reflection;
- using Query;
+using System;
+using System.Collections.Generic;
+using System.Linq.Expressions;
+using System.Reflection;
+using Firebase.Database.Query;
+namespace Firebase.Database.Offline
+{
public static class DatabaseExtensions
{
/// <summary>
- /// Create new instances of the <see cref="RealtimeDatabase{T}"/>.
+ /// Create new instances of the <see cref="RealtimeDatabase{T}" />.
/// </summary>
/// <typeparam name="T"> Type of elements. </typeparam>
/// <param name="filenameModifier"> Custom string which will get appended to the file name. </param>
/// <param name="elementRoot"> Optional custom root element of received json items. </param>
- /// <param name="streamingOptions"> Realtime streaming options. </param>
+ /// <param name="streamingOptions"> Realtime streaming options. </param>
/// <param name="initialPullStrategy"> Specifies what strategy should be used for initial pulling of server data. </param>
- /// <param name="pushChanges"> Specifies whether changed items should actually be pushed to the server. It this is false, then Put / Post / Delete will not affect server data. </param>
- /// <returns> The <see cref="RealtimeDatabase{T}"/>. </returns>
+ /// <param name="pushChanges">
+ /// Specifies whether changed items should actually be pushed to the server. It this is false,
+ /// then Put / Post / Delete will not affect server data.
+ /// </param>
+ /// <returns> The <see cref="RealtimeDatabase{T}" />. </returns>
public static RealtimeDatabase<T> AsRealtimeDatabase<T>(this ChildQuery query, string filenameModifier = "",
string elementRoot = "", StreamingOptions streamingOptions = StreamingOptions.LatestOnly,
InitialPullStrategy initialPullStrategy = InitialPullStrategy.MissingOnly, bool pushChanges = true)
@@ -29,16 +31,19 @@
}
/// <summary>
- /// Create new instances of the <see cref="RealtimeDatabase{T}"/>.
+ /// Create new instances of the <see cref="RealtimeDatabase{T}" />.
/// </summary>
/// <typeparam name="T"> Type of elements. </typeparam>
- /// <typeparam name="TSetHandler"> Type of the custom <see cref="ISetHandler{T}"/> to use. </typeparam>
+ /// <typeparam name="TSetHandler"> Type of the custom <see cref="ISetHandler{T}" /> to use. </typeparam>
/// <param name="filenameModifier"> Custom string which will get appended to the file name. </param>
/// <param name="elementRoot"> Optional custom root element of received json items. </param>
- /// <param name="streamingOptions"> Realtime streaming options. </param>
+ /// <param name="streamingOptions"> Realtime streaming options. </param>
/// <param name="initialPullStrategy"> Specifies what strategy should be used for initial pulling of server data. </param>
- /// <param name="pushChanges"> Specifies whether changed items should actually be pushed to the server. It this is false, then Put / Post / Delete will not affect server data. </param>
- /// <returns> The <see cref="RealtimeDatabase{T}"/>. </returns>
+ /// <param name="pushChanges">
+ /// Specifies whether changed items should actually be pushed to the server. It this is false,
+ /// then Put / Post / Delete will not affect server data.
+ /// </param>
+ /// <returns> The <see cref="RealtimeDatabase{T}" />. </returns>
public static RealtimeDatabase<T> AsRealtimeDatabase<T, TSetHandler>(this ChildQuery query,
string filenameModifier = "", string elementRoot = "",
StreamingOptions streamingOptions = StreamingOptions.LatestOnly,
@@ -52,12 +57,15 @@
}
/// <summary>
- /// Overwrites existing object with given key leaving any missing properties intact in firebase.
+ /// Overwrites existing object with given key leaving any missing properties intact in firebase.
/// </summary>
/// <param name="key"> The key. </param>
/// <param name="obj"> The object to set. </param>
/// <param name="syncOnline"> Indicates whether the item should be synced online. </param>
- /// <param name="priority"> The priority. Objects with higher priority will be synced first. Higher number indicates higher priority. </param>
+ /// <param name="priority">
+ /// The priority. Objects with higher priority will be synced first. Higher number indicates higher
+ /// priority.
+ /// </param>
public static void Patch<T>(this RealtimeDatabase<T> db, string key, T obj, bool syncOnline = true,
int priority = 1)
where T : class
@@ -66,12 +74,15 @@
}
/// <summary>
- /// Overwrites existing object with given key.
+ /// Overwrites existing object with given key.
/// </summary>
/// <param name="key"> The key. </param>
/// <param name="obj"> The object to set. </param>
/// <param name="syncOnline"> Indicates whether the item should be synced online. </param>
- /// <param name="priority"> The priority. Objects with higher priority will be synced first. Higher number indicates higher priority. </param>
+ /// <param name="priority">
+ /// The priority. Objects with higher priority will be synced first. Higher number indicates higher
+ /// priority.
+ /// </param>
public static void Put<T>(this RealtimeDatabase<T> db, string key, T obj, bool syncOnline = true,
int priority = 1)
where T : class
@@ -80,11 +91,14 @@
}
/// <summary>
- /// Adds a new entity to the Database.
+ /// Adds a new entity to the Database.
/// </summary>
/// <param name="obj"> The object to add. </param>
/// <param name="syncOnline"> Indicates whether the item should be synced online. </param>
- /// <param name="priority"> The priority. Objects with higher priority will be synced first. Higher number indicates higher priority. </param>
+ /// <param name="priority">
+ /// The priority. Objects with higher priority will be synced first. Higher number indicates higher
+ /// priority.
+ /// </param>
/// <returns> The generated key for this object. </returns>
public static string Post<T>(this RealtimeDatabase<T> db, T obj, bool syncOnline = true, int priority = 1)
where T : class
@@ -97,11 +111,14 @@
}
/// <summary>
- /// Deletes the entity with the given key.
+ /// Deletes the entity with the given key.
/// </summary>
/// <param name="key"> The key. </param>
/// <param name="syncOnline"> Indicates whether the item should be synced online. </param>
- /// <param name="priority"> The priority. Objects with higher priority will be synced first. Higher number indicates higher priority. </param>
+ /// <param name="priority">
+ /// The priority. Objects with higher priority will be synced first. Higher number indicates higher
+ /// priority.
+ /// </param>
public static void Delete<T>(this RealtimeDatabase<T> db, string key, bool syncOnline = true, int priority = 1)
where T : class
{
@@ -109,7 +126,8 @@
}
/// <summary>
- /// Do a Put for a nested property specified by <paramref name="propertyExpression"/> of an object with key <paramref name="key"/>.
+ /// Do a Put for a nested property specified by <paramref name="propertyExpression" /> of an object with key
+ /// <paramref name="key" />.
/// </summary>
/// <typeparam name="T"> Type of the root elements. </typeparam>
/// <typeparam name="TProperty"> Type of the property being modified</typeparam>
@@ -118,7 +136,10 @@
/// <param name="propertyExpression"> Expression on the root element leading to target value to modify. </param>
/// <param name="value"> Value to put. </param>
/// <param name="syncOnline"> Indicates whether the item should be synced online. </param>
- /// <param name="priority"> The priority. Objects with higher priority will be synced first. Higher number indicates higher priority. </param>
+ /// <param name="priority">
+ /// The priority. Objects with higher priority will be synced first. Higher number indicates higher
+ /// priority.
+ /// </param>
public static void Put<T, TProperty>(this RealtimeDatabase<T> db, string key,
Expression<Func<T, TProperty>> propertyExpression, TProperty value, bool syncOnline = true,
int priority = 1)
@@ -128,7 +149,8 @@
}
/// <summary>
- /// Do a Patch for a nested property specified by <paramref name="propertyExpression"/> of an object with key <paramref name="key"/>.
+ /// Do a Patch for a nested property specified by <paramref name="propertyExpression" /> of an object with key
+ /// <paramref name="key" />.
/// </summary>
/// <typeparam name="T"> Type of the root elements. </typeparam>
/// <typeparam name="TProperty"> Type of the property being modified</typeparam>
@@ -137,7 +159,10 @@
/// <param name="propertyExpression"> Expression on the root element leading to target value to modify. </param>
/// <param name="value"> Value to patch. </param>
/// <param name="syncOnline"> Indicates whether the item should be synced online. </param>
- /// <param name="priority"> The priority. Objects with higher priority will be synced first. Higher number indicates higher priority. </param>
+ /// <param name="priority">
+ /// The priority. Objects with higher priority will be synced first. Higher number indicates higher
+ /// priority.
+ /// </param>
public static void Patch<T, TProperty>(this RealtimeDatabase<T> db, string key,
Expression<Func<T, TProperty>> propertyExpression, TProperty value, bool syncOnline = true,
int priority = 1)
@@ -147,7 +172,8 @@
}
/// <summary>
- /// Delete a nested property specified by <paramref name="propertyExpression"/> of an object with key <paramref name="key"/>. This basically does a Put with null value.
+ /// Delete a nested property specified by <paramref name="propertyExpression" /> of an object with key
+ /// <paramref name="key" />. This basically does a Put with null value.
/// </summary>
/// <typeparam name="T"> Type of the root elements. </typeparam>
/// <typeparam name="TProperty"> Type of the property being modified</typeparam>
@@ -156,7 +182,10 @@
/// <param name="propertyExpression"> Expression on the root element leading to target value to modify. </param>
/// <param name="value"> Value to put. </param>
/// <param name="syncOnline"> Indicates whether the item should be synced online. </param>
- /// <param name="priority"> The priority. Objects with higher priority will be synced first. Higher number indicates higher priority. </param>
+ /// <param name="priority">
+ /// The priority. Objects with higher priority will be synced first. Higher number indicates higher
+ /// priority.
+ /// </param>
public static void Delete<T, TProperty>(this RealtimeDatabase<T> db, string key,
Expression<Func<T, TProperty>> propertyExpression, bool syncOnline = true, int priority = 1)
where T : class
@@ -166,8 +195,9 @@
}
/// <summary>
- /// Post a new entity into the nested dictionary specified by <paramref name="propertyExpression"/> of an object with key <paramref name="key"/>.
- /// The key of the new entity is automatically generated.
+ /// Post a new entity into the nested dictionary specified by <paramref name="propertyExpression" /> of an object with
+ /// key <paramref name="key" />.
+ /// The key of the new entity is automatically generated.
/// </summary>
/// <typeparam name="T"> Type of the root elements. </typeparam>
/// <typeparam name="TSelector"> Type of the dictionary being modified</typeparam>
@@ -177,7 +207,10 @@
/// <param name="propertyExpression"> Expression on the root element leading to target value to modify. </param>
/// <param name="value"> Value to put. </param>
/// <param name="syncOnline"> Indicates whether the item should be synced online. </param>
- /// <param name="priority"> The priority. Objects with higher priority will be synced first. Higher number indicates higher priority. </param>
+ /// <param name="priority">
+ /// The priority. Objects with higher priority will be synced first. Higher number indicates higher
+ /// priority.
+ /// </param>
public static void Post<T, TSelector, TProperty>(this RealtimeDatabase<T> db, string key,
Expression<Func<T, TSelector>> propertyExpression, TProperty value, bool syncOnline = true,
int priority = 1)
@@ -193,8 +226,9 @@
}
/// <summary>
- /// Delete an entity with key <paramref name="dictionaryKey"/> in the nested dictionary specified by <paramref name="propertyExpression"/> of an object with key <paramref name="key"/>.
- /// The key of the new entity is automatically generated.
+ /// Delete an entity with key <paramref name="dictionaryKey" /> in the nested dictionary specified by
+ /// <paramref name="propertyExpression" /> of an object with key <paramref name="key" />.
+ /// The key of the new entity is automatically generated.
/// </summary>
/// <typeparam name="T"> Type of the root elements. </typeparam>
/// <typeparam name="TSelector"> Type of the dictionary being modified</typeparam>
@@ -204,7 +238,10 @@
/// <param name="propertyExpression"> Expression on the root element leading to target value to modify. </param>
/// <param name="dictionaryKey"> Key within the nested dictionary to delete. </param>
/// <param name="syncOnline"> Indicates whether the item should be synced online. </param>
- /// <param name="priority"> The priority. Objects with higher priority will be synced first. Higher number indicates higher priority. </param>
+ /// <param name="priority">
+ /// The priority. Objects with higher priority will be synced first. Higher number indicates higher
+ /// priority.
+ /// </param>
public static void Delete<T, TProperty>(this RealtimeDatabase<T> db, string key,
Expression<Func<T, IDictionary<string, TProperty>>> propertyExpression, string dictionaryKey,
bool syncOnline = true, int priority = 1)
diff --git a/FireBase/Offline/ISetHandler.cs b/FireBase/Offline/ISetHandler.cs
index e3b49b5..c04bd41 100644
--- a/FireBase/Offline/ISetHandler.cs
+++ b/FireBase/Offline/ISetHandler.cs
@@ -1,8 +1,8 @@
-namespace Firebase.Database.Offline
-{
- using Query;
- using System.Threading.Tasks;
+using System.Threading.Tasks;
+using Firebase.Database.Query;
+namespace Firebase.Database.Offline
+{
public interface ISetHandler<in T>
{
Task SetAsync(ChildQuery query, string key, OfflineEntry entry);
diff --git a/FireBase/Offline/InitialPullStrategy.cs b/FireBase/Offline/InitialPullStrategy.cs
index a1ae3f7..ca2bebf 100644
--- a/FireBase/Offline/InitialPullStrategy.cs
+++ b/FireBase/Offline/InitialPullStrategy.cs
@@ -1,23 +1,23 @@
namespace Firebase.Database.Offline
{
/// <summary>
- /// Specifies the strategy for initial pull of server data.
+ /// Specifies the strategy for initial pull of server data.
/// </summary>
public enum InitialPullStrategy
{
/// <summary>
- /// Don't pull anything.
+ /// Don't pull anything.
/// </summary>
None,
/// <summary>
- /// Pull only what isn't already stored offline.
+ /// Pull only what isn't already stored offline.
/// </summary>
MissingOnly,
/// <summary>
- /// Pull everything that exists on the server.
+ /// Pull everything that exists on the server.
/// </summary>
- Everything,
+ Everything
}
} \ No newline at end of file
diff --git a/FireBase/Offline/Internals/MemberAccessVisitor.cs b/FireBase/Offline/Internals/MemberAccessVisitor.cs
index 2bc0fc3..89a77da 100644
--- a/FireBase/Offline/Internals/MemberAccessVisitor.cs
+++ b/FireBase/Offline/Internals/MemberAccessVisitor.cs
@@ -1,10 +1,10 @@
-namespace Firebase.Database.Offline.Internals
-{
- using System.Collections.Generic;
- using System.Linq.Expressions;
- using System.Reflection;
- using Newtonsoft.Json;
+using System.Collections.Generic;
+using System.Linq.Expressions;
+using System.Reflection;
+using Newtonsoft.Json;
+namespace Firebase.Database.Offline.Internals
+{
public class MemberAccessVisitor : ExpressionVisitor
{
private readonly IList<string> propertyNames = new List<string>();
@@ -13,10 +13,6 @@
public IEnumerable<string> PropertyNames => propertyNames;
- public MemberAccessVisitor()
- {
- }
-
public override Expression Visit(Expression expr)
{
if (expr?.NodeType == ExpressionType.MemberAccess)
diff --git a/FireBase/Offline/OfflineCacheAdapter.cs b/FireBase/Offline/OfflineCacheAdapter.cs
index 0918a8c..3153d1b 100644
--- a/FireBase/Offline/OfflineCacheAdapter.cs
+++ b/FireBase/Offline/OfflineCacheAdapter.cs
@@ -1,10 +1,10 @@
-namespace Firebase.Database.Offline
-{
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+namespace Firebase.Database.Offline
+{
internal class OfflineCacheAdapter<TKey, T> : IDictionary<string, T>, IDictionary
{
private readonly IDictionary<string, OfflineEntry> database;
@@ -19,14 +19,10 @@
throw new NotImplementedException();
}
- public int Count => database.Count;
-
public bool IsSynchronized { get; }
public object SyncRoot { get; }
- public bool IsReadOnly => database.IsReadOnly;
-
object IDictionary.this[object key]
{
get => database[key.ToString()].Deserialize<T>();
@@ -42,27 +38,10 @@
}
}
- public ICollection<string> Keys => database.Keys;
-
ICollection IDictionary.Values { get; }
ICollection IDictionary.Keys { get; }
- public ICollection<T> Values => database.Values.Select(o => o.Deserialize<T>()).ToList();
-
- public T this[string key]
- {
- get => database[key].Deserialize<T>();
-
- set
- {
- if (database.ContainsKey(key))
- database[key] = new OfflineEntry(key, value, database[key].Priority, database[key].SyncOptions);
- else
- database[key] = new OfflineEntry(key, value, 1, SyncOptions.None);
- }
- }
-
public bool Contains(object key)
{
return ContainsKey(key.ToString());
@@ -80,6 +59,32 @@
public bool IsFixedSize => false;
+ public void Add(object key, object value)
+ {
+ Add(key.ToString(), (T) value);
+ }
+
+ public int Count => database.Count;
+
+ public bool IsReadOnly => database.IsReadOnly;
+
+ public ICollection<string> Keys => database.Keys;
+
+ public ICollection<T> Values => database.Values.Select(o => o.Deserialize<T>()).ToList();
+
+ public T this[string key]
+ {
+ get => database[key].Deserialize<T>();
+
+ set
+ {
+ if (database.ContainsKey(key))
+ database[key] = new OfflineEntry(key, value, database[key].Priority, database[key].SyncOptions);
+ else
+ database[key] = new OfflineEntry(key, value, 1, SyncOptions.None);
+ }
+ }
+
public IEnumerator<KeyValuePair<string, T>> GetEnumerator()
{
return database.Select(d => new KeyValuePair<string, T>(d.Key, d.Value.Deserialize<T>())).GetEnumerator();
@@ -95,11 +100,6 @@
Add(item.Key, item.Value);
}
- public void Add(object key, object value)
- {
- Add(key.ToString(), (T) value);
- }
-
public void Clear()
{
database.Clear();
diff --git a/FireBase/Offline/OfflineDatabase.cs b/FireBase/Offline/OfflineDatabase.cs
index 3e6e7d8..be0380b 100644
--- a/FireBase/Offline/OfflineDatabase.cs
+++ b/FireBase/Offline/OfflineDatabase.cs
@@ -1,22 +1,22 @@
-namespace Firebase.Database.Offline
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using LiteDB;
+
+namespace Firebase.Database.Offline
{
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using LiteDB;
-
/// <summary>
- /// The offline database.
+ /// The offline database.
/// </summary>
public class OfflineDatabase : IDictionary<string, OfflineEntry>
{
- private readonly LiteRepository db;
private readonly IDictionary<string, OfflineEntry> cache;
+ private readonly LiteRepository db;
/// <summary>
- /// Initializes a new instance of the <see cref="OfflineDatabase"/> class.
+ /// Initializes a new instance of the <see cref="OfflineDatabase" /> class.
/// </summary>
/// <param name="itemType"> The item type which is used to determine the database file name. </param>
/// <param name="filenameModifier"> Custom string which will get appended to the file name. </param>
@@ -38,33 +38,41 @@
}
/// <summary>
- /// Gets the number of elements contained in the <see cref="T:System.Collections.Generic.ICollection`1"/>.
+ /// Gets the number of elements contained in the <see cref="T:System.Collections.Generic.ICollection`1" />.
/// </summary>
- /// <returns> The number of elements contained in the <see cref="T:System.Collections.Generic.ICollection`1"/>. </returns>
+ /// <returns> The number of elements contained in the <see cref="T:System.Collections.Generic.ICollection`1" />. </returns>
public int Count => cache.Count;
/// <summary>
- /// Gets a value indicating whether this is a read-only collection.
+ /// Gets a value indicating whether this is a read-only collection.
/// </summary>
public bool IsReadOnly => cache.IsReadOnly;
/// <summary>
- /// Gets an <see cref="T:System.Collections.Generic.ICollection`1"/> containing the keys of the <see cref="T:System.Collections.Generic.IDictionary`2"/>.
+ /// Gets an <see cref="T:System.Collections.Generic.ICollection`1" /> containing the keys of the
+ /// <see cref="T:System.Collections.Generic.IDictionary`2" />.
/// </summary>
- /// <returns> An <see cref="T:System.Collections.Generic.ICollection`1"/> containing the keys of the object that implements <see cref="T:System.Collections.Generic.IDictionary`2"/>. </returns>
+ /// <returns>
+ /// An <see cref="T:System.Collections.Generic.ICollection`1" /> containing the keys of the object that
+ /// implements <see cref="T:System.Collections.Generic.IDictionary`2" />.
+ /// </returns>
public ICollection<string> Keys => cache.Keys;
/// <summary>
- /// Gets an <see cref="T:System.Collections.Generic.ICollection`1"/> containing the values in the <see cref="T:System.Collections.Generic.IDictionary`2"/>.
+ /// Gets an <see cref="T:System.Collections.Generic.ICollection`1" /> containing the values in the
+ /// <see cref="T:System.Collections.Generic.IDictionary`2" />.
/// </summary>
- /// <returns> An <see cref="T:System.Collections.Generic.ICollection`1"/> containing the values in the object that implements <see cref="T:System.Collections.Generic.IDictionary`2"/>. </returns>
+ /// <returns>
+ /// An <see cref="T:System.Collections.Generic.ICollection`1" /> containing the values in the object that
+ /// implements <see cref="T:System.Collections.Generic.IDictionary`2" />.
+ /// </returns>
public ICollection<OfflineEntry> Values => cache.Values;
/// <summary>
- /// Gets or sets the element with the specified key.
+ /// Gets or sets the element with the specified key.
/// </summary>
/// <param name="key">The key of the element to get or set.</param>
- /// <returns> The element with the specified key. </returns>
+ /// <returns> The element with the specified key. </returns>
public OfflineEntry this[string key]
{
get => cache[key];
@@ -77,7 +85,7 @@
}
/// <summary>
- /// Returns an enumerator that iterates through the collection.
+ /// Returns an enumerator that iterates through the collection.
/// </summary>
/// <returns> An enumerator that can be used to iterate through the collection. </returns>
public IEnumerator<KeyValuePair<string, OfflineEntry>> GetEnumerator()
@@ -91,65 +99,82 @@
}
/// <summary>
- /// Adds an item to the <see cref="T:System.Collections.Generic.ICollection`1"/>.
+ /// Adds an item to the <see cref="T:System.Collections.Generic.ICollection`1" />.
/// </summary>
- /// <param name="item">The object to add to the <see cref="T:System.Collections.Generic.ICollection`1"/>.</param>
+ /// <param name="item">The object to add to the <see cref="T:System.Collections.Generic.ICollection`1" />.</param>
public void Add(KeyValuePair<string, OfflineEntry> item)
{
Add(item.Key, item.Value);
}
/// <summary>
- /// Removes all items from the <see cref="T:System.Collections.Generic.ICollection`1"/>.
- /// </summary>
+ /// Removes all items from the <see cref="T:System.Collections.Generic.ICollection`1" />.
+ /// </summary>
public void Clear()
{
cache.Clear();
- db.Delete<OfflineEntry>(Query.All());
+ db.Delete<OfflineEntry>(LiteDB.Query.All());
}
/// <summary>
- /// Determines whether the <see cref="T:System.Collections.Generic.ICollection`1"/> contains a specific value.
+ /// Determines whether the <see cref="T:System.Collections.Generic.ICollection`1" /> contains a specific value.
/// </summary>
- /// <param name="item">The object to locate in the <see cref="T:System.Collections.Generic.ICollection`1"/>.</param>
- /// <returns> True if <paramref name="item"/> is found in the <see cref="T:System.Collections.Generic.ICollection`1"/>; otherwise, false. </returns>
+ /// <param name="item">The object to locate in the <see cref="T:System.Collections.Generic.ICollection`1" />.</param>
+ /// <returns>
+ /// True if <paramref name="item" /> is found in the <see cref="T:System.Collections.Generic.ICollection`1" />;
+ /// otherwise, false.
+ /// </returns>
public bool Contains(KeyValuePair<string, OfflineEntry> item)
{
return ContainsKey(item.Key);
}
/// <summary>
- /// Copies the elements of the <see cref="T:System.Collections.Generic.ICollection`1"/> to an <see cref="T:System.Array"/>, starting at a particular <see cref="T:System.Array"/> index.
+ /// Copies the elements of the <see cref="T:System.Collections.Generic.ICollection`1" /> to an
+ /// <see cref="T:System.Array" />, starting at a particular <see cref="T:System.Array" /> index.
/// </summary>
- /// <param name="array">The one-dimensional <see cref="T:System.Array"/> that is the destination of the elements copied from <see cref="T:System.Collections.Generic.ICollection`1"/>. The <see cref="T:System.Array"/> must have zero-based indexing.</param>
- /// <param name="arrayIndex">The zero-based index in <paramref name="array"/> at which copying begins.</param>
+ /// <param name="array">
+ /// The one-dimensional <see cref="T:System.Array" /> that is the destination of the elements copied
+ /// from <see cref="T:System.Collections.Generic.ICollection`1" />. The <see cref="T:System.Array" /> must have
+ /// zero-based indexing.
+ /// </param>
+ /// <param name="arrayIndex">The zero-based index in <paramref name="array" /> at which copying begins.</param>
public void CopyTo(KeyValuePair<string, OfflineEntry>[] array, int arrayIndex)
{
cache.CopyTo(array, arrayIndex);
}
/// <summary>
- /// Removes the first occurrence of a specific object from the <see cref="T:System.Collections.Generic.ICollection`1"/>.
+ /// Removes the first occurrence of a specific object from the
+ /// <see cref="T:System.Collections.Generic.ICollection`1" />.
/// </summary>
- /// <param name="item">The object to remove from the <see cref="T:System.Collections.Generic.ICollection`1"/>.</param>
- /// <returns> True if <paramref name="item"/> was successfully removed from the <see cref="T:System.Collections.Generic.ICollection`1"/>; otherwise, false. This method also returns false if <paramref name="item"/> is not found in the original <see cref="T:System.Collections.Generic.ICollection`1"/>. </returns>
+ /// <param name="item">The object to remove from the <see cref="T:System.Collections.Generic.ICollection`1" />.</param>
+ /// <returns>
+ /// True if <paramref name="item" /> was successfully removed from the
+ /// <see cref="T:System.Collections.Generic.ICollection`1" />; otherwise, false. This method also returns false if
+ /// <paramref name="item" /> is not found in the original <see cref="T:System.Collections.Generic.ICollection`1" />.
+ /// </returns>
public bool Remove(KeyValuePair<string, OfflineEntry> item)
{
return Remove(item.Key);
}
/// <summary>
- /// Determines whether the <see cref="T:System.Collections.Generic.IDictionary`2"/> contains an element with the specified key.
+ /// Determines whether the <see cref="T:System.Collections.Generic.IDictionary`2" /> contains an element with the
+ /// specified key.
/// </summary>
- /// <param name="key">The key to locate in the <see cref="T:System.Collections.Generic.IDictionary`2"/>.</param>
- /// <returns> True if the <see cref="T:System.Collections.Generic.IDictionary`2"/> contains an element with the key; otherwise, false. </returns>
+ /// <param name="key">The key to locate in the <see cref="T:System.Collections.Generic.IDictionary`2" />.</param>
+ /// <returns>
+ /// True if the <see cref="T:System.Collections.Generic.IDictionary`2" /> contains an element with the key;
+ /// otherwise, false.
+ /// </returns>
public bool ContainsKey(string key)
{
return cache.ContainsKey(key);
}
/// <summary>
- /// Adds an element with the provided key and value to the <see cref="T:System.Collections.Generic.IDictionary`2"/>.
+ /// Adds an element with the provided key and value to the <see cref="T:System.Collections.Generic.IDictionary`2" />.
/// </summary>
/// <param name="key">The object to use as the key of the element to add.</param>
/// <param name="value">The object to use as the value of the element to add.</param>
@@ -160,10 +185,13 @@
}
/// <summary>
- /// Removes the element with the specified key from the <see cref="T:System.Collections.Generic.IDictionary`2"/>.
+ /// Removes the element with the specified key from the <see cref="T:System.Collections.Generic.IDictionary`2" />.
/// </summary>
/// <param name="key">The key of the element to remove.</param>
- /// <returns> True if the element is successfully removed; otherwise, false. This method also returns false if <paramref name="key"/> was not found in the original <see cref="T:System.Collections.Generic.IDictionary`2"/>. </returns>
+ /// <returns>
+ /// True if the element is successfully removed; otherwise, false. This method also returns false if
+ /// <paramref name="key" /> was not found in the original <see cref="T:System.Collections.Generic.IDictionary`2" />.
+ /// </returns>
public bool Remove(string key)
{
cache.Remove(key);
@@ -171,10 +199,18 @@
}
/// <summary>
- /// Gets the value associated with the specified key.
- /// </summary>
- /// <param name="key">The key whose value to get.</param><param name="value">When this method returns, the value associated with the specified key, if the key is found; otherwise, the default value for the type of the <paramref name="value"/> parameter. This parameter is passed uninitialized.</param>
- /// <returns> True if the object that implements <see cref="T:System.Collections.Generic.IDictionary`2"/> contains an element with the specified key; otherwise, false. </returns>
+ /// Gets the value associated with the specified key.
+ /// </summary>
+ /// <param name="key">The key whose value to get.</param>
+ /// <param name="value">
+ /// When this method returns, the value associated with the specified key, if the key is found;
+ /// otherwise, the default value for the type of the <paramref name="value" /> parameter. This parameter is passed
+ /// uninitialized.
+ /// </param>
+ /// <returns>
+ /// True if the object that implements <see cref="T:System.Collections.Generic.IDictionary`2" /> contains an
+ /// element with the specified key; otherwise, false.
+ /// </returns>
public bool TryGetValue(string key, out OfflineEntry value)
{
return cache.TryGetValue(key, out value);
diff --git a/FireBase/Offline/OfflineEntry.cs b/FireBase/Offline/OfflineEntry.cs
index dfd5910..9feffa3 100644
--- a/FireBase/Offline/OfflineEntry.cs
+++ b/FireBase/Offline/OfflineEntry.cs
@@ -1,21 +1,24 @@
-namespace Firebase.Database.Offline
-{
- using System;
- using Newtonsoft.Json;
+using System;
+using Newtonsoft.Json;
+namespace Firebase.Database.Offline
+{
/// <summary>
- /// Represents an object stored in offline storage.
+ /// Represents an object stored in offline storage.
/// </summary>
public class OfflineEntry
{
private object dataInstance;
/// <summary>
- /// Initializes a new instance of the <see cref="OfflineEntry"/> class with an already serialized object.
+ /// Initializes a new instance of the <see cref="OfflineEntry" /> class with an already serialized object.
/// </summary>
/// <param name="key"> The key. </param>
/// <param name="obj"> The object. </param>
- /// <param name="priority"> The priority. Objects with higher priority will be synced first. Higher number indicates higher priority. </param>
+ /// <param name="priority">
+ /// The priority. Objects with higher priority will be synced first. Higher number indicates higher
+ /// priority.
+ /// </param>
/// <param name="syncOptions"> The sync options. </param>
public OfflineEntry(string key, object obj, string data, int priority, SyncOptions syncOptions,
bool isPartial = false)
@@ -31,11 +34,14 @@
}
/// <summary>
- /// Initializes a new instance of the <see cref="OfflineEntry"/> class.
+ /// Initializes a new instance of the <see cref="OfflineEntry" /> class.
/// </summary>
/// <param name="key"> The key. </param>
/// <param name="obj"> The object. </param>
- /// <param name="priority"> The priority. Objects with higher priority will be synced first. Higher number indicates higher priority. </param>
+ /// <param name="priority">
+ /// The priority. Objects with higher priority will be synced first. Higher number indicates higher
+ /// priority.
+ /// </param>
/// <param name="syncOptions"> The sync options. </param>
public OfflineEntry(string key, object obj, int priority, SyncOptions syncOptions, bool isPartial = false)
: this(key, obj, JsonConvert.SerializeObject(obj), priority, syncOptions, isPartial)
@@ -43,47 +49,48 @@
}
/// <summary>
- /// Initializes a new instance of the <see cref="OfflineEntry"/> class.
+ /// Initializes a new instance of the <see cref="OfflineEntry" /> class.
/// </summary>
public OfflineEntry()
{
}
/// <summary>
- /// Gets or sets the key of this entry.
+ /// Gets or sets the key of this entry.
/// </summary>
public string Key { get; set; }
/// <summary>
- /// Gets or sets the priority. Objects with higher priority will be synced first. Higher number indicates higher priority.
+ /// Gets or sets the priority. Objects with higher priority will be synced first. Higher number indicates higher
+ /// priority.
/// </summary>
public int Priority { get; set; }
/// <summary>
- /// Gets or sets the timestamp when this entry was last touched.
+ /// Gets or sets the timestamp when this entry was last touched.
/// </summary>
public DateTime Timestamp { get; set; }
/// <summary>
- /// Gets or sets the <see cref="SyncOptions"/> which define what sync state this entry is in.
+ /// Gets or sets the <see cref="SyncOptions" /> which define what sync state this entry is in.
/// </summary>
public SyncOptions SyncOptions { get; set; }
/// <summary>
- /// Gets or sets serialized JSON data.
+ /// Gets or sets serialized JSON data.
/// </summary>
public string Data { get; set; }
/// <summary>
- /// Specifies whether this is only a partial object.
+ /// Specifies whether this is only a partial object.
/// </summary>
public bool IsPartial { get; set; }
/// <summary>
- /// Deserializes <see cref="Data"/> into <typeparamref name="T"/>. The result is cached.
+ /// Deserializes <see cref="Data" /> into <typeparamref name="T" />. The result is cached.
/// </summary>
/// <typeparam name="T"> Type of object to deserialize into. </typeparam>
- /// <returns> Instance of <typeparamref name="T"/>. </returns>
+ /// <returns> Instance of <typeparamref name="T" />. </returns>
public T Deserialize<T>()
{
return (T) (dataInstance ?? (dataInstance = JsonConvert.DeserializeObject<T>(Data)));
diff --git a/FireBase/Offline/RealtimeDatabase.cs b/FireBase/Offline/RealtimeDatabase.cs
index 4d61027..973db46 100644
--- a/FireBase/Offline/RealtimeDatabase.cs
+++ b/FireBase/Offline/RealtimeDatabase.cs
@@ -1,50 +1,57 @@
-namespace Firebase.Database.Offline
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Linq.Expressions;
+using System.Net;
+using System.Reactive.Disposables;
+using System.Reactive.Linq;
+using System.Reactive.Subjects;
+using System.Reactive.Threading.Tasks;
+using System.Reflection;
+using System.Threading;
+using System.Threading.Tasks;
+using Firebase.Database.Extensions;
+using Firebase.Database.Offline.Internals;
+using Firebase.Database.Query;
+using Firebase.Database.Streaming;
+using Newtonsoft.Json;
+
+namespace Firebase.Database.Offline
{
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Reactive.Linq;
- using System.Reactive.Subjects;
- using System.Threading;
- using System.Threading.Tasks;
- using Extensions;
- using Query;
- using Streaming;
- using System.Reactive.Threading.Tasks;
- using System.Linq.Expressions;
- using Internals;
- using Newtonsoft.Json;
- using System.Reflection;
- using System.Reactive.Disposables;
-
/// <summary>
- /// The real-time Database which synchronizes online and offline data.
+ /// The real-time Database which synchronizes online and offline data.
/// </summary>
/// <typeparam name="T"> Type of entities. </typeparam>
- public partial class RealtimeDatabase<T> : IDisposable where T : class
+ public class RealtimeDatabase<T> : IDisposable where T : class
{
private readonly ChildQuery childQuery;
private readonly string elementRoot;
- private readonly StreamingOptions streamingOptions;
- private readonly Subject<FirebaseEvent<T>> subject;
+ private readonly FirebaseCache<T> firebaseCache;
private readonly InitialPullStrategy initialPullStrategy;
private readonly bool pushChanges;
- private readonly FirebaseCache<T> firebaseCache;
+ private readonly StreamingOptions streamingOptions;
+ private readonly Subject<FirebaseEvent<T>> subject;
+ private FirebaseSubscription<T> firebaseSubscription;
private bool isSyncRunning;
private IObservable<FirebaseEvent<T>> observable;
- private FirebaseSubscription<T> firebaseSubscription;
/// <summary>
- /// Initializes a new instance of the <see cref="RealtimeDatabase{T}"/> class.
+ /// Initializes a new instance of the <see cref="RealtimeDatabase{T}" /> class.
/// </summary>
/// <param name="childQuery"> The child query. </param>
/// <param name="elementRoot"> The element Root. </param>
/// <param name="offlineDatabaseFactory"> The offline database factory. </param>
/// <param name="filenameModifier"> Custom string which will get appended to the file name. </param>
/// <param name="streamChanges"> Specifies whether changes should be streamed from the server. </param>
- /// <param name="pullEverythingOnStart"> Specifies if everything should be pull from the online storage on start. It only makes sense when <see cref="streamChanges"/> is set to true. </param>
- /// <param name="pushChanges"> Specifies whether changed items should actually be pushed to the server. If this is false, then Put / Post / Delete will not affect server data. </param>
+ /// <param name="pullEverythingOnStart">
+ /// Specifies if everything should be pull from the online storage on start. It only
+ /// makes sense when <see cref="streamChanges" /> is set to true.
+ /// </param>
+ /// <param name="pushChanges">
+ /// Specifies whether changed items should actually be pushed to the server. If this is false,
+ /// then Put / Post / Delete will not affect server data.
+ /// </param>
public RealtimeDatabase(ChildQuery childQuery, string elementRoot,
Func<Type, string, IDictionary<string, OfflineEntry>> offlineDatabaseFactory, string filenameModifier,
StreamingOptions streamingOptions, InitialPullStrategy initialPullStrategy, bool pushChanges,
@@ -67,24 +74,34 @@
}
/// <summary>
- /// Event raised whenever an exception is thrown in the synchronization thread. Exception thrown in there are swallowed, so this event is the only way to get to them.
+ /// Gets the backing Database.
/// </summary>
- public event EventHandler<ExceptionEventArgs> SyncExceptionThrown;
+ public IDictionary<string, OfflineEntry> Database { get; }
+
+ public ISetHandler<T> PutHandler { private get; set; }
+
+ public void Dispose()
+ {
+ subject.OnCompleted();
+ firebaseSubscription?.Dispose();
+ }
/// <summary>
- /// Gets the backing Database.
+ /// Event raised whenever an exception is thrown in the synchronization thread. Exception thrown in there are
+ /// swallowed, so this event is the only way to get to them.
/// </summary>
- public IDictionary<string, OfflineEntry> Database { get; private set; }
-
- public ISetHandler<T> PutHandler { private get; set; }
+ public event EventHandler<ExceptionEventArgs> SyncExceptionThrown;
/// <summary>
- /// Overwrites existing object with given key.
+ /// Overwrites existing object with given key.
/// </summary>
/// <param name="key"> The key. </param>
/// <param name="obj"> The object to set. </param>
/// <param name="syncOnline"> Indicates whether the item should be synced online. </param>
- /// <param name="priority"> The priority. Objects with higher priority will be synced first. Higher number indicates higher priority. </param>
+ /// <param name="priority">
+ /// The priority. Objects with higher priority will be synced first. Higher number indicates higher
+ /// priority.
+ /// </param>
public void Set(string key, T obj, SyncOptions syncOptions, int priority = 1)
{
SetAndRaise(key, new OfflineEntry(key, obj, priority, syncOptions));
@@ -118,10 +135,13 @@
}
/// <summary>
- /// Fetches an object with the given key and adds it to the Database.
+ /// Fetches an object with the given key and adds it to the Database.
/// </summary>
/// <param name="key"> The key. </param>
- /// <param name="priority"> The priority. Objects with higher priority will be synced first. Higher number indicates higher priority. </param>
+ /// <param name="priority">
+ /// The priority. Objects with higher priority will be synced first. Higher number indicates higher
+ /// priority.
+ /// </param>
public void Pull(string key, int priority = 1)
{
if (!Database.ContainsKey(key))
@@ -132,7 +152,7 @@
}
/// <summary>
- /// Fetches everything from the remote database.
+ /// Fetches everything from the remote database.
/// </summary>
public async Task PullAsync()
{
@@ -142,7 +162,7 @@
.RetryAfterDelay<IReadOnlyCollection<FirebaseObject<T>>, FirebaseException>(
childQuery.Client.Options.SyncPeriod,
ex => ex.StatusCode ==
- System.Net.HttpStatusCode
+ HttpStatusCode
.OK) // OK implies the request couldn't complete due to network error.
.Select(e => ResetDatabaseFromInitial(e, false))
.SelectMany(e => e)
@@ -164,7 +184,7 @@
}
/// <summary>
- /// Retrieves all offline items currently stored in local database.
+ /// Retrieves all offline items currently stored in local database.
/// </summary>
public IEnumerable<FirebaseObject<T>> Once()
{
@@ -174,10 +194,10 @@
.ToList();
}
- /// <summary>
- /// Starts observing the real-time Database. Events will be fired both when change is done locally and remotely.
- /// </summary>
- /// <returns> Stream of <see cref="FirebaseEvent{T}"/>. </returns>
+ /// <summary>
+ /// Starts observing the real-time Database. Events will be fired both when change is done locally and remotely.
+ /// </summary>
+ /// <returns> Stream of <see cref="FirebaseEvent{T}" />. </returns>
public IObservable<FirebaseEvent<T>> AsObservable()
{
if (!isSyncRunning)
@@ -212,7 +232,7 @@
.RetryAfterDelay<IReadOnlyCollection<FirebaseObject<T>>, FirebaseException>(
childQuery.Client.Options.SyncPeriod,
ex => ex.StatusCode ==
- System.Net.HttpStatusCode
+ HttpStatusCode
.OK) // OK implies the request couldn't complete due to network error.
.Select(e => ResetDatabaseFromInitial(e))
.SelectMany(e => e)
@@ -230,12 +250,6 @@
return observable;
}
- public void Dispose()
- {
- subject.OnCompleted();
- firebaseSubscription?.Dispose();
- }
-
private IReadOnlyCollection<FirebaseObject<T>> ResetDatabaseFromInitial(
IReadOnlyCollection<FirebaseObject<T>> collection, bool onlyWhenInitialEverything = true)
{
@@ -308,8 +322,6 @@
firebaseSubscription.ExceptionThrown += StreamingExceptionThrown;
return new CompositeDisposable(firebaseSubscription.Run(), completeDisposable);
- default:
- break;
}
return completeDisposable;
diff --git a/FireBase/Offline/SetHandler.cs b/FireBase/Offline/SetHandler.cs
index 18a5131..6314c3c 100644
--- a/FireBase/Offline/SetHandler.cs
+++ b/FireBase/Offline/SetHandler.cs
@@ -1,8 +1,8 @@
-namespace Firebase.Database.Offline
-{
- using Query;
- using System.Threading.Tasks;
+using System.Threading.Tasks;
+using Firebase.Database.Query;
+namespace Firebase.Database.Offline
+{
public class SetHandler<T> : ISetHandler<T>
{
public virtual async Task SetAsync(ChildQuery query, string key, OfflineEntry entry)
diff --git a/FireBase/Offline/StreamingOptions.cs b/FireBase/Offline/StreamingOptions.cs
index 4a5f7b8..a420cbb 100644
--- a/FireBase/Offline/StreamingOptions.cs
+++ b/FireBase/Offline/StreamingOptions.cs
@@ -3,18 +3,20 @@
public enum StreamingOptions
{
/// <summary>
- /// No realtime streaming.
+ /// No realtime streaming.
/// </summary>
None,
/// <summary>
- /// Streaming of only new items - not the existing ones.
+ /// Streaming of only new items - not the existing ones.
/// </summary>
LatestOnly,
/// <summary>
- /// Streaming of all items. This will also pull all existing items on start, so be mindful about the number of items in your DB.
- /// When used, consider not setting the <see cref="InitialPullStrategy"/> to <see cref="InitialPullStrategy.Everything"/> because you would pointlessly pull everything twice.
+ /// Streaming of all items. This will also pull all existing items on start, so be mindful about the number of items in
+ /// your DB.
+ /// When used, consider not setting the <see cref="InitialPullStrategy" /> to
+ /// <see cref="InitialPullStrategy.Everything" /> because you would pointlessly pull everything twice.
/// </summary>
Everything
}
diff --git a/FireBase/Offline/SyncOptions.cs b/FireBase/Offline/SyncOptions.cs
index aa3e21c..ca68d0a 100644
--- a/FireBase/Offline/SyncOptions.cs
+++ b/FireBase/Offline/SyncOptions.cs
@@ -1,27 +1,27 @@
namespace Firebase.Database.Offline
{
/// <summary>
- /// Specifies type of sync requested for given data.
+ /// Specifies type of sync requested for given data.
/// </summary>
public enum SyncOptions
{
/// <summary>
- /// No sync needed for given data.
+ /// No sync needed for given data.
/// </summary>
None,
/// <summary>
- /// Data should be pulled from firebase.
+ /// Data should be pulled from firebase.
/// </summary>
Pull,
/// <summary>
- /// Data should be put to firebase.
+ /// Data should be put to firebase.
/// </summary>
Put,
/// <summary>
- /// Data should be patched in firebase.
+ /// Data should be patched in firebase.
/// </summary>
Patch
}
diff --git a/FireBase/Query/AuthQuery.cs b/FireBase/Query/AuthQuery.cs
index 14beb7e..2cfda3c 100644
--- a/FireBase/Query/AuthQuery.cs
+++ b/FireBase/Query/AuthQuery.cs
@@ -1,18 +1,18 @@
+using System;
+
namespace Firebase.Database.Query
{
- using System;
-
/// <summary>
- /// Represents an auth parameter in firebase query, e.g. "?auth=xyz".
+ /// Represents an auth parameter in firebase query, e.g. "?auth=xyz".
/// </summary>
public class AuthQuery : ParameterQuery
{
private readonly Func<string> tokenFactory;
/// <summary>
- /// Initializes a new instance of the <see cref="AuthQuery"/> class.
+ /// Initializes a new instance of the <see cref="AuthQuery" /> class.
/// </summary>
- /// <param name="parent"> The parent. </param>
+ /// <param name="parent"> The parent. </param>
/// <param name="tokenFactory"> The authentication token factory. </param>
/// <param name="client"> The owner. </param>
public AuthQuery(FirebaseQuery parent, Func<string> tokenFactory, FirebaseClient client) : base(parent,
@@ -22,10 +22,10 @@ namespace Firebase.Database.Query
}
/// <summary>
- /// Build the url parameter value of this child.
+ /// Build the url parameter value of this child.
/// </summary>
/// <param name="child"> The child of this child. </param>
- /// <returns> The <see cref="string"/>. </returns>
+ /// <returns> The <see cref="string" />. </returns>
protected override string BuildUrlParameter(FirebaseQuery child)
{
return tokenFactory();
diff --git a/FireBase/Query/ChildQuery.cs b/FireBase/Query/ChildQuery.cs
index 510ae75..014fe09 100644
--- a/FireBase/Query/ChildQuery.cs
+++ b/FireBase/Query/ChildQuery.cs
@@ -1,16 +1,16 @@
+using System;
+
namespace Firebase.Database.Query
{
- using System;
-
/// <summary>
- /// Firebase query which references the child of current node.
+ /// Firebase query which references the child of current node.
/// </summary>
public class ChildQuery : FirebaseQuery
{
private readonly Func<string> pathFactory;
/// <summary>
- /// Initializes a new instance of the <see cref="ChildQuery"/> class.
+ /// Initializes a new instance of the <see cref="ChildQuery" /> class.
/// </summary>
/// <param name="parent"> The parent. </param>
/// <param name="pathFactory"> The path to the child node. </param>
@@ -22,7 +22,7 @@ namespace Firebase.Database.Query
}
/// <summary>
- /// Initializes a new instance of the <see cref="ChildQuery"/> class.
+ /// Initializes a new instance of the <see cref="ChildQuery" /> class.
/// </summary>
/// <param name="client"> The client. </param>
/// <param name="pathFactory"> The path to the child node. </param>
@@ -32,10 +32,10 @@ namespace Firebase.Database.Query
}
/// <summary>
- /// Build the url segment of this child.
+ /// Build the url segment of this child.
/// </summary>
/// <param name="child"> The child of this child. </param>
- /// <returns> The <see cref="string"/>. </returns>
+ /// <returns> The <see cref="string" />. </returns>
protected override string BuildUrlSegment(FirebaseQuery child)
{
var s = pathFactory();
diff --git a/FireBase/Query/FilterQuery.cs b/FireBase/Query/FilterQuery.cs
index be544c8..3434d1d 100644
--- a/FireBase/Query/FilterQuery.cs
+++ b/FireBase/Query/FilterQuery.cs
@@ -1,24 +1,24 @@
+using System;
+using System.Globalization;
+
namespace Firebase.Database.Query
{
- using System;
- using System.Globalization;
-
/// <summary>
- /// Represents a firebase filtering query, e.g. "?LimitToLast=10".
+ /// Represents a firebase filtering query, e.g. "?LimitToLast=10".
/// </summary>
public class FilterQuery : ParameterQuery
{
- private readonly Func<string> valueFactory;
- private readonly Func<double> doubleValueFactory;
private readonly Func<bool> boolValueFactory;
+ private readonly Func<double> doubleValueFactory;
+ private readonly Func<string> valueFactory;
/// <summary>
- /// Initializes a new instance of the <see cref="FilterQuery"/> class.
+ /// Initializes a new instance of the <see cref="FilterQuery" /> class.
/// </summary>
/// <param name="parent"> The parent. </param>
/// <param name="filterFactory"> The filter. </param>
/// <param name="valueFactory"> The value for filter. </param>
- /// <param name="client"> The owning client. </param>
+ /// <param name="client"> The owning client. </param>
public FilterQuery(FirebaseQuery parent, Func<string> filterFactory, Func<string> valueFactory,
FirebaseClient client)
: base(parent, filterFactory, client)
@@ -27,7 +27,7 @@ namespace Firebase.Database.Query
}
/// <summary>
- /// Initializes a new instance of the <see cref="FilterQuery"/> class.
+ /// Initializes a new instance of the <see cref="FilterQuery" /> class.
/// </summary>
/// <param name="parent"> The parent. </param>
/// <param name="filterFactory"> The filter. </param>
@@ -41,7 +41,7 @@ namespace Firebase.Database.Query
}
/// <summary>
- /// Initializes a new instance of the <see cref="FilterQuery"/> class.
+ /// Initializes a new instance of the <see cref="FilterQuery" /> class.
/// </summary>
/// <param name="parent"> The parent. </param>
/// <param name="filterFactory"> The filter. </param>
@@ -55,25 +55,21 @@ namespace Firebase.Database.Query
}
/// <summary>
- /// The build url parameter.
+ /// The build url parameter.
/// </summary>
- /// <param name="child"> The child. </param>
- /// <returns> Url parameter part of the resulting path. </returns>
+ /// <param name="child"> The child. </param>
+ /// <returns> Url parameter part of the resulting path. </returns>
protected override string BuildUrlParameter(FirebaseQuery child)
{
if (valueFactory != null)
{
- if (valueFactory() == null) return $"null";
+ if (valueFactory() == null) return "null";
return $"\"{valueFactory()}\"";
}
- else if (doubleValueFactory != null)
- {
+
+ if (doubleValueFactory != null)
return doubleValueFactory().ToString(CultureInfo.InvariantCulture);
- }
- else if (boolValueFactory != null)
- {
- return $"{boolValueFactory().ToString().ToLower()}";
- }
+ if (boolValueFactory != null) return $"{boolValueFactory().ToString().ToLower()}";
return string.Empty;
}
diff --git a/FireBase/Query/FirebaseQuery.cs b/FireBase/Query/FirebaseQuery.cs
index 5e09795..60d0289 100644
--- a/FireBase/Query/FirebaseQuery.cs
+++ b/FireBase/Query/FirebaseQuery.cs
@@ -1,29 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.Net;
+using System.Net.Http;
+using System.Reactive.Linq;
+using System.Threading.Tasks;
+using Firebase.Database.Http;
+using Firebase.Database.Streaming;
+using Newtonsoft.Json;
+
namespace Firebase.Database.Query
{
- using System;
- using System.Collections.Generic;
- using System.Net.Http;
- using System.Reactive.Linq;
- using System.Threading.Tasks;
- using Http;
- using Offline;
- using Streaming;
- using Newtonsoft.Json;
- using System.Net;
-
/// <summary>
- /// Represents a firebase query.
+ /// Represents a firebase query.
/// </summary>
public abstract class FirebaseQuery : IFirebaseQuery, IDisposable
{
- protected TimeSpan DEFAULT_HTTP_CLIENT_TIMEOUT = new TimeSpan(0, 0, 180);
-
protected readonly FirebaseQuery Parent;
private HttpClient client;
+ protected TimeSpan DEFAULT_HTTP_CLIENT_TIMEOUT = new TimeSpan(0, 0, 180);
- /// <summary>
- /// Initializes a new instance of the <see cref="FirebaseQuery"/> class.
+ /// <summary>
+ /// Initializes a new instance of the <see cref="FirebaseQuery" /> class.
/// </summary>
/// <param name="parent"> The parent of this query. </param>
/// <param name="client"> The owning client. </param>
@@ -34,16 +32,24 @@ namespace Firebase.Database.Query
}
/// <summary>
- /// Gets the client.
+ /// Disposes this instance.
+ /// </summary>
+ public void Dispose()
+ {
+ client?.Dispose();
+ }
+
+ /// <summary>
+ /// Gets the client.
/// </summary>
public FirebaseClient Client { get; }
/// <summary>
- /// Queries the firebase server once returning collection of items.
+ /// Queries the firebase server once returning collection of items.
/// </summary>
/// <param name="timeout"> Optional timeout value. </param>
/// <typeparam name="T"> Type of elements. </typeparam>
- /// <returns> Collection of <see cref="FirebaseObject{T}"/> holding the entities returned by server. </returns>
+ /// <returns> Collection of <see cref="FirebaseObject{T}" /> holding the entities returned by server. </returns>
public async Task<IReadOnlyCollection<FirebaseObject<T>>> OnceAsync<T>(TimeSpan? timeout = null)
{
var url = string.Empty;
@@ -62,6 +68,39 @@ namespace Firebase.Database.Query
.ConfigureAwait(false);
}
+ /// <summary>
+ /// Starts observing this query watching for changes real time sent by the server.
+ /// </summary>
+ /// <typeparam name="T"> Type of elements. </typeparam>
+ /// <param name="elementRoot"> Optional custom root element of received json items. </param>
+ /// <returns> Observable stream of <see cref="FirebaseEvent{T}" />. </returns>
+ public IObservable<FirebaseEvent<T>> AsObservable<T>(
+ EventHandler<ExceptionEventArgs<FirebaseException>> exceptionHandler = null, string elementRoot = "")
+ {
+ return Observable.Create<FirebaseEvent<T>>(observer =>
+ {
+ var sub = new FirebaseSubscription<T>(observer, this, elementRoot, new FirebaseCache<T>());
+ sub.ExceptionThrown += exceptionHandler;
+ return sub.Run();
+ });
+ }
+
+ /// <summary>
+ /// Builds the actual URL of this query.
+ /// </summary>
+ /// <returns> The <see cref="string" />. </returns>
+ public async Task<string> BuildUrlAsync()
+ {
+ // if token factory is present on the parent then use it to generate auth token
+ if (Client.Options.AuthTokenAsyncFactory != null)
+ {
+ var token = await Client.Options.AuthTokenAsyncFactory().ConfigureAwait(false);
+ return this.WithAuth(token).BuildUrl(null);
+ }
+
+ return BuildUrl(null);
+ }
+
/*public async Task<IReadOnlyCollection<FirebaseObject<Object>>> OnceAsync(Type dataType, TimeSpan? timeout = null)
{
var url = string.Empty;
@@ -80,11 +119,11 @@ namespace Firebase.Database.Query
}*/
/// <summary>
- /// Assumes given query is pointing to a single object of type <typeparamref name="T"/> and retrieves it.
+ /// Assumes given query is pointing to a single object of type <typeparamref name="T" /> and retrieves it.
/// </summary>
/// <param name="timeout"> Optional timeout value. </param>
/// <typeparam name="T"> Type of elements. </typeparam>
- /// <returns> Single object of type <typeparamref name="T"/>. </returns>
+ /// <returns> Single object of type <typeparamref name="T" />. </returns>
public async Task<T> OnceSingleAsync<T>(TimeSpan? timeout = null)
{
var responseData = string.Empty;
@@ -118,45 +157,12 @@ namespace Firebase.Database.Query
}
/// <summary>
- /// Starts observing this query watching for changes real time sent by the server.
- /// </summary>
- /// <typeparam name="T"> Type of elements. </typeparam>
- /// <param name="elementRoot"> Optional custom root element of received json items. </param>
- /// <returns> Observable stream of <see cref="FirebaseEvent{T}"/>. </returns>
- public IObservable<FirebaseEvent<T>> AsObservable<T>(
- EventHandler<ExceptionEventArgs<FirebaseException>> exceptionHandler = null, string elementRoot = "")
- {
- return Observable.Create<FirebaseEvent<T>>(observer =>
- {
- var sub = new FirebaseSubscription<T>(observer, this, elementRoot, new FirebaseCache<T>());
- sub.ExceptionThrown += exceptionHandler;
- return sub.Run();
- });
- }
-
- /// <summary>
- /// Builds the actual URL of this query.
- /// </summary>
- /// <returns> The <see cref="string"/>. </returns>
- public async Task<string> BuildUrlAsync()
- {
- // if token factory is present on the parent then use it to generate auth token
- if (Client.Options.AuthTokenAsyncFactory != null)
- {
- var token = await Client.Options.AuthTokenAsyncFactory().ConfigureAwait(false);
- return this.WithAuth(token).BuildUrl(null);
- }
-
- return BuildUrl(null);
- }
-
- /// <summary>
- /// Posts given object to repository.
+ /// Posts given object to repository.
/// </summary>
/// <param name="obj"> The object. </param>
/// <param name="generateKeyOffline"> Specifies whether the key should be generated offline instead of online. </param>
/// <param name="timeout"> Optional timeout value. </param>
- /// <typeparam name="T"> Type of <see cref="obj"/> </typeparam>
+ /// <typeparam name="T"> Type of <see cref="obj" /> </typeparam>
/// <returns> Resulting firebase object with populated key. </returns>
public async Task<FirebaseObject<string>> PostAsync(string data, bool generateKeyOffline = true,
TimeSpan? timeout = null)
@@ -169,23 +175,21 @@ namespace Firebase.Database.Query
return new FirebaseObject<string>(key, data);
}
- else
- {
- var c = GetClient(timeout);
- var sendData = await SendAsync(c, data, HttpMethod.Post).ConfigureAwait(false);
- var result = JsonConvert.DeserializeObject<PostResult>(sendData, Client.Options.JsonSerializerSettings);
- return new FirebaseObject<string>(result.Name, data);
- }
+ var c = GetClient(timeout);
+ var sendData = await SendAsync(c, data, HttpMethod.Post).ConfigureAwait(false);
+ var result = JsonConvert.DeserializeObject<PostResult>(sendData, Client.Options.JsonSerializerSettings);
+
+ return new FirebaseObject<string>(result.Name, data);
}
/// <summary>
- /// Patches data at given location instead of overwriting them.
- /// </summary>
+ /// Patches data at given location instead of overwriting them.
+ /// </summary>
/// <param name="obj"> The object. </param>
/// <param name="timeout"> Optional timeout value. </param>
- /// <typeparam name="T"> Type of <see cref="obj"/> </typeparam>
- /// <returns> The <see cref="Task"/>. </returns>
+ /// <typeparam name="T"> Type of <see cref="obj" /> </typeparam>
+ /// <returns> The <see cref="Task" />. </returns>
public async Task PatchAsync(string data, TimeSpan? timeout = null)
{
var c = GetClient(timeout);
@@ -194,12 +198,12 @@ namespace Firebase.Database.Query
}
/// <summary>
- /// Sets or overwrites data at given location.
- /// </summary>
+ /// Sets or overwrites data at given location.
+ /// </summary>
/// <param name="obj"> The object. </param>
/// <param name="timeout"> Optional timeout value. </param>
- /// <typeparam name="T"> Type of <see cref="obj"/> </typeparam>
- /// <returns> The <see cref="Task"/>. </returns>
+ /// <typeparam name="T"> Type of <see cref="obj" /> </typeparam>
+ /// <returns> The <see cref="Task" />. </returns>
public async Task PutAsync(string data, TimeSpan? timeout = null)
{
var c = GetClient(timeout);
@@ -208,10 +212,10 @@ namespace Firebase.Database.Query
}
/// <summary>
- /// Deletes data from given location.
+ /// Deletes data from given location.
/// </summary>
/// <param name="timeout"> Optional timeout value. </param>
- /// <returns> The <see cref="Task"/>. </returns>
+ /// <returns> The <see cref="Task" />. </returns>
public async Task DeleteAsync(TimeSpan? timeout = null)
{
var c = GetClient(timeout);
@@ -243,18 +247,10 @@ namespace Firebase.Database.Query
}
/// <summary>
- /// Disposes this instance.
- /// </summary>
- public void Dispose()
- {
- client?.Dispose();
- }
-
- /// <summary>
- /// Build the url segment of this child.
+ /// Build the url segment of this child.
/// </summary>
/// <param name="child"> The child of this query. </param>
- /// <returns> The <see cref="string"/>. </returns>
+ /// <returns> The <see cref="string" />. </returns>
protected abstract string BuildUrlSegment(FirebaseQuery child);
private string BuildUrl(FirebaseQuery child)
diff --git a/FireBase/Query/IFirebaseQuery.cs b/FireBase/Query/IFirebaseQuery.cs
index 9f6e36c..0da4b15 100644
--- a/FireBase/Query/IFirebaseQuery.cs
+++ b/FireBase/Query/IFirebaseQuery.cs
@@ -1,40 +1,40 @@
-namespace Firebase.Database.Query
-{
- using System;
- using System.Collections.Generic;
- using System.Threading.Tasks;
- using Streaming;
+using System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using Firebase.Database.Streaming;
+namespace Firebase.Database.Query
+{
/// <summary>
- /// The FirebaseQuery interface.
+ /// The FirebaseQuery interface.
/// </summary>
public interface IFirebaseQuery
{
/// <summary>
- /// Gets the owning client of this query.
+ /// Gets the owning client of this query.
/// </summary>
FirebaseClient Client { get; }
/// <summary>
- /// Retrieves items which exist on the location specified by this query instance.
+ /// Retrieves items which exist on the location specified by this query instance.
/// </summary>
/// <param name="timeout"> Optional timeout value. </param>
/// <typeparam name="T"> Type of the items. </typeparam>
- /// <returns> Collection of <see cref="FirebaseObject{T}"/>. </returns>
+ /// <returns> Collection of <see cref="FirebaseObject{T}" />. </returns>
Task<IReadOnlyCollection<FirebaseObject<T>>> OnceAsync<T>(TimeSpan? timeout = null);
/// <summary>
- /// Returns current location as an observable which allows to real-time listening to events from the firebase server.
+ /// Returns current location as an observable which allows to real-time listening to events from the firebase server.
/// </summary>
/// <typeparam name="T"> Type of the items. </typeparam>
- /// <returns> Cold observable of <see cref="FirebaseEvent{T}"/>. </returns>
+ /// <returns> Cold observable of <see cref="FirebaseEvent{T}" />. </returns>
IObservable<FirebaseEvent<T>> AsObservable<T>(
EventHandler<ExceptionEventArgs<FirebaseException>> exceptionHandler, string elementRoot = "");
/// <summary>
- /// Builds the actual url of this query.
+ /// Builds the actual url of this query.
/// </summary>
- /// <returns> The <see cref="string"/>. </returns>
+ /// <returns> The <see cref="string" />. </returns>
Task<string> BuildUrlAsync();
}
} \ No newline at end of file
diff --git a/FireBase/Query/OrderQuery.cs b/FireBase/Query/OrderQuery.cs
index 16adba7..302d1a3 100644
--- a/FireBase/Query/OrderQuery.cs
+++ b/FireBase/Query/OrderQuery.cs
@@ -1,16 +1,16 @@
+using System;
+
namespace Firebase.Database.Query
{
- using System;
-
/// <summary>
- /// Represents a firebase ordering query, e.g. "?OrderBy=Foo".
+ /// Represents a firebase ordering query, e.g. "?OrderBy=Foo".
/// </summary>
public class OrderQuery : ParameterQuery
{
private readonly Func<string> propertyNameFactory;
/// <summary>
- /// Initializes a new instance of the <see cref="OrderQuery"/> class.
+ /// Initializes a new instance of the <see cref="OrderQuery" /> class.
/// </summary>
/// <param name="parent"> The query parent. </param>
/// <param name="propertyNameFactory"> The property name. </param>
@@ -22,10 +22,10 @@ namespace Firebase.Database.Query
}
/// <summary>
- /// The build url parameter.
+ /// The build url parameter.
/// </summary>
/// <param name="child"> The child. </param>
- /// <returns> The <see cref="string"/>. </returns>
+ /// <returns> The <see cref="string" />. </returns>
protected override string BuildUrlParameter(FirebaseQuery child)
{
return $"\"{propertyNameFactory()}\"";
diff --git a/FireBase/Query/ParameterQuery.cs b/FireBase/Query/ParameterQuery.cs
index fb273a3..572224c 100644
--- a/FireBase/Query/ParameterQuery.cs
+++ b/FireBase/Query/ParameterQuery.cs
@@ -1,9 +1,9 @@
+using System;
+
namespace Firebase.Database.Query
{
- using System;
-
/// <summary>
- /// Represents a parameter in firebase query, e.g. "?data=foo".
+ /// Represents a parameter in firebase query, e.g. "?data=foo".
/// </summary>
public abstract class ParameterQuery : FirebaseQuery
{
@@ -11,7 +11,7 @@ namespace Firebase.Database.Query
private readonly string separator;
/// <summary>
- /// Initializes a new instance of the <see cref="ParameterQuery"/> class.
+ /// Initializes a new instance of the <see cref="ParameterQuery" /> class.
/// </summary>
/// <param name="parent"> The parent of this query. </param>
/// <param name="parameterFactory"> The parameter. </param>
@@ -24,20 +24,20 @@ namespace Firebase.Database.Query
}
/// <summary>
- /// Build the url segment represented by this query.
- /// </summary>
+ /// Build the url segment represented by this query.
+ /// </summary>
/// <param name="child"> The child. </param>
- /// <returns> The <see cref="string"/>. </returns>
+ /// <returns> The <see cref="string" />. </returns>
protected override string BuildUrlSegment(FirebaseQuery child)
{
return $"{separator}{parameterFactory()}={BuildUrlParameter(child)}";
}
/// <summary>
- /// The build url parameter.
+ /// The build url parameter.
/// </summary>
/// <param name="child"> The child. </param>
- /// <returns> The <see cref="string"/>. </returns>
+ /// <returns> The <see cref="string" />. </returns>
protected abstract string BuildUrlParameter(FirebaseQuery child);
}
} \ No newline at end of file
diff --git a/FireBase/Query/QueryExtensions.cs b/FireBase/Query/QueryExtensions.cs
index 735fe0a..df2edfc 100644
--- a/FireBase/Query/QueryExtensions.cs
+++ b/FireBase/Query/QueryExtensions.cs
@@ -6,158 +6,163 @@ using Newtonsoft.Json;
namespace Firebase.Database.Query
{
/// <summary>
- /// Query extensions providing linq like syntax for firebase server methods.
+ /// Query extensions providing linq like syntax for firebase server methods.
/// </summary>
public static class QueryExtensions
{
/// <summary>
- /// Adds an auth parameter to the query.
+ /// Adds an auth parameter to the query.
/// </summary>
/// <param name="node"> The child. </param>
/// <param name="token"> The auth token. </param>
- /// <returns> The <see cref="AuthQuery"/>. </returns>
+ /// <returns> The <see cref="AuthQuery" />. </returns>
internal static AuthQuery WithAuth(this FirebaseQuery node, string token)
{
return node.WithAuth(() => token);
}
/// <summary>
- /// Appends print=silent to save bandwidth.
+ /// Appends print=silent to save bandwidth.
/// </summary>
/// <param name="node"> The child. </param>
- /// <returns> The <see cref="SilentQuery"/>. </returns>
+ /// <returns> The <see cref="SilentQuery" />. </returns>
internal static SilentQuery Silent(this FirebaseQuery node)
{
return new SilentQuery(node, node.Client);
}
/// <summary>
- /// References a sub child of the existing node.
+ /// References a sub child of the existing node.
/// </summary>
/// <param name="node"> The child. </param>
/// <param name="path"> The path of sub child. </param>
- /// <returns> The <see cref="ChildQuery"/>. </returns>
+ /// <returns> The <see cref="ChildQuery" />. </returns>
public static ChildQuery Child(this ChildQuery node, string path)
{
return node.Child(() => path);
}
/// <summary>
- /// Order data by given <see cref="propertyName"/>. Note that this is used mainly for following filtering queries and due to firebase implementation
- /// the data may actually not be ordered.
+ /// Order data by given <see cref="propertyName" />. Note that this is used mainly for following filtering queries and
+ /// due to firebase implementation
+ /// the data may actually not be ordered.
/// </summary>
/// <param name="child"> The child. </param>
/// <param name="propertyName"> The property name. </param>
- /// <returns> The <see cref="OrderQuery"/>. </returns>
+ /// <returns> The <see cref="OrderQuery" />. </returns>
public static OrderQuery OrderBy(this ChildQuery child, string propertyName)
{
return child.OrderBy(() => propertyName);
}
/// <summary>
- /// Instructs firebase to send data greater or equal to the <see cref="value"/>. This must be preceded by an OrderBy query.
+ /// Instructs firebase to send data greater or equal to the <see cref="value" />. This must be preceded by an OrderBy
+ /// query.
/// </summary>
/// <param name="child"> Current node. </param>
/// <param name="value"> Value to start at. </param>
- /// <returns> The <see cref="FilterQuery"/>. </returns>
+ /// <returns> The <see cref="FilterQuery" />. </returns>
public static FilterQuery StartAt(this ParameterQuery child, string value)
{
return child.StartAt(() => value);
}
/// <summary>
- /// Instructs firebase to send data lower or equal to the <see cref="value"/>. This must be preceded by an OrderBy query.
+ /// Instructs firebase to send data lower or equal to the <see cref="value" />. This must be preceded by an OrderBy
+ /// query.
/// </summary>
/// <param name="child"> Current node. </param>
/// <param name="value"> Value to start at. </param>
- /// <returns> The <see cref="FilterQuery"/>. </returns>
+ /// <returns> The <see cref="FilterQuery" />. </returns>
public static FilterQuery EndAt(this ParameterQuery child, string value)
{
return child.EndAt(() => value);
}
/// <summary>
- /// Instructs firebase to send data equal to the <see cref="value"/>. This must be preceded by an OrderBy query.
+ /// Instructs firebase to send data equal to the <see cref="value" />. This must be preceded by an OrderBy query.
/// </summary>
/// <param name="child"> Current node. </param>
/// <param name="value"> Value to start at. </param>
- /// <returns> The <see cref="FilterQuery"/>. </returns>
+ /// <returns> The <see cref="FilterQuery" />. </returns>
public static FilterQuery EqualTo(this ParameterQuery child, string value)
{
return child.EqualTo(() => value);
}
/// <summary>
- /// Instructs firebase to send data greater or equal to the <see cref="value"/>. This must be preceded by an OrderBy query.
+ /// Instructs firebase to send data greater or equal to the <see cref="value" />. This must be preceded by an OrderBy
+ /// query.
/// </summary>
/// <param name="child"> Current node. </param>
/// <param name="value"> Value to start at. </param>
- /// <returns> The <see cref="FilterQuery"/>. </returns>
+ /// <returns> The <see cref="FilterQuery" />. </returns>
public static FilterQuery StartAt(this ParameterQuery child, double value)
{
return child.StartAt(() => value);
}
/// <summary>
- /// Instructs firebase to send data lower or equal to the <see cref="value"/>. This must be preceded by an OrderBy query.
+ /// Instructs firebase to send data lower or equal to the <see cref="value" />. This must be preceded by an OrderBy
+ /// query.
/// </summary>
/// <param name="child"> Current node. </param>
/// <param name="value"> Value to start at. </param>
- /// <returns> The <see cref="FilterQuery"/>. </returns>
+ /// <returns> The <see cref="FilterQuery" />. </returns>
public static FilterQuery EndAt(this ParameterQuery child, double value)
{
return child.EndAt(() => value);
}
/// <summary>
- /// Instructs firebase to send data equal to the <see cref="value"/>. This must be preceded by an OrderBy query.
+ /// Instructs firebase to send data equal to the <see cref="value" />. This must be preceded by an OrderBy query.
/// </summary>
/// <param name="child"> Current node. </param>
/// <param name="value"> Value to start at. </param>
- /// <returns> The <see cref="FilterQuery"/>. </returns>
+ /// <returns> The <see cref="FilterQuery" />. </returns>
public static FilterQuery EqualTo(this ParameterQuery child, double value)
{
return child.EqualTo(() => value);
}
/// <summary>
- /// Instructs firebase to send data equal to the <see cref="value"/>. This must be preceded by an OrderBy query.
+ /// Instructs firebase to send data equal to the <see cref="value" />. This must be preceded by an OrderBy query.
/// </summary>
/// <param name="child"> Current node. </param>
/// <param name="value"> Value to start at. </param>
- /// <returns> The <see cref="FilterQuery"/>. </returns>
+ /// <returns> The <see cref="FilterQuery" />. </returns>
public static FilterQuery EqualTo(this ParameterQuery child, bool value)
{
return child.EqualTo(() => value);
}
/// <summary>
- /// Instructs firebase to send data equal to null. This must be preceded by an OrderBy query.
+ /// Instructs firebase to send data equal to null. This must be preceded by an OrderBy query.
/// </summary>
/// <param name="child"> Current node. </param>
- /// <returns> The <see cref="FilterQuery"/>. </returns>
+ /// <returns> The <see cref="FilterQuery" />. </returns>
public static FilterQuery EqualTo(this ParameterQuery child)
{
return child.EqualTo(() => null);
}
/// <summary>
- /// Limits the result to first <see cref="count"/> items.
+ /// Limits the result to first <see cref="count" /> items.
/// </summary>
/// <param name="child"> Current node. </param>
/// <param name="count"> Number of elements. </param>
- /// <returns> The <see cref="FilterQuery"/>. </returns>
+ /// <returns> The <see cref="FilterQuery" />. </returns>
public static FilterQuery LimitToFirst(this ParameterQuery child, int count)
{
return child.LimitToFirst(() => count);
}
/// <summary>
- /// Limits the result to last <see cref="count"/> items.
+ /// Limits the result to last <see cref="count" /> items.
/// </summary>
/// <param name="child"> Current node. </param>
/// <param name="count"> Number of elements. </param>
- /// <returns> The <see cref="FilterQuery"/>. </returns>
+ /// <returns> The <see cref="FilterQuery" />. </returns>
public static FilterQuery LimitToLast(this ParameterQuery child, int count)
{
return child.LimitToLast(() => count);
@@ -184,7 +189,8 @@ namespace Firebase.Database.Query
}
/// <summary>
- /// Fan out given item to multiple locations at once. See https://firebase.googleblog.com/2015/10/client-side-fan-out-for-data-consistency_73.html for details.
+ /// Fan out given item to multiple locations at once. See
+ /// https://firebase.googleblog.com/2015/10/client-side-fan-out-for-data-consistency_73.html for details.
/// </summary>
/// <typeparam name="T"> Type of object to fan out. </typeparam>
/// <param name="query"> Current node. </param>
diff --git a/FireBase/Query/QueryFactoryExtensions.cs b/FireBase/Query/QueryFactoryExtensions.cs
index b54c315..71dae5c 100644
--- a/FireBase/Query/QueryFactoryExtensions.cs
+++ b/FireBase/Query/QueryFactoryExtensions.cs
@@ -1,173 +1,184 @@
+using System;
+
namespace Firebase.Database.Query
{
- using System;
-
/// <summary>
- /// Query extensions providing linq like syntax for firebase server methods.
+ /// Query extensions providing linq like syntax for firebase server methods.
/// </summary>
public static class QueryFactoryExtensions
{
/// <summary>
- /// Adds an auth parameter to the query.
+ /// Adds an auth parameter to the query.
/// </summary>
/// <param name="node"> The child. </param>
/// <param name="tokenFactory"> The auth token. </param>
- /// <returns> The <see cref="AuthQuery"/>. </returns>
+ /// <returns> The <see cref="AuthQuery" />. </returns>
internal static AuthQuery WithAuth(this FirebaseQuery node, Func<string> tokenFactory)
{
return new AuthQuery(node, tokenFactory, node.Client);
}
/// <summary>
- /// References a sub child of the existing node.
+ /// References a sub child of the existing node.
/// </summary>
/// <param name="node"> The child. </param>
/// <param name="pathFactory"> The path of sub child. </param>
- /// <returns> The <see cref="ChildQuery"/>. </returns>
+ /// <returns> The <see cref="ChildQuery" />. </returns>
public static ChildQuery Child(this ChildQuery node, Func<string> pathFactory)
{
return new ChildQuery(node, pathFactory, node.Client);
}
/// <summary>
- /// Order data by given <see cref="propertyNameFactory"/>. Note that this is used mainly for following filtering queries and due to firebase implementation
- /// the data may actually not be ordered.
+ /// Order data by given <see cref="propertyNameFactory" />. Note that this is used mainly for following filtering
+ /// queries and due to firebase implementation
+ /// the data may actually not be ordered.
/// </summary>
/// <param name="child"> The child. </param>
/// <param name="propertyNameFactory"> The property name. </param>
- /// <returns> The <see cref="OrderQuery"/>. </returns>
+ /// <returns> The <see cref="OrderQuery" />. </returns>
public static OrderQuery OrderBy(this ChildQuery child, Func<string> propertyNameFactory)
{
return new OrderQuery(child, propertyNameFactory, child.Client);
}
/// <summary>
- /// Order data by $key. Note that this is used mainly for following filtering queries and due to firebase implementation
- /// the data may actually not be ordered.
+ /// Order data by $key. Note that this is used mainly for following filtering queries and due to firebase
+ /// implementation
+ /// the data may actually not be ordered.
/// </summary>
/// <param name="child"> The child. </param>
- /// <returns> The <see cref="OrderQuery"/>. </returns>
+ /// <returns> The <see cref="OrderQuery" />. </returns>
public static OrderQuery OrderByKey(this ChildQuery child)
{
return child.OrderBy("$key");
}
/// <summary>
- /// Order data by $value. Note that this is used mainly for following filtering queries and due to firebase implementation
- /// the data may actually not be ordered.
+ /// Order data by $value. Note that this is used mainly for following filtering queries and due to firebase
+ /// implementation
+ /// the data may actually not be ordered.
/// </summary>
/// <param name="child"> The child. </param>
- /// <returns> The <see cref="OrderQuery"/>. </returns>
+ /// <returns> The <see cref="OrderQuery" />. </returns>
public static OrderQuery OrderByValue(this ChildQuery child)
{
return child.OrderBy("$value");
}
/// <summary>
- /// Order data by $priority. Note that this is used mainly for following filtering queries and due to firebase implementation
- /// the data may actually not be ordered.
+ /// Order data by $priority. Note that this is used mainly for following filtering queries and due to firebase
+ /// implementation
+ /// the data may actually not be ordered.
/// </summary>
/// <param name="child"> The child. </param>
- /// <returns> The <see cref="OrderQuery"/>. </returns>
+ /// <returns> The <see cref="OrderQuery" />. </returns>
public static OrderQuery OrderByPriority(this ChildQuery child)
{
return child.OrderBy("$priority");
}
/// <summary>
- /// Instructs firebase to send data greater or equal to the <see cref="valueFactory"/>. This must be preceded by an OrderBy query.
+ /// Instructs firebase to send data greater or equal to the <see cref="valueFactory" />. This must be preceded by an
+ /// OrderBy query.
/// </summary>
/// <param name="child"> Current node. </param>
/// <param name="valueFactory"> Value to start at. </param>
- /// <returns> The <see cref="FilterQuery"/>. </returns>
+ /// <returns> The <see cref="FilterQuery" />. </returns>
public static FilterQuery StartAt(this ParameterQuery child, Func<string> valueFactory)
{
return new FilterQuery(child, () => "startAt", valueFactory, child.Client);
}
/// <summary>
- /// Instructs firebase to send data lower or equal to the <see cref="valueFactory"/>. This must be preceded by an OrderBy query.
+ /// Instructs firebase to send data lower or equal to the <see cref="valueFactory" />. This must be preceded by an
+ /// OrderBy query.
/// </summary>
/// <param name="child"> Current node. </param>
/// <param name="valueFactory"> Value to start at. </param>
- /// <returns> The <see cref="FilterQuery"/>. </returns>
+ /// <returns> The <see cref="FilterQuery" />. </returns>
public static FilterQuery EndAt(this ParameterQuery child, Func<string> valueFactory)
{
return new FilterQuery(child, () => "endAt", valueFactory, child.Client);
}
/// <summary>
- /// Instructs firebase to send data equal to the <see cref="valueFactory"/>. This must be preceded by an OrderBy query.
+ /// Instructs firebase to send data equal to the <see cref="valueFactory" />. This must be preceded by an OrderBy
+ /// query.
/// </summary>
/// <param name="child"> Current node. </param>
/// <param name="valueFactory"> Value to start at. </param>
- /// <returns> The <see cref="FilterQuery"/>. </returns>
+ /// <returns> The <see cref="FilterQuery" />. </returns>
public static FilterQuery EqualTo(this ParameterQuery child, Func<string> valueFactory)
{
return new FilterQuery(child, () => "equalTo", valueFactory, child.Client);
}
/// <summary>
- /// Instructs firebase to send data greater or equal to the <see cref="valueFactory"/>. This must be preceded by an OrderBy query.
+ /// Instructs firebase to send data greater or equal to the <see cref="valueFactory" />. This must be preceded by an
+ /// OrderBy query.
/// </summary>
/// <param name="child"> Current node. </param>
/// <param name="valueFactory"> Value to start at. </param>
- /// <returns> The <see cref="FilterQuery"/>. </returns>
+ /// <returns> The <see cref="FilterQuery" />. </returns>
public static FilterQuery StartAt(this ParameterQuery child, Func<double> valueFactory)
{
return new FilterQuery(child, () => "startAt", valueFactory, child.Client);
}
/// <summary>
- /// Instructs firebase to send data lower or equal to the <see cref="valueFactory"/>. This must be preceded by an OrderBy query.
+ /// Instructs firebase to send data lower or equal to the <see cref="valueFactory" />. This must be preceded by an
+ /// OrderBy query.
/// </summary>
/// <param name="child"> Current node. </param>
/// <param name="valueFactory"> Value to start at. </param>
- /// <returns> The <see cref="FilterQuery"/>. </returns>
+ /// <returns> The <see cref="FilterQuery" />. </returns>
public static FilterQuery EndAt(this ParameterQuery child, Func<double> valueFactory)
{
return new FilterQuery(child, () => "endAt", valueFactory, child.Client);
}
/// <summary>
- /// Instructs firebase to send data equal to the <see cref="valueFactory"/>. This must be preceded by an OrderBy query.
+ /// Instructs firebase to send data equal to the <see cref="valueFactory" />. This must be preceded by an OrderBy
+ /// query.
/// </summary>
/// <param name="child"> Current node. </param>
/// <param name="valueFactory"> Value to start at. </param>
- /// <returns> The <see cref="FilterQuery"/>. </returns>
+ /// <returns> The <see cref="FilterQuery" />. </returns>
public static FilterQuery EqualTo(this ParameterQuery child, Func<double> valueFactory)
{
return new FilterQuery(child, () => "equalTo", valueFactory, child.Client);
}
/// <summary>
- /// Instructs firebase to send data equal to the <see cref="valueFactory"/>. This must be preceded by an OrderBy query.
+ /// Instructs firebase to send data equal to the <see cref="valueFactory" />. This must be preceded by an OrderBy
+ /// query.
/// </summary>
/// <param name="child"> Current node. </param>
/// <param name="valueFactory"> Value to start at. </param>
- /// <returns> The <see cref="FilterQuery"/>. </returns>
+ /// <returns> The <see cref="FilterQuery" />. </returns>
public static FilterQuery EqualTo(this ParameterQuery child, Func<bool> valueFactory)
{
return new FilterQuery(child, () => "equalTo", valueFactory, child.Client);
}
/// <summary>
- /// Limits the result to first <see cref="countFactory"/> items.
+ /// Limits the result to first <see cref="countFactory" /> items.
/// </summary>
/// <param name="child"> Current node. </param>
/// <param name="countFactory"> Number of elements. </param>
- /// <returns> The <see cref="FilterQuery"/>. </returns>
+ /// <returns> The <see cref="FilterQuery" />. </returns>
public static FilterQuery LimitToFirst(this ParameterQuery child, Func<int> countFactory)
{
return new FilterQuery(child, () => "limitToFirst", () => countFactory(), child.Client);
}
/// <summary>
- /// Limits the result to last <see cref="countFactory"/> items.
+ /// Limits the result to last <see cref="countFactory" /> items.
/// </summary>
/// <param name="child"> Current node. </param>
/// <param name="countFactory"> Number of elements. </param>
- /// <returns> The <see cref="FilterQuery"/>. </returns>
+ /// <returns> The <see cref="FilterQuery" />. </returns>
public static FilterQuery LimitToLast(this ParameterQuery child, Func<int> countFactory)
{
return new FilterQuery(child, () => "limitToLast", () => countFactory(), child.Client);
diff --git a/FireBase/Query/SilentQuery.cs b/FireBase/Query/SilentQuery.cs
index 1960426..d09d38b 100644
--- a/FireBase/Query/SilentQuery.cs
+++ b/FireBase/Query/SilentQuery.cs
@@ -1,7 +1,7 @@
namespace Firebase.Database.Query
{
/// <summary>
- /// Appends print=silent to the url.
+ /// Appends print=silent to the url.
/// </summary>
public class SilentQuery : ParameterQuery
{
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;
-
/// <summary>
- /// The firebase cache.
+ /// The firebase cache.
/// </summary>
/// <typeparam name="T"> Type of top-level entities in the cache. </typeparam>
public class FirebaseCache<T> : IEnumerable<FirebaseObject<T>>
@@ -17,13 +17,13 @@ namespace Firebase.Database.Streaming
private readonly IDictionary<string, T> dictionary;
private readonly bool isDictionaryType;
- private readonly JsonSerializerSettings serializerSettings = new JsonSerializerSettings()
+ private readonly JsonSerializerSettings serializerSettings = new JsonSerializerSettings
{
ObjectCreationHandling = ObjectCreationHandling.Replace
};
/// <summary>
- /// Initializes a new instance of the <see cref="FirebaseCache{T}"/> class.
+ /// Initializes a new instance of the <see cref="FirebaseCache{T}" /> class.
/// </summary>
public FirebaseCache()
: this(new Dictionary<string, T>())
@@ -31,7 +31,7 @@ namespace Firebase.Database.Streaming
}
/// <summary>
- /// Initializes a new instance of the <see cref="FirebaseCache{T}"/> class and populates it with existing data.
+ /// Initializes a new instance of the <see cref="FirebaseCache{T}" /> class and populates it with existing data.
/// </summary>
/// <param name="existingItems"> The existing items. </param>
public FirebaseCache(IDictionary<string, T> existingItems)
@@ -41,10 +41,10 @@ namespace Firebase.Database.Streaming
}
/// <summary>
- /// The push data.
+ /// The push data.
/// </summary>
- /// <param name="path"> The path of incoming data, separated by slash. </param>
- /// <param name="data"> The data in json format as returned by firebase. </param>
+ /// <param name="path"> The path of incoming data, separated by slash. </param>
+ /// <param name="data"> The data in json format as returned by firebase. </param>
/// <returns> Collection of top-level entities which were affected by the push. </returns>
public IEnumerable<FirebaseObject<T>> 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<JsonPropertyAttribute>()?.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
{
/// <summary>
- /// Firebase event which hold <see cref="EventType"/> and the object affected by the event.
+ /// Firebase event which hold <see cref="EventType" /> and the object affected by the event.
/// </summary>
/// <typeparam name="T"> Type of object affected by the event. </typeparam>
public class FirebaseEvent<T> : FirebaseObject<T>
{
/// <summary>
- /// Initializes a new instance of the <see cref="FirebaseEvent{T}"/> class.
+ /// Initializes a new instance of the <see cref="FirebaseEvent{T}" /> class.
/// </summary>
/// <param name="key"> The key of the object. </param>
/// <param name="obj"> The object. </param>
@@ -20,12 +20,12 @@ namespace Firebase.Database.Streaming
}
/// <summary>
- /// Gets the source of the event.
+ /// Gets the source of the event.
/// </summary>
public FirebaseEventSource EventSource { get; }
/// <summary>
- /// Gets the event type.
+ /// Gets the event type.
/// </summary>
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
{
/// <summary>
- /// Specifies the origin of given <see cref="FirebaseEvent{T}"/>
+ /// Specifies the origin of given <see cref="FirebaseEvent{T}" />
/// </summary>
public enum FirebaseEventSource
{
/// <summary>
- /// Event comes from an offline source.
+ /// Event comes from an offline source.
/// </summary>
Offline,
/// <summary>
- /// 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).
/// </summary>
OnlineInitial,
/// <summary>
- /// Event comes from online source received thru active stream.
+ /// Event comes from online source received thru active stream.
/// </summary>
OnlineStream,
/// <summary>
- /// Event comes from online source being fetched manually.
+ /// Event comes from online source being fetched manually.
/// </summary>
OnlinePull,
/// <summary>
- /// 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).
/// </summary>
OnlinePush,
/// <summary>
- /// Event comes from an online source.
+ /// Event comes from an online source.
/// </summary>
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
{
/// <summary>
- /// The type of event.
+ /// The type of event.
/// </summary>
public enum FirebaseEventType
{
/// <summary>
- /// Item was inserted or updated.
+ /// Item was inserted or updated.
/// </summary>
InsertOrUpdate,
/// <summary>
- /// Item was deleted.
+ /// Item was deleted.
/// </summary>
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;
-
/// <summary>
- /// The firebase subscription.
+ /// The firebase subscription.
/// </summary>
/// <typeparam name="T"> Type of object to be streaming back to the called. </typeparam>
internal class FirebaseSubscription<T> : IDisposable
{
+ private static readonly HttpClient http;
+ private readonly FirebaseCache<T> cache;
private readonly CancellationTokenSource cancel;
+ private readonly FirebaseClient client;
+ private readonly string elementRoot;
private readonly IObserver<FirebaseEvent<T>> observer;
private readonly IFirebaseQuery query;
- private readonly FirebaseCache<T> cache;
- private readonly string elementRoot;
- private readonly FirebaseClient client;
-
- private static HttpClient http;
static FirebaseSubscription()
{
@@ -43,7 +41,7 @@ namespace Firebase.Database.Streaming
}
/// <summary>
- /// Initializes a new instance of the <see cref="FirebaseSubscription{T}"/> class.
+ /// Initializes a new instance of the <see cref="FirebaseSubscription{T}" /> class.
/// </summary>
/// <param name="observer"> The observer. </param>
/// <param name="query"> The query. </param>
@@ -59,13 +57,13 @@ namespace Firebase.Database.Streaming
client = query.Client;
}
- public event EventHandler<ExceptionEventArgs<FirebaseException>> ExceptionThrown;
-
public void Dispose()
{
cancel.Cancel();
}
+ public event EventHandler<ExceptionEventArgs<FirebaseException>> 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
+{
/// <summary>
- /// When a regular <see cref="StreamReader"/> is used in a UWP app its <see cref="StreamReader.ReadLine"/> method tends to take a long
- /// time for data larger then 2 KB. This extremly simple implementation of <see cref="TextReader"/> can be used instead to boost performance
- /// in your UWP app. Use <see cref="FirebaseOptions"/> to inject an instance of this class into your <see cref="FirebaseClient"/>.
+ /// When a regular <see cref="StreamReader" /> is used in a UWP app its <see cref="StreamReader.ReadLine" /> method
+ /// tends to take a long
+ /// time for data larger then 2 KB. This extremly simple implementation of <see cref="TextReader" /> can be used
+ /// instead to boost performance
+ /// in your UWP app. Use <see cref="FirebaseOptions" /> to inject an instance of this class into your
+ /// <see cref="FirebaseClient" />.
/// </summary>
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)
diff --git a/ZooBOTanica/CritCreate.cs b/ZooBOTanica/CritCreate.cs
index c26f323..e79cff4 100644
--- a/ZooBOTanica/CritCreate.cs
+++ b/ZooBOTanica/CritCreate.cs
@@ -1,18 +1,11 @@
using System;
using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
-using System.Drawing;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
using System.Windows.Forms;
+using DSALib;
+using DSALib.Characters;
namespace ZooBOTanica
{
- using DSALib;
- using DSALib.Characters;
-
public partial class CritCreateForm : Form
{
public Critter critter;
diff --git a/ZooBOTanica/Program.cs b/ZooBOTanica/Program.cs
index 0c1123e..59c7434 100644
--- a/ZooBOTanica/Program.cs
+++ b/ZooBOTanica/Program.cs
@@ -1,7 +1,4 @@
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
using System.Windows.Forms;
namespace ZooBOTanica
@@ -9,7 +6,7 @@ namespace ZooBOTanica
internal static class Program
{
/// <summary>
- /// Der Haupteinstiegspunkt für die Anwendung.
+ /// Der Haupteinstiegspunkt für die Anwendung.
/// </summary>
[STAThread]
private static void Main()
diff --git a/ZooBOTanica/Properties/AssemblyInfo.cs b/ZooBOTanica/Properties/AssemblyInfo.cs
index 8bba4bc..b2b516e 100644
--- a/ZooBOTanica/Properties/AssemblyInfo.cs
+++ b/ZooBOTanica/Properties/AssemblyInfo.cs
@@ -1,5 +1,4 @@
using System.Reflection;
-using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Allgemeine Informationen über eine Assembly werden über die folgenden