This repository has been archived by the owner on Feb 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 295
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[client][managed][offline] * remove redundant overloads in interface …
…and move them to extensions * abstract out system property reading into object reader
- Loading branch information
Showing
15 changed files
with
312 additions
and
100 deletions.
There are no files selected for viewing
Submodule queryjs
updated
from 53a8e7 to 340c11
This file contains 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
This file contains 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
64 changes: 64 additions & 0 deletions
64
sdk/Managed/src/Microsoft.WindowsAzure.MobileServices/Table/MobileServiceObjectReader.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// ---------------------------------------------------------------------------- | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// ---------------------------------------------------------------------------- | ||
|
||
using System; | ||
using Newtonsoft.Json.Linq; | ||
|
||
namespace Microsoft.WindowsAzure.MobileServices | ||
{ | ||
internal class MobileServiceObjectReader | ||
{ | ||
public string VersionPropertyName { get; set; } | ||
public string DeletedPropertyName { get; set; } | ||
public string UpdatedAtPropertyName { get; set; } | ||
public string IdPropertyName { get; set; } | ||
public string CreatedAtPropertyName { get; set; } | ||
|
||
public MobileServiceObjectReader() | ||
{ | ||
this.VersionPropertyName = MobileServiceSystemColumns.Version; | ||
this.DeletedPropertyName = MobileServiceSystemColumns.Deleted; | ||
this.UpdatedAtPropertyName = MobileServiceSystemColumns.UpdatedAt; | ||
this.IdPropertyName = MobileServiceSystemColumns.Id; | ||
this.CreatedAtPropertyName = MobileServiceSystemColumns.CreatedAt; | ||
} | ||
|
||
public string GetVersion(JObject item) | ||
{ | ||
return (string)item[this.VersionPropertyName]; | ||
} | ||
|
||
public string GetId(JObject item) | ||
{ | ||
return (string)item[IdPropertyName]; | ||
} | ||
|
||
public bool IsDeleted(JObject item) | ||
{ | ||
JToken deletedToken = item[DeletedPropertyName]; | ||
bool isDeleted = deletedToken != null && deletedToken.Value<bool>(); | ||
return isDeleted; | ||
} | ||
|
||
public DateTimeOffset? GetUpdatedAt(JObject item) | ||
{ | ||
return GetDateTimeOffset(item, UpdatedAtPropertyName); | ||
} | ||
|
||
public DateTimeOffset? GetCreatedAt(JObject item) | ||
{ | ||
return GetDateTimeOffset(item, CreatedAtPropertyName); | ||
} | ||
|
||
private static DateTimeOffset? GetDateTimeOffset(JObject item, string name) | ||
{ | ||
JToken updatedAtToken = item[name]; | ||
if (updatedAtToken != null) | ||
{ | ||
return updatedAtToken.ToObject<DateTimeOffset?>(); | ||
} | ||
return null; | ||
} | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.