diff --git a/.gitignore b/.gitignore index d0126a1..72f2b33 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,8 @@ TestResults *.user *.sln.docstates +#C9 Folder +.c9/ # Build results [Dd]ebug/ [Rr]elease/ @@ -98,4 +100,5 @@ Generated_Code #added for RIA/Silverlight projects # Visual Studio version. Backup files are not needed, because we have git ;-) _UpgradeReport_Files/ Backup*/ -UpgradeLog*.XML \ No newline at end of file +UpgradeLog*.XML +*.nupkg diff --git a/.nuget/NuGet.Config b/.nuget/NuGet.Config index c5c8397..3343d68 100644 --- a/.nuget/NuGet.Config +++ b/.nuget/NuGet.Config @@ -1,7 +1,7 @@  - - - + + + \ No newline at end of file diff --git a/.nuget/NuGet.targets b/.nuget/NuGet.targets index 83fe906..3f8c37b 100644 --- a/.nuget/NuGet.targets +++ b/.nuget/NuGet.targets @@ -2,7 +2,7 @@ $(MSBuildProjectDirectory)\..\ - + false @@ -11,11 +11,11 @@ true - + false - + @@ -28,28 +28,36 @@ $([System.IO.Path]::Combine($(SolutionDir), ".nuget")) - $([System.IO.Path]::Combine($(ProjectDir), "packages.config")) - + $(SolutionDir).nuget - packages.config + + + + $(MSBuildProjectDirectory)\packages.$(MSBuildProjectName.Replace(' ', '_')).config + $(MSBuildProjectDirectory)\packages.$(MSBuildProjectName).config + + + + $(MSBuildProjectDirectory)\packages.config + $(PackagesProjectConfig) $(NuGetToolsPath)\NuGet.exe @(PackageSource) - + "$(NuGetExePath)" - mono --runtime=v4.0.30319 $(NuGetExePath) + mono --runtime=v4.0.30319 "$(NuGetExePath)" $(TargetDir.Trim('\\')) - + -RequireConsent -NonInteractive - + "$(SolutionDir) " "$(SolutionDir)" @@ -85,24 +93,24 @@ - + - + - - + - + @@ -133,4 +141,4 @@ - \ No newline at end of file + diff --git a/.nuget/packages.config b/.nuget/packages.config new file mode 100644 index 0000000..a7df95c --- /dev/null +++ b/.nuget/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/FireSharp.Serialization.JsonNet/FireSharp.Serialization.JsonNet.csproj b/FireSharp.Serialization.JsonNet/FireSharp.Serialization.JsonNet.csproj deleted file mode 100644 index 58ff6e9..0000000 --- a/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/FireSharp.Serialization.JsonNet/FireSharp.Serialization.JsonNet.nuspec b/FireSharp.Serialization.JsonNet/FireSharp.Serialization.JsonNet.nuspec deleted file mode 100644 index 4b11eaf..0000000 --- a/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/FireSharp.Serialization.JsonNet/JsonNetSerializer.cs b/FireSharp.Serialization.JsonNet/JsonNetSerializer.cs deleted file mode 100644 index 728a898..0000000 --- a/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/FireSharp.Serialization.JsonNet/packages.config b/FireSharp.Serialization.JsonNet/packages.config deleted file mode 100644 index a8f3b82..0000000 --- a/FireSharp.Serialization.JsonNet/packages.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/FireSharp.Serialization.ServiceStack/FireSharp.Serialization.ServiceStack.csproj b/FireSharp.Serialization.ServiceStack/FireSharp.Serialization.ServiceStack.csproj deleted file mode 100644 index 63976b6..0000000 --- a/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/FireSharp.Serialization.ServiceStack/FireSharp.Serialization.ServiceStack.nuspec b/FireSharp.Serialization.ServiceStack/FireSharp.Serialization.ServiceStack.nuspec deleted file mode 100644 index 43e3747..0000000 --- a/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/FireSharp.Serialization.ServiceStack/Properties/AssemblyInfo.cs b/FireSharp.Serialization.ServiceStack/Properties/AssemblyInfo.cs deleted file mode 100644 index 94584ed..0000000 --- a/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/FireSharp.Serialization.ServiceStack/ServiceStackJsonSerializer.cs b/FireSharp.Serialization.ServiceStack/ServiceStackJsonSerializer.cs deleted file mode 100644 index 9701a94..0000000 --- a/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/FireSharp.Serialization.ServiceStack/packages.config b/FireSharp.Serialization.ServiceStack/packages.config deleted file mode 100644 index 970b7de..0000000 --- a/FireSharp.Serialization.ServiceStack/packages.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/FireSharp.Test.Console/App.config b/FireSharp.Test.Console/App.config new file mode 100644 index 0000000..c774a25 --- /dev/null +++ b/FireSharp.Test.Console/App.config @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/FireSharp.Test.Console/FireSharp.Test.Console.csproj b/FireSharp.Test.Console/FireSharp.Test.Console.csproj new file mode 100644 index 0000000..6a4216d --- /dev/null +++ b/FireSharp.Test.Console/FireSharp.Test.Console.csproj @@ -0,0 +1,88 @@ + + + + + Debug + AnyCPU + {0DF0042E-769D-409B-A9F7-19449FD0AFD0} + Exe + Properties + FireSharp.Test.Console + FireSharp.Test.Console + v4.5.1 + 512 + true + ..\ + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + ..\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 + + + + + + + + + + + + + + + + + + + {67b7ea6f-dc34-4f48-8331-58df137d78c9} + FireSharp + + + + + + + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + + + + \ No newline at end of file diff --git a/FireSharp.Test.Console/Program.cs b/FireSharp.Test.Console/Program.cs new file mode 100644 index 0000000..0148a37 --- /dev/null +++ b/FireSharp.Test.Console/Program.cs @@ -0,0 +1,38 @@ +using FireSharp.Config; + +namespace FireSharp.Test.Console +{ + public class Program + { + protected const string BASE_PATH = "https://firesharp.firebaseio.com/"; + protected const string FIREBASE_SECRET = "fubr9j2Kany9KU3SHCIHBLm142anWCzvlBs1D977"; + private static FirebaseClient _client; + + private static void Main() + { + IFirebaseConfig config = new FirebaseConfig + { + AuthSecret = FIREBASE_SECRET, + BasePath = BASE_PATH + }; + + _client = new FirebaseClient(config); //Uses JsonNet default + + EventStreaming(); + Crud(); + + System.Console.Read(); + } + + private static async void Crud() + { + var setResponse = await _client.SetAsync("todos", new {name = "SET CALL"}); + System.Console.WriteLine(setResponse.Body); + } + + private static async void EventStreaming() + { + await _client.ListenAsync("chat", (sender, args) => { System.Console.WriteLine(args.Data); }); + } + } +} \ No newline at end of file diff --git a/FireSharp.Serialization.JsonNet/Properties/AssemblyInfo.cs b/FireSharp.Test.Console/Properties/AssemblyInfo.cs similarity index 72% rename from FireSharp.Serialization.JsonNet/Properties/AssemblyInfo.cs rename to FireSharp.Test.Console/Properties/AssemblyInfo.cs index 767ef2d..11e29d8 100644 --- a/FireSharp.Serialization.JsonNet/Properties/AssemblyInfo.cs +++ b/FireSharp.Test.Console/Properties/AssemblyInfo.cs @@ -5,12 +5,12 @@ // 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: AssemblyTitle("FireSharp.Test.Console")] +[assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("FireSharp.Serialization.JsonNet")] -[assembly: AssemblyCopyright("Copyright © 2013")] +[assembly: AssemblyProduct("FireSharp.Test.Console")] +[assembly: AssemblyCopyright("Copyright © 2014")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -22,7 +22,7 @@ // The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("2eda7645-3da5-4131-971f-b2861facd164")] +[assembly: Guid("36e73638-c60a-48e8-a807-e705468013a1")] // Version information for an assembly consists of the following four values: // @@ -35,5 +35,5 @@ // 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 +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] \ No newline at end of file diff --git a/FireSharp.Test.Console/packages.config b/FireSharp.Test.Console/packages.config new file mode 100644 index 0000000..85a748e --- /dev/null +++ b/FireSharp.Test.Console/packages.config @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/FireSharp.Tests/App.config b/FireSharp.Tests/App.config index f9f34d7..6b16337 100644 --- a/FireSharp.Tests/App.config +++ b/FireSharp.Tests/App.config @@ -4,18 +4,20 @@
- - - - - - - - - - - + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/FireSharp.Tests/FireSharp.Tests.csproj b/FireSharp.Tests/FireSharp.Tests.csproj index 1eb8664..99e4c39 100644 --- a/FireSharp.Tests/FireSharp.Tests.csproj +++ b/FireSharp.Tests/FireSharp.Tests.csproj @@ -13,6 +13,7 @@ 512 ..\ true + 2c2e6014 true @@ -32,23 +33,46 @@ 4 - + False - ..\packages\Moq.4.2.1408.0717\lib\net40\Moq.dll + ..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll - - ..\packages\NUnit.2.6.3\lib\nunit.framework.dll + + False + ..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll + + + ..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll + + + False + ..\packages\Moq.4.2.1409.1722\lib\net40\Moq.dll - + False - ..\packages\AutoFixture.3.20.0\lib\net40\Ploeh.AutoFixture.dll + ..\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll - - ..\packages\RestSharp.104.4.0\lib\net4\RestSharp.dll - True + + False + ..\packages\NUnit.2.6.4\lib\nunit.framework.dll + + + False + ..\packages\AutoFixture.3.22.0\lib\net40\Ploeh.AutoFixture.dll + + + + False + ..\packages\Microsoft.Net.Http.2.2.28\lib\net45\System.Net.Http.Extensions.dll + + + False + ..\packages\Microsoft.Net.Http.2.2.28\lib\net45\System.Net.Http.Primitives.dll + + @@ -57,13 +81,8 @@ - - - + - - - @@ -75,21 +94,18 @@ - - {A5F20EAF-9E8E-4CED-90F3-F19869570B7C} - FireSharp.Serialization.JsonNet - - - {7B0E3BC1-4C1D-4748-B678-3197E8E194FC} - FireSharp.Serialization.ServiceStack - - {7613B723-E81B-4C02-A3EC-54F8F02C60F6} + {67b7ea6f-dc34-4f48-8331-58df137d78c9} FireSharp + + + + + - - - - - - + + + + + + - - + + - - - - - + + + + + \ No newline at end of file diff --git a/FireSharp.WebApp/Web.Debug.config b/FireSharp.WebApp/Web.Debug.config index 4048ab9..3e2a97c 100644 --- a/FireSharp.WebApp/Web.Debug.config +++ b/FireSharp.WebApp/Web.Debug.config @@ -3,7 +3,7 @@ - - - - + \ No newline at end of file diff --git a/FireSharp.WebApp/Web.Release.config b/FireSharp.WebApp/Web.Release.config index 08a3408..9fd481f 100644 --- a/FireSharp.WebApp/Web.Release.config +++ b/FireSharp.WebApp/Web.Release.config @@ -3,7 +3,7 @@ - - - - - + \ No newline at end of file diff --git a/FireSharp.WebApp/Web.config b/FireSharp.WebApp/Web.config index 4cbdcaf..ee551cf 100644 --- a/FireSharp.WebApp/Web.config +++ b/FireSharp.WebApp/Web.config @@ -6,12 +6,6 @@ --> - -
- - - - diff --git a/FireSharp.sln b/FireSharp.sln index 30f7de2..e63b412 100644 --- a/FireSharp.sln +++ b/FireSharp.sln @@ -1,10 +1,8 @@  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 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FireSharp.Tests", "FireSharp.Tests\FireSharp.Tests.csproj", "{F7C691EB-249D-48D7-BE52-DF33C55B1F96}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FireSharp.WebApp", "FireSharp.WebApp\FireSharp.WebApp.csproj", "{36E7801E-AF0D-47F7-9C6C-7BE3DBB9DF30}" @@ -16,9 +14,9 @@ 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}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FireSharp", "FireSharp\FireSharp.csproj", "{67B7EA6F-DC34-4F48-8331-58DF137D78C9}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FireSharp.Serialization.JsonNet", "FireSharp.Serialization.JsonNet\FireSharp.Serialization.JsonNet.csproj", "{A5F20EAF-9E8E-4CED-90F3-F19869570B7C}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FireSharp.Test.Console", "FireSharp.Test.Console\FireSharp.Test.Console.csproj", "{0DF0042E-769D-409B-A9F7-19449FD0AFD0}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -26,10 +24,6 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {7613B723-E81B-4C02-A3EC-54F8F02C60F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7613B723-E81B-4C02-A3EC-54F8F02C60F6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7613B723-E81B-4C02-A3EC-54F8F02C60F6}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7613B723-E81B-4C02-A3EC-54F8F02C60F6}.Release|Any CPU.Build.0 = Release|Any CPU {F7C691EB-249D-48D7-BE52-DF33C55B1F96}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {F7C691EB-249D-48D7-BE52-DF33C55B1F96}.Debug|Any CPU.Build.0 = Debug|Any CPU {F7C691EB-249D-48D7-BE52-DF33C55B1F96}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -38,14 +32,14 @@ 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 + {67B7EA6F-DC34-4F48-8331-58DF137D78C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {67B7EA6F-DC34-4F48-8331-58DF137D78C9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {67B7EA6F-DC34-4F48-8331-58DF137D78C9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {67B7EA6F-DC34-4F48-8331-58DF137D78C9}.Release|Any CPU.Build.0 = Release|Any CPU + {0DF0042E-769D-409B-A9F7-19449FD0AFD0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0DF0042E-769D-409B-A9F7-19449FD0AFD0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0DF0042E-769D-409B-A9F7-19449FD0AFD0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0DF0042E-769D-409B-A9F7-19449FD0AFD0}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/FireSharp/Config/ConfigSection/FirebaseConfigurationSection.cs b/FireSharp/Config/ConfigSection/FirebaseConfigurationSection.cs deleted file mode 100644 index dec5828..0000000 --- a/FireSharp/Config/ConfigSection/FirebaseConfigurationSection.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Configuration; - -namespace FireSharp.Config.ConfigSection -{ - public class FirebaseConfigurationSection : ConfigurationSection - { - /// - /// The name of this section in the app.config. - /// - public const string SectionName = "firebase"; - - private const string ConnectionPropertyName = "connectionFactory"; - - [ConfigurationProperty(ConnectionPropertyName)] - public FirebaseConnectionElement FirebaseConnectionElement { get { return (FirebaseConnectionElement)base[ConnectionPropertyName]; } } - - public FirebaseConnectionElement FirebaseTokenElement { get { return (FirebaseConnectionElement)base[ConnectionPropertyName]; } } - } -} diff --git a/FireSharp/Config/ConfigSection/FirebaseConnectionElement.cs b/FireSharp/Config/ConfigSection/FirebaseConnectionElement.cs deleted file mode 100644 index cd22581..0000000 --- a/FireSharp/Config/ConfigSection/FirebaseConnectionElement.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System.Configuration; - -namespace FireSharp.Config.ConfigSection -{ - public class FirebaseConnectionElement : ConfigurationElement - { - private const string BasePathPropertyName = "basePath"; - private const string AuthSecretPropertyName = "authSecret"; - - [ConfigurationProperty(BasePathPropertyName, IsRequired = true)] - public string BasePath - { - get { return (string)this[BasePathPropertyName]; } - set { this[BasePathPropertyName] = value; } - } - - [ConfigurationProperty(AuthSecretPropertyName, IsRequired = false)] - public string AuthSecret - { - get { return (string)this[AuthSecretPropertyName]; } - set { this[AuthSecretPropertyName] = value; } - } - - } -} \ No newline at end of file diff --git a/FireSharp/Config/ConfigSection/FirebaseTokenElement.cs b/FireSharp/Config/ConfigSection/FirebaseTokenElement.cs deleted file mode 100644 index 8d66e8c..0000000 --- a/FireSharp/Config/ConfigSection/FirebaseTokenElement.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.Configuration; - -namespace FireSharp.Config.ConfigSection -{ - public class FirebaseTokenElement : ConfigurationElement - { - private const string TokenPropertyName = "token"; - - [ConfigurationProperty(TokenPropertyName, IsRequired = true)] - public string Token - { - get { return (string)this[TokenPropertyName]; } - set { this[TokenPropertyName] = value; } - } - - } -} \ No newline at end of file diff --git a/FireSharp/Config/FirebaseConfig.cs b/FireSharp/Config/FirebaseConfig.cs index 48e32bd..08fcdc5 100644 --- a/FireSharp/Config/FirebaseConfig.cs +++ b/FireSharp/Config/FirebaseConfig.cs @@ -1,47 +1,14 @@ -using System.Configuration; -using FireSharp.Config.ConfigSection; -using FireSharp.Exceptions; - -namespace FireSharp.Config +namespace FireSharp.Config { - using RestSharp.Serializers; - public class FirebaseConfig : IFirebaseConfig { public FirebaseConfig() { - TryGetConfigurationFromAppConfig(); - } - - private void TryGetConfigurationFromAppConfig() - { - var connectionSection = ConfigurationManager.GetSection(FirebaseConfigurationSection.SectionName) as FirebaseConfigurationSection; - if (connectionSection == null || connectionSection.FirebaseConnectionElement == null) return; - - this.AuthSecret = connectionSection.FirebaseConnectionElement.AuthSecret; - - this.SetBasePath(connectionSection); - + TimeoutInMinute = 1; } - private void SetBasePath(FirebaseConfigurationSection connectionSection) - { - var path = connectionSection.FirebaseConnectionElement.BasePath; - if (path.Equals("**your firebase path**")) - throw new FirebaseException("Change your basepath in web.config"); - - this.BasePath = connectionSection.FirebaseConnectionElement.BasePath; - } - - private ISerializer _serializer; - 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; } } } diff --git a/FireSharp/Config/IFirebaseConfig.cs b/FireSharp/Config/IFirebaseConfig.cs index 2cc50a6..6ee9127 100644 --- a/FireSharp/Config/IFirebaseConfig.cs +++ b/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/FireSharp/EventStreaming/Delegates.cs b/FireSharp/EventStreaming/Delegates.cs index c977fb9..7ad4065 100644 --- a/FireSharp/EventStreaming/Delegates.cs +++ b/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/FireSharp/EventStreaming/SimpleCacheItem.cs b/FireSharp/EventStreaming/SimpleCacheItem.cs new file mode 100644 index 0000000..27d1894 --- /dev/null +++ b/FireSharp/EventStreaming/SimpleCacheItem.cs @@ -0,0 +1,18 @@ +using System.Collections.Generic; + +namespace FireSharp.EventStreaming +{ + internal class SimpleCacheItem + { + private List _children; + public string Name { get; set; } + public string Value { get; set; } + public SimpleCacheItem 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/FireSharp/EventStreaming/TemporaryCache.cs b/FireSharp/EventStreaming/TemporaryCache.cs new file mode 100644 index 0000000..a6979fa --- /dev/null +++ b/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 SimpleCacheItem _tree = new SimpleCacheItem(); + private readonly object _treeLock = new object(); + + public TemporaryCache() + { + _tree.Name = string.Empty; + _tree.Created = false; + _tree.Parent = null; + _tree.Name = null; + } + + internal SimpleCacheItem 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 SimpleCacheItem FindRoot(string path) + { + var segments = path.Split(_seperator, StringSplitOptions.RemoveEmptyEntries); + + return segments.Aggregate(_tree, GetNamedChild); + } + + private static SimpleCacheItem GetNamedChild(SimpleCacheItem root, string segment) + { + var newRoot = root.Children.FirstOrDefault(c => c.Name == segment); + + if (newRoot == null) + { + newRoot = new SimpleCacheItem {Name = segment, Parent = root, Created = true}; + root.Children.Add(newRoot); + } + + return newRoot; + } + + private void Replace(SimpleCacheItem root, JsonReader reader) + { + UpdateChildren(root, reader, true); + } + + private void UpdateChildren(SimpleCacheItem 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(SimpleCacheItem 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(SimpleCacheItem child) + { + if (child.Parent != null) + { + return child.Parent.Children.Remove(child); + } + + return false; + } + + private string PathFromRoot(SimpleCacheItem 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/FireSharp/EventStreaming/ValueAddedEventArgs.cs b/FireSharp/EventStreaming/ValueAddedEventArgs.cs index 79d98f0..53f9da3 100644 --- a/FireSharp/EventStreaming/ValueAddedEventArgs.cs +++ b/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/FireSharp/EventStreaming/ValueChangedEventArgs.cs b/FireSharp/EventStreaming/ValueChangedEventArgs.cs index c38da92..14016c4 100644 --- a/FireSharp/EventStreaming/ValueChangedEventArgs.cs +++ b/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/FireSharp/EventStreaming/ValueRemovedEventArgs.cs b/FireSharp/EventStreaming/ValueRemovedEventArgs.cs index 29a3aea..ae132fa 100644 --- a/FireSharp/EventStreaming/ValueRemovedEventArgs.cs +++ b/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/FireSharp/Exceptions/FirebaseException.cs b/FireSharp/Exceptions/FirebaseException.cs index 2d7c7f7..e29552d 100644 --- a/FireSharp/Exceptions/FirebaseException.cs +++ b/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/FireSharp/Extensions/ObjectExtensions.cs b/FireSharp/Extensions/ObjectExtensions.cs index 2d53e5e..0429fa3 100644 --- a/FireSharp/Extensions/ObjectExtensions.cs +++ b/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/FireSharp/FireSharp.csproj b/FireSharp/FireSharp.csproj index e486dc2..8a6c9eb 100644 --- a/FireSharp/FireSharp.csproj +++ b/FireSharp/FireSharp.csproj @@ -1,16 +1,20 @@  - + + 10.0 Debug AnyCPU - {7613B723-E81B-4C02-A3EC-54F8F02C60F6} + {67B7EA6F-DC34-4F48-8331-58DF137D78C9} Library Properties FireSharp FireSharp - v4.5 + en-US 512 + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Profile344 + v4.0 ..\ true @@ -32,50 +36,82 @@ 4 - - ..\packages\RestSharp.104.4.0\lib\net4\RestSharp.dll - + + - - - + + + - - - + + - + - + - + + + ..\packages\Microsoft.Bcl.Async.1.0.168\lib\portable-net40+sl4+win8+wp71+wpa81\Microsoft.Threading.Tasks.dll + + + ..\packages\Microsoft.Bcl.Async.1.0.168\lib\portable-net40+sl4+win8+wp71+wpa81\Microsoft.Threading.Tasks.Extensions.dll + + + ..\packages\Newtonsoft.Json.6.0.4\lib\portable-net40+sl5+wp80+win8+wpa81\Newtonsoft.Json.dll + + + ..\packages\Microsoft.Bcl.1.1.9\lib\portable-net40+sl5+win8+wp8+wpa81\System.IO.dll + + + ..\packages\Microsoft.Net.Http.2.2.28\lib\portable-net40+sl4+win8+wp71+wpa81\System.Net.Http.dll + + + ..\packages\Microsoft.Net.Http.2.2.28\lib\portable-net40+sl4+win8+wp71+wpa81\System.Net.Http.Extensions.dll + + + ..\packages\Microsoft.Net.Http.2.2.28\lib\portable-net40+sl4+win8+wp71+wpa81\System.Net.Http.Primitives.dll + + + ..\packages\Microsoft.Bcl.1.1.9\lib\portable-net40+sl5+win8+wp8+wpa81\System.Runtime.dll + + + ..\packages\Microsoft.Bcl.1.1.9\lib\portable-net40+sl5+win8+wp8+wpa81\System.Threading.Tasks.dll + - - - - - + + + + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + +