This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using Realms; | |
namespace RealmDev.Core.RealmObjects | |
{ | |
public class Comment : EmbeddedObject | |
{ | |
public DateTimeOffset CreatedOn { get; set; } | |
public string Text { get; set; } | |
public string Author { get; set; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public async Task<JObject> GetLocationJObject(int locationId) | |
{ | |
return await Task.Run(() => | |
{ | |
var companyJObject = JObject.Parse(RawJson.Company); // parsing to JObject is fast even for large objects | |
var locationJObject = companyJObject[nameof(Company.Locations)]? | |
.FirstOrDefault(x => (int)x[nameof(Location.Id)] == locationId) as JObject; | |
return locationJObject; | |
}) | |
.ConfigureAwait(false); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using Newtonsoft.Json; | |
using Newtonsoft.Json.Serialization; | |
namespace JsonPerf.Resolvers | |
{ | |
/// <summary> | |
/// Can be used for any type to dynamically specify which properties are part of the serialization contract |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
readonly Lazy<DynamicContractResolver> _locationDetailsResolver = | |
new Lazy<DynamicContractResolver>(() => | |
new DynamicContractResolver( | |
nameof(Models.Location.Name), | |
nameof(Models.Location.Address), | |
nameof(Models.Location.Id))); | |
var serializerSettings = new JsonSerializerSettings | |
{ | |
ContractResolver = _locationDetailsResolver?.Value |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CurrentLocationJObject[nameof(Models.Location.Name)] = CurrentLocation.Name; | |
CurrentLocationJObject[nameof(Models.Location.Address)] = CurrentLocation.Address; | |
await _locationManager.SaveLocation(CurrentLocationJObject, CurrentLocation.Id); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public async Task SaveLocation(JObject locationJObject, int locationId) | |
{ | |
await Task.Run(() => | |
{ | |
var companyJObject = JObject.Parse(RawJson.Company); | |
companyJObject[nameof(Company.Locations)]? | |
.FirstOrDefault(x => (decimal)x[nameof(Location.Id)] == locationId) | |
.Replace(locationJObject); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Observable.FromEventPattern<ViewPager.PageScrolledEventArgs> ( | |
x => _viewPager.PageScrolled += x, | |
x => _viewPager.PageScrolled -= x) | |
.Select (args => args.EventArgs) | |
.StartWith(new ViewPager.PageScrolledEventArgs(0, 0, 0)) | |
.PairWithPrevious() | |
.Skip(1) | |
.Select(args => { | |
var scrollDirection = | |
args.Item1.Position != args.Item2.Position |