diff --git a/src/.nuget/NuGet.Config b/src/.nuget/NuGet.Config
index c5c8397..3343d68 100644
--- a/src/.nuget/NuGet.Config
+++ b/src/.nuget/NuGet.Config
@@ -1,7 +1,7 @@
-
-
-
+
+
+
\ No newline at end of file
diff --git a/src/FireSharp.Serialization.JsonNet/FireSharp.Serialization.JsonNet.csproj b/src/FireSharp.Serialization.JsonNet/FireSharp.Serialization.JsonNet.csproj
deleted file mode 100644
index 58ff6e9..0000000
--- a/src/FireSharp.Serialization.JsonNet/FireSharp.Serialization.JsonNet.csproj
+++ /dev/null
@@ -1,67 +0,0 @@
-
-
-
-
- Debug
- AnyCPU
- {A5F20EAF-9E8E-4CED-90F3-F19869570B7C}
- Library
- Properties
- FireSharp.Serialization.JsonNet
- FireSharp.Serialization.JsonNet
- v4.5
- 512
- ..\
- true
-
-
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
-
-
-
- False
- ..\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll
-
-
- ..\packages\RestSharp.104.4.0\lib\net4\RestSharp.dll
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/FireSharp.Serialization.JsonNet/FireSharp.Serialization.JsonNet.nuspec b/src/FireSharp.Serialization.JsonNet/FireSharp.Serialization.JsonNet.nuspec
deleted file mode 100644
index 4b11eaf..0000000
--- a/src/FireSharp.Serialization.JsonNet/FireSharp.Serialization.JsonNet.nuspec
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
- FireSharp.Serialization.JsonNet
- 1.1.0
- Fire# Serialization JsonNet
- ziyasal
- ziyasal
- https://github.com/ziyasal/FireSharp/blob/master/LICENSE.md
- https://github.com/ziyasal/FireSharp
- false
- Provides JSON serialization support using Newtonsoft.JsonNet.
- en-US
- firebase rest api client realtime newtonsoft jsonnet json
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/FireSharp.Serialization.JsonNet/JsonNetSerializer.cs b/src/FireSharp.Serialization.JsonNet/JsonNetSerializer.cs
deleted file mode 100644
index 728a898..0000000
--- a/src/FireSharp.Serialization.JsonNet/JsonNetSerializer.cs
+++ /dev/null
@@ -1,105 +0,0 @@
-#region License
-
-// Copyright 2010 John Sheehan
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#endregion
-
-#region Acknowledgements
-
-// Original JsonNetSerializer contributed by Daniel Crenna (@dimebrain)
-
-#endregion
-
-namespace FireSharp.Serialization.JsonNet
-{
- using System.IO;
- using Newtonsoft.Json;
- using RestSharp.Serializers;
-
- ///
- /// JsonNet JSON serializer for request bodies
- /// Doesn't currently use the SerializeAs attribute, defers to Newtonsoft's attributes
- ///
- public class JsonNetSerializer : ISerializer
- {
- private readonly Newtonsoft.Json.JsonSerializer _serializer;
-
- ///
- /// Default serializer
- ///
- public JsonNetSerializer()
- {
- ContentType = "application/json";
-
- _serializer = new Newtonsoft.Json.JsonSerializer
- {
- MissingMemberHandling = MissingMemberHandling.Ignore,
- NullValueHandling = NullValueHandling.Include,
- DefaultValueHandling = DefaultValueHandling.Include
- };
- }
-
- ///
- /// Default serializer with overload for allowing custom Json.NET settings
- ///
- public JsonNetSerializer(Newtonsoft.Json.JsonSerializer serializer)
- {
- ContentType = "application/json";
- _serializer = serializer;
- }
-
- ///
- /// Serialize the object as JSON
- ///
- /// Object to serialize
- /// JSON as String
- public string Serialize(object obj)
- {
- using (var stringWriter = new StringWriter())
- {
- using (var jsonTextWriter = new JsonTextWriter(stringWriter))
- {
- jsonTextWriter.Formatting = Formatting.Indented;
- jsonTextWriter.QuoteChar = '"';
-
- _serializer.Serialize(jsonTextWriter, obj);
-
- var result = stringWriter.ToString();
- return result;
- }
- }
- }
-
- ///
- /// Unused for JSON Serialization
- ///
- public string DateFormat { get; set; }
-
- ///
- /// Unused for JSON Serialization
- ///
- public string RootElement { get; set; }
-
- ///
- /// Unused for JSON Serialization
- ///
- public string Namespace { get; set; }
-
- ///
- /// Content type for serialized content
- ///
- public string ContentType { get; set; }
- }
-}
\ No newline at end of file
diff --git a/src/FireSharp.Serialization.JsonNet/Properties/AssemblyInfo.cs b/src/FireSharp.Serialization.JsonNet/Properties/AssemblyInfo.cs
deleted file mode 100644
index 767ef2d..0000000
--- a/src/FireSharp.Serialization.JsonNet/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-using System.Reflection;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-
-[assembly: AssemblyTitle("FireSharp.Serialization.JsonNet")]
-[assembly: AssemblyDescription("Provides JSON serialization support using Newtonsoft.JsonNet.")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("FireSharp.Serialization.JsonNet")]
-[assembly: AssemblyCopyright("Copyright © 2013")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-
-[assembly: Guid("2eda7645-3da5-4131-971f-b2861facd164")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
-
-[assembly: AssemblyVersion("1.1.0")]
-[assembly: AssemblyFileVersion("1.1.0")]
\ No newline at end of file
diff --git a/src/FireSharp.Serialization.JsonNet/packages.config b/src/FireSharp.Serialization.JsonNet/packages.config
deleted file mode 100644
index a8f3b82..0000000
--- a/src/FireSharp.Serialization.JsonNet/packages.config
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/FireSharp.Serialization.ServiceStack/FireSharp.Serialization.ServiceStack.csproj b/src/FireSharp.Serialization.ServiceStack/FireSharp.Serialization.ServiceStack.csproj
deleted file mode 100644
index 63976b6..0000000
--- a/src/FireSharp.Serialization.ServiceStack/FireSharp.Serialization.ServiceStack.csproj
+++ /dev/null
@@ -1,68 +0,0 @@
-
-
-
-
- Debug
- AnyCPU
- {7B0E3BC1-4C1D-4748-B678-3197E8E194FC}
- Library
- Properties
- FireSharp.Serialization.ServiceStack
- FireSharp.Serialization.ServiceStack
- v4.5
- 512
- ..\
- true
-
-
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
-
-
-
- ..\packages\RestSharp.104.4.0\lib\net4\RestSharp.dll
- True
-
-
- ..\packages\ServiceStack.Text.4.0.18\lib\net40\ServiceStack.Text.dll
- True
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/FireSharp.Serialization.ServiceStack/FireSharp.Serialization.ServiceStack.nuspec b/src/FireSharp.Serialization.ServiceStack/FireSharp.Serialization.ServiceStack.nuspec
deleted file mode 100644
index 43e3747..0000000
--- a/src/FireSharp.Serialization.ServiceStack/FireSharp.Serialization.ServiceStack.nuspec
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
- FireSharp.Serialization.ServiceStack
- 1.1.0
- Fire# Serialization ServiceStack
- ziyasal
- ziyasal
- https://github.com/ziyasal/FireSharp/blob/master/LICENSE.md
- https://github.com/ziyasal/FireSharp
- false
- Provides JSON serialization support using ServiceStack.Text.
- en-US
- firebase rest api client realtime servicestack json
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/FireSharp.Serialization.ServiceStack/Properties/AssemblyInfo.cs b/src/FireSharp.Serialization.ServiceStack/Properties/AssemblyInfo.cs
deleted file mode 100644
index 94584ed..0000000
--- a/src/FireSharp.Serialization.ServiceStack/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-using System.Reflection;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-
-[assembly: AssemblyTitle("FireSharp.Serialization.ServiceStack")]
-[assembly: AssemblyDescription("Provides JSON serialization support using ServiceStack.Text.")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("FireSharp.Serialization.ServiceStack")]
-[assembly: AssemblyCopyright("Copyright © 2013")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-
-[assembly: Guid("58917e1e-bd52-4983-9569-490eda166ac6")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
-
-[assembly: AssemblyVersion("1.1.0")]
-[assembly: AssemblyFileVersion("1.1.0")]
\ No newline at end of file
diff --git a/src/FireSharp.Serialization.ServiceStack/ServiceStackJsonSerializer.cs b/src/FireSharp.Serialization.ServiceStack/ServiceStackJsonSerializer.cs
deleted file mode 100644
index 9701a94..0000000
--- a/src/FireSharp.Serialization.ServiceStack/ServiceStackJsonSerializer.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-namespace FireSharp.Serialization.ServiceStack
-{
- using RestSharp.Serializers;
-
- ///
- /// ServiceSatck JSON serializer for request bodies
- /// Doesn't currently use the SerializeAs attribute, defers to ServiceStack's attributes that ServiceStack.Text supports DataContract,DataMember attributes
- ///
- public class ServiceStackJsonSerializer : ISerializer
- {
- ///
- /// Default serializer
- ///
- public ServiceStackJsonSerializer()
- {
- ContentType = "application/json";
- }
-
- ///
- /// Serialize the object as JSON
- ///
- /// Object to serialize
- /// JSON as String
- public string Serialize(object obj)
- {
- return global::ServiceStack.Text.JsonSerializer.SerializeToString(obj);
- }
-
- ///
- /// Unused for JSON Serialization
- ///
- public string DateFormat { get; set; }
-
- ///
- /// Unused for JSON Serialization
- ///
- public string RootElement { get; set; }
-
- ///
- /// Unused for JSON Serialization
- ///
- public string Namespace { get; set; }
-
- ///
- /// Content type for serialized content
- ///
- public string ContentType { get; set; }
- }
-}
\ No newline at end of file
diff --git a/src/FireSharp.Serialization.ServiceStack/packages.config b/src/FireSharp.Serialization.ServiceStack/packages.config
deleted file mode 100644
index 970b7de..0000000
--- a/src/FireSharp.Serialization.ServiceStack/packages.config
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/FireSharp.Tests/App.config b/src/FireSharp.Tests/App.config
index 8fcb677..839a7a4 100644
--- a/src/FireSharp.Tests/App.config
+++ b/src/FireSharp.Tests/App.config
@@ -1,15 +1,15 @@
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/FireSharp.Tests/FireSharp.Tests.csproj b/src/FireSharp.Tests/FireSharp.Tests.csproj
index 79a091b..e93dda4 100644
--- a/src/FireSharp.Tests/FireSharp.Tests.csproj
+++ b/src/FireSharp.Tests/FireSharp.Tests.csproj
@@ -43,12 +43,16 @@
False
..\packages\AutoFixture.3.20.0\lib\net40\Ploeh.AutoFixture.dll
-
- ..\packages\RestSharp.104.4.0\lib\net4\RestSharp.dll
- True
-
+
+
+ ..\packages\Microsoft.Net.Http.2.2.28\lib\net45\System.Net.Http.Extensions.dll
+
+
+ ..\packages\Microsoft.Net.Http.2.2.28\lib\net45\System.Net.Http.Primitives.dll
+
+
@@ -57,12 +61,10 @@
-
-
-
+
-
-
+
+
@@ -74,14 +76,6 @@
-
- {A5F20EAF-9E8E-4CED-90F3-F19869570B7C}
- FireSharp.Serialization.JsonNet
-
-
- {7B0E3BC1-4C1D-4748-B678-3197E8E194FC}
- FireSharp.Serialization.ServiceStack
-
{7613B723-E81B-4C02-A3EC-54F8F02C60F6}
FireSharp
@@ -89,6 +83,11 @@
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
-
-
+
+
-
-
-
-
-
+
+
+
+
+
\ No newline at end of file
diff --git a/src/FireSharp.WebApp/Web.Debug.config b/src/FireSharp.WebApp/Web.Debug.config
index 4048ab9..3e2a97c 100644
--- a/src/FireSharp.WebApp/Web.Debug.config
+++ b/src/FireSharp.WebApp/Web.Debug.config
@@ -3,7 +3,7 @@
-
-
-
-
+
\ No newline at end of file
diff --git a/src/FireSharp.WebApp/Web.Release.config b/src/FireSharp.WebApp/Web.Release.config
index 08a3408..9fd481f 100644
--- a/src/FireSharp.WebApp/Web.Release.config
+++ b/src/FireSharp.WebApp/Web.Release.config
@@ -3,7 +3,7 @@
-
-
-
-
-
+
\ No newline at end of file
diff --git a/src/FireSharp.WebApp/Web.config b/src/FireSharp.WebApp/Web.config
index ee551cf..2fe3818 100644
--- a/src/FireSharp.WebApp/Web.config
+++ b/src/FireSharp.WebApp/Web.config
@@ -6,34 +6,34 @@
-->
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/FireSharp.sln b/src/FireSharp.sln
index 30f7de2..15c16aa 100644
--- a/src/FireSharp.sln
+++ b/src/FireSharp.sln
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
-VisualStudioVersion = 12.0.30324.0
+VisualStudioVersion = 12.0.31101.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FireSharp", "FireSharp\FireSharp.csproj", "{7613B723-E81B-4C02-A3EC-54F8F02C60F6}"
EndProject
@@ -16,10 +16,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{83537A
.nuget\NuGet.targets = .nuget\NuGet.targets
EndProjectSection
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FireSharp.Serialization.ServiceStack", "FireSharp.Serialization.ServiceStack\FireSharp.Serialization.ServiceStack.csproj", "{7B0E3BC1-4C1D-4748-B678-3197E8E194FC}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FireSharp.Serialization.JsonNet", "FireSharp.Serialization.JsonNet\FireSharp.Serialization.JsonNet.csproj", "{A5F20EAF-9E8E-4CED-90F3-F19869570B7C}"
-EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -38,14 +34,6 @@ Global
{36E7801E-AF0D-47F7-9C6C-7BE3DBB9DF30}.Debug|Any CPU.Build.0 = Debug|Any CPU
{36E7801E-AF0D-47F7-9C6C-7BE3DBB9DF30}.Release|Any CPU.ActiveCfg = Release|Any CPU
{36E7801E-AF0D-47F7-9C6C-7BE3DBB9DF30}.Release|Any CPU.Build.0 = Release|Any CPU
- {7B0E3BC1-4C1D-4748-B678-3197E8E194FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {7B0E3BC1-4C1D-4748-B678-3197E8E194FC}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {7B0E3BC1-4C1D-4748-B678-3197E8E194FC}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {7B0E3BC1-4C1D-4748-B678-3197E8E194FC}.Release|Any CPU.Build.0 = Release|Any CPU
- {A5F20EAF-9E8E-4CED-90F3-F19869570B7C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {A5F20EAF-9E8E-4CED-90F3-F19869570B7C}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {A5F20EAF-9E8E-4CED-90F3-F19869570B7C}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {A5F20EAF-9E8E-4CED-90F3-F19869570B7C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/src/FireSharp/Config/FirebaseConfig.cs b/src/FireSharp/Config/FirebaseConfig.cs
index a162f97..707d6db 100644
--- a/src/FireSharp/Config/FirebaseConfig.cs
+++ b/src/FireSharp/Config/FirebaseConfig.cs
@@ -1,18 +1,14 @@
namespace FireSharp.Config
{
- using RestSharp.Serializers;
-
public class FirebaseConfig : IFirebaseConfig
{
- private ISerializer _serializer;
+ public FirebaseConfig()
+ {
+ TimeoutInMinute = 1;
+ }
public string BasePath { get; set; }
public string AuthSecret { get; set; }
-
- public ISerializer Serializer
- {
- get { return _serializer ?? (_serializer = new JsonSerializer()); }
- set { _serializer = value ?? new JsonSerializer(); }
- }
+ public int TimeoutInMinute { get; set; }
}
-}
+}
\ No newline at end of file
diff --git a/src/FireSharp/Config/IFirebaseConfig.cs b/src/FireSharp/Config/IFirebaseConfig.cs
index 2cc50a6..6ee9127 100644
--- a/src/FireSharp/Config/IFirebaseConfig.cs
+++ b/src/FireSharp/Config/IFirebaseConfig.cs
@@ -1,11 +1,9 @@
-using RestSharp.Serializers;
-
-namespace FireSharp.Config
+namespace FireSharp.Config
{
public interface IFirebaseConfig
{
string BasePath { get; set; }
string AuthSecret { get; set; }
- ISerializer Serializer { get; set; }
+ int TimeoutInMinute { get; set; }
}
}
\ No newline at end of file
diff --git a/src/FireSharp/EventStreaming/CacheItem.cs b/src/FireSharp/EventStreaming/CacheItem.cs
new file mode 100644
index 0000000..3118aee
--- /dev/null
+++ b/src/FireSharp/EventStreaming/CacheItem.cs
@@ -0,0 +1,18 @@
+using System.Collections.Generic;
+
+namespace FireSharp.EventStreaming
+{
+ internal class CacheItem
+ {
+ private List _children;
+ public string Name { get; set; }
+ public string Value { get; set; }
+ public CacheItem Parent { get; set; }
+ public bool Created { get; set; }
+
+ public List Children
+ {
+ get { return _children ?? (_children = new List()); }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/FireSharp/EventStreaming/Delegates.cs b/src/FireSharp/EventStreaming/Delegates.cs
index c977fb9..7ad4065 100644
--- a/src/FireSharp/EventStreaming/Delegates.cs
+++ b/src/FireSharp/EventStreaming/Delegates.cs
@@ -1,6 +1,8 @@
namespace FireSharp.EventStreaming
{
public delegate void ValueAddedEventHandler(object sender, ValueAddedEventArgs args);
+
public delegate void ValueChangedEventHandler(object sender, ValueChangedEventArgs args);
+
public delegate void ValueRemovedEventHandler(object sender, ValueRemovedEventArgs args);
}
\ No newline at end of file
diff --git a/src/FireSharp/EventStreaming/TemporaryCache.cs b/src/FireSharp/EventStreaming/TemporaryCache.cs
new file mode 100644
index 0000000..880bb90
--- /dev/null
+++ b/src/FireSharp/EventStreaming/TemporaryCache.cs
@@ -0,0 +1,199 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Newtonsoft.Json;
+
+namespace FireSharp.EventStreaming
+{
+ internal sealed class TemporaryCache
+ {
+ private readonly LinkedList _pathFromRootList = new LinkedList();
+ private readonly char[] _seperator = {'/'};
+ private readonly CacheItem _tree = new CacheItem();
+ private readonly object _treeLock = new object();
+
+ public TemporaryCache()
+ {
+ _tree.Name = string.Empty;
+ _tree.Created = false;
+ _tree.Parent = null;
+ _tree.Name = null;
+ }
+
+ internal CacheItem Root
+ {
+ get { return _tree; }
+ }
+
+ public void Replace(string path, JsonReader data)
+ {
+ lock (_treeLock)
+ {
+ var root = FindRoot(path);
+ Replace(root, data);
+ }
+ }
+
+ public void Update(string path, JsonReader data)
+ {
+ lock (_treeLock)
+ {
+ var root = FindRoot(path);
+ UpdateChildren(root, data);
+ }
+ }
+
+ private CacheItem FindRoot(string path)
+ {
+ var segments = path.Split(_seperator, StringSplitOptions.RemoveEmptyEntries);
+
+ return segments.Aggregate(_tree, GetNamedChild);
+ }
+
+ private static CacheItem GetNamedChild(CacheItem root, string segment)
+ {
+ var newRoot = root.Children.FirstOrDefault(c => c.Name == segment);
+
+ if (newRoot == null)
+ {
+ newRoot = new CacheItem {Name = segment, Parent = root, Created = true};
+ root.Children.Add(newRoot);
+ }
+
+ return newRoot;
+ }
+
+ private void Replace(CacheItem root, JsonReader reader)
+ {
+ UpdateChildren(root, reader, true);
+ }
+
+ private void UpdateChildren(CacheItem root, JsonReader reader, bool replace = false)
+ {
+ if (replace)
+ {
+ DeleteChild(root);
+
+ if (root.Parent != null)
+ {
+ root.Parent.Children.Add(root);
+ }
+ }
+
+ while (reader.Read())
+ {
+ switch (reader.TokenType)
+ {
+ case JsonToken.PropertyName:
+ UpdateChildren(GetNamedChild(root, reader.Value.ToString()), reader);
+ break;
+ case JsonToken.Boolean:
+ case JsonToken.Bytes:
+ case JsonToken.Date:
+ case JsonToken.Float:
+ case JsonToken.Integer:
+ case JsonToken.String:
+ if (root.Created)
+ {
+ root.Value = reader.Value.ToString();
+ OnAdded(new ValueAddedEventArgs(PathFromRoot(root), reader.Value.ToString()));
+ root.Created = false;
+ }
+ else
+ {
+ var oldData = root.Value;
+ root.Value = reader.Value.ToString();
+ OnUpdated(new ValueChangedEventArgs(PathFromRoot(root), root.Value, oldData));
+ }
+
+ return;
+ case JsonToken.Null:
+ DeleteChild(root);
+ return;
+ }
+ }
+ }
+
+ private void DeleteChild(CacheItem root)
+ {
+ if (root.Parent != null)
+ {
+ if (RemoveChildFromParent(root))
+ {
+ OnRemoved(new ValueRemovedEventArgs(PathFromRoot(root)));
+ }
+ }
+ else
+ {
+ foreach (var child in root.Children.ToArray())
+ {
+ RemoveChildFromParent(child);
+ OnRemoved(new ValueRemovedEventArgs(PathFromRoot(child)));
+ }
+ }
+ }
+
+ private bool RemoveChildFromParent(CacheItem child)
+ {
+ if (child.Parent != null)
+ {
+ return child.Parent.Children.Remove(child);
+ }
+
+ return false;
+ }
+
+ private string PathFromRoot(CacheItem root)
+ {
+ var size = 1;
+
+ while (root.Name != null)
+ {
+ size += root.Name.Length + 1;
+ _pathFromRootList.AddFirst(root);
+ root = root.Parent;
+ }
+
+ if (_pathFromRootList.Count == 0)
+ {
+ return "/";
+ }
+
+ var sb = new StringBuilder(size);
+ foreach (var d in _pathFromRootList)
+ {
+ sb.AppendFormat("/{0}", d.Name);
+ }
+
+ _pathFromRootList.Clear();
+
+ return sb.ToString();
+ }
+
+ private void OnAdded(ValueAddedEventArgs args)
+ {
+ var added = Added;
+ if (added == null) return;
+ added(this, args);
+ }
+
+ private void OnUpdated(ValueChangedEventArgs args)
+ {
+ var updated = Changed;
+ if (updated == null) return;
+ updated(this, args);
+ }
+
+ private void OnRemoved(ValueRemovedEventArgs args)
+ {
+ var removed = Removed;
+ if (removed == null) return;
+ removed(this, args);
+ }
+
+ public event ValueAddedEventHandler Added;
+ public event ValueChangedEventHandler Changed;
+ public event ValueRemovedEventHandler Removed;
+ }
+}
\ No newline at end of file
diff --git a/src/FireSharp/EventStreaming/ValueAddedEventArgs.cs b/src/FireSharp/EventStreaming/ValueAddedEventArgs.cs
index 79d98f0..53f9da3 100644
--- a/src/FireSharp/EventStreaming/ValueAddedEventArgs.cs
+++ b/src/FireSharp/EventStreaming/ValueAddedEventArgs.cs
@@ -1,6 +1,7 @@
+using System;
+
namespace FireSharp.EventStreaming
{
- using System;
public class ValueAddedEventArgs : EventArgs
{
public ValueAddedEventArgs(string path, string data)
diff --git a/src/FireSharp/EventStreaming/ValueChangedEventArgs.cs b/src/FireSharp/EventStreaming/ValueChangedEventArgs.cs
index c38da92..14016c4 100644
--- a/src/FireSharp/EventStreaming/ValueChangedEventArgs.cs
+++ b/src/FireSharp/EventStreaming/ValueChangedEventArgs.cs
@@ -1,6 +1,7 @@
+using System;
+
namespace FireSharp.EventStreaming
{
- using System;
public class ValueChangedEventArgs : EventArgs
{
public ValueChangedEventArgs(string path, string data, string oldData)
@@ -12,7 +13,6 @@ public ValueChangedEventArgs(string path, string data, string oldData)
public string Path { get; private set; }
public string Data { get; private set; }
-
public string OldData { get; private set; }
}
}
\ No newline at end of file
diff --git a/src/FireSharp/EventStreaming/ValueRemovedEventArgs.cs b/src/FireSharp/EventStreaming/ValueRemovedEventArgs.cs
index 29a3aea..ae132fa 100644
--- a/src/FireSharp/EventStreaming/ValueRemovedEventArgs.cs
+++ b/src/FireSharp/EventStreaming/ValueRemovedEventArgs.cs
@@ -1,6 +1,7 @@
+using System;
+
namespace FireSharp.EventStreaming
{
- using System;
public class ValueRemovedEventArgs : EventArgs
{
public ValueRemovedEventArgs(string path)
diff --git a/src/FireSharp/Exceptions/FirebaseException.cs b/src/FireSharp/Exceptions/FirebaseException.cs
index 2d7c7f7..e29552d 100644
--- a/src/FireSharp/Exceptions/FirebaseException.cs
+++ b/src/FireSharp/Exceptions/FirebaseException.cs
@@ -1,7 +1,7 @@
-namespace FireSharp.Exceptions
-{
- using System;
+using System;
+namespace FireSharp.Exceptions
+{
public class FirebaseException : Exception
{
public FirebaseException(string message)
diff --git a/src/FireSharp/Extensions/ObjectExtensions.cs b/src/FireSharp/Extensions/ObjectExtensions.cs
index 2d53e5e..0429fa3 100644
--- a/src/FireSharp/Extensions/ObjectExtensions.cs
+++ b/src/FireSharp/Extensions/ObjectExtensions.cs
@@ -1,22 +1,19 @@
-using RestSharp;
-using RestSharp.Deserializers;
+using System.Net.Http;
+using Newtonsoft.Json;
namespace FireSharp.Extensions
{
- using RestSharp.Serializers;
-
public static class ObjectExtensions
{
public static string ToJson(this object @object)
{
- JsonSerializer serializer = new JsonSerializer();
- return serializer.Serialize(@object);
+ return JsonConvert.SerializeObject(@object);
}
- public static T ReadAs(this IRestResponse response)
+ public static T ReadAs(this HttpResponseMessage response)
{
- JsonDeserializer serializer = new JsonDeserializer();
- return serializer.Deserialize(response);
+ var task = response.Content.ReadAsStringAsync();
+ return JsonConvert.DeserializeObject(task.Result);
}
}
}
\ No newline at end of file
diff --git a/src/FireSharp/FireSharp.csproj b/src/FireSharp/FireSharp.csproj
index 4ead0c4..c9e584c 100644
--- a/src/FireSharp/FireSharp.csproj
+++ b/src/FireSharp/FireSharp.csproj
@@ -32,11 +32,20 @@
4
-
- ..\packages\RestSharp.104.4.0\lib\net4\RestSharp.dll
+
+ ..\packages\Newtonsoft.Json.6.0.7\lib\net45\Newtonsoft.Json.dll
+ True
+
+
+ ..\packages\Microsoft.Net.Http.2.2.28\lib\net45\System.Net.Http.Extensions.dll
+
+
+ ..\packages\Microsoft.Net.Http.2.2.28\lib\net45\System.Net.Http.Primitives.dll
+
+
@@ -46,7 +55,9 @@
+
+
@@ -71,6 +82,11 @@
+
+
+
+
+