|
SushiHangover.RealmJson.Extensions
Extension Methods for adding JSON APIs to a Realm Instance.
|
Extension Methods for adding JSON APIs to a Realm Instance
PM> Install-Package RealmJson.Extensions Ref: https://www.nuget.org/packages/RealmJson.Extensions
Post on StackOverflow with the tags: **[XAMARIN]** **[REALM]** **[JSON]**
https://sushihangover.github.io/Realm.Json.Extensions/
using (var theRealm = Realm.GetInstance(RealmDBTempPath()))
{
var realmObject = theRealm.CreateObjectFromJson<StateUnique>(jsonString);
}
using (var stream = new MemoryStream(byteArray))
using (var theRealm = Realm.GetInstance(RealmDBTempPath()))
{
var testObject = theRealm.CreateObjectFromJson<StateUnique>(stream);
}
using (var theRealm = Realm.GetInstance(RealmDBTempPath()))
using (var assetStream = Application.Context.Assets.Open("States.json"))
{
theRealm.CreateAllFromJson<State>(assetStream);
}
using (var theRealm = Realm.GetInstance(RealmDBTempPath()))
using (var fileStream = new FileStream("./Data/States.json", FileMode.Open, FileAccess.Read))
{
theRealm.CreateAllFromJson<State>(fileStream);
}
Note: Consult the Unit Tests for more usage details
Xamarin.Forms UsageAutoMapper does not support PCL Profile 259(2)) and thus adding this Nuget package will fail if applied to a default Xamarin.Form project.
You can change your Xamarin.From project to Profile 111, then retarget the Xamarin.Forms package, and you will be able to add the Nuget package.
See the Xamarin.Forms-based (Nuget.Test) project in the code repo as an example.
Note: Once Xamarin has full support for .NET Standard and AutoMapper releases v5.2 (3), this mess should go away.
(2) https://github.com/AutoMapper/AutoMapper/issues/1531
(3) https://github.com/AutoMapper/AutoMapper/issues/1532
API Reference documention is built via the great
xbuild or msbuild based:xbuild /p:SolutionDir=./ /target:Clean /p:Configuration=Release RealmJson.Extensions/RealmJson.Extensions.csproj xbuild /p:SolutionDir=./ /target:Build /p:Configuration=Release RealmJson.Extensions/RealmJson.Extensions.csproj
Xamarin.Androidadb shell am instrument -w RealmJson.Test.Droid/app.tests.TestInstrumentation
Ref: Automate Android Nunit Test
Ref: Issue 32005
Xamarin.iOSxbuild RealmJson.Test.iOS/RealmJson.Test.iOS.csproj /p:SolutionDir=~/ xcrun simctl list open -a Simulator --args -CurrentDeviceUDID 360D3BC6-4A6D-4B7E-A899-5C7651EC2107 xcrun simctl install booted ./RealmJson.Test.iOS/bin/iPhoneSimulator/Debug/RealmJson.Test.iOS.app xcrun simctl launch booted com.sushihangover.realmjson-test-ios cat ~/Library/Logs/CoreSimulator/360D3BC6-4A6D-4B7E-A899-5C7651EC2107/system.log
There is a #if PERF within Tests.Shared.Perf.Streaming.cs that contains multple tests to evaluate streaming performance and memory overhead.
These test methods try to evaluate:
Realm.Manage vs. AutoMapper performance/effeciencyRealmObjects can be used in a Realm Transaction on a mobile device.See https://github.com/sushihangover/Realm.Json.Extensions/blob/master/Perf.md "Perf.md" for details.
Consult LICENSE
<head> <style> .nuget-badge code { -moz-border-radius: 5px; -webkit-border-radius: 5px; background-color: #202020; border: 4px solid silver; border-radius: 5px; box-shadow: 2px 2px 3px #6e6e6e; color: #e2e2e2; display: block; font: 1.0em 'andale mono', 'lucida console', monospace; line-height: 1.5em; overflow: auto; padding: 15px } .nuget-badge code::before { content: "PM> " } .code { -moz-border-radius: 5px; -webkit-border-radius: 5px; background-color: #202020; border: 4px solid silver; border-radius: 5px; box-shadow: 2px 2px 3px #6e6e6e; color: #e2e2e2; display: block; font: 1.0em 'andale mono', 'lucida console', monospace; line-height: 1.5em; overflow: auto; padding: 15px }
</style> </head>
1.8.13