forked from JonMcPherson/parse-live-query-dotnet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
No More Dependency on Parse SDK. Expect better updates and faster too.
- Loading branch information
Showing
150 changed files
with
14,856 additions
and
105 deletions.
There are no files selected for viewing
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
47 changes: 47 additions & 0 deletions
47
ParseLiveQuery/Parse/Abstractions/Infrastructure/Control/IParseFieldOperation.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,47 @@ | ||
namespace Parse.Abstractions.Infrastructure.Control; | ||
|
||
/// <summary> | ||
/// A ParseFieldOperation represents a modification to a value in a ParseObject. | ||
/// For example, setting, deleting, or incrementing a value are all different kinds of | ||
/// ParseFieldOperations. ParseFieldOperations themselves can be considered to be | ||
/// immutable. | ||
/// </summary> | ||
public interface IParseFieldOperation: IJsonConvertible | ||
{ | ||
/// <summary> | ||
/// Converts the ParseFieldOperation to a data structure that can be converted to JSON and sent to | ||
/// Parse as part of a save operation. | ||
/// </summary> | ||
/// <returns>An object to be JSONified.</returns> | ||
/// | ||
//object Encode(IServiceHub serviceHub); | ||
|
||
/// <summary> | ||
/// Returns a field operation that is composed of a previous operation followed by | ||
/// this operation. This will not mutate either operation. However, it may return | ||
/// <code>this</code> if the current operation is not affected by previous changes. | ||
/// For example: | ||
/// {increment by 2}.MergeWithPrevious({set to 5}) -> {set to 7} | ||
/// {set to 5}.MergeWithPrevious({increment by 2}) -> {set to 5} | ||
/// {add "foo"}.MergeWithPrevious({delete}) -> {set to ["foo"]} | ||
/// {delete}.MergeWithPrevious({add "foo"}) -> {delete} /// </summary> | ||
/// <param name="previous">The most recent operation on the field, or null if none.</param> | ||
/// <returns>A new ParseFieldOperation or this.</returns> | ||
IParseFieldOperation MergeWithPrevious(IParseFieldOperation previous); | ||
|
||
/// <summary> | ||
/// Returns a new estimated value based on a previous value and this operation. This | ||
/// value is not intended to be sent to Parse, but it is used locally on the client to | ||
/// inspect the most likely current value for a field. | ||
/// | ||
/// The key and object are used solely for ParseRelation to be able to construct objects | ||
/// that refer back to their parents. | ||
/// </summary> | ||
/// <param name="oldValue">The previous value for the field.</param> | ||
/// <param name="key">The key that this value is for.</param> | ||
/// <returns>The new value for the field.</returns> | ||
object Apply(object oldValue, string key); | ||
|
||
object Value { get; } // Added property to expose operation value | ||
|
||
} |
65 changes: 65 additions & 0 deletions
65
ParseLiveQuery/Parse/Abstractions/Infrastructure/CustomServiceHub.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,65 @@ | ||
using Parse.Abstractions.Infrastructure.Data; | ||
using Parse.Abstractions.Infrastructure.Execution; | ||
using Parse.Abstractions.Platform.Analytics; | ||
using Parse.Abstractions.Platform.Cloud; | ||
using Parse.Abstractions.Platform.Configuration; | ||
using Parse.Abstractions.Platform.Files; | ||
using Parse.Abstractions.Platform.Installations; | ||
using Parse.Abstractions.Platform.Objects; | ||
using Parse.Abstractions.Platform.Push; | ||
using Parse.Abstractions.Platform.Queries; | ||
using Parse.Abstractions.Platform.Sessions; | ||
using Parse.Abstractions.Platform.Users; | ||
|
||
namespace Parse.Abstractions.Infrastructure; | ||
|
||
public abstract class CustomServiceHub : ICustomServiceHub | ||
{ | ||
public virtual IServiceHub Services { get; internal set; } | ||
|
||
public virtual IServiceHubCloner Cloner => Services.Cloner; | ||
|
||
public virtual IMetadataController MetadataController => Services.MetadataController; | ||
|
||
public virtual IWebClient WebClient => Services.WebClient; | ||
|
||
public virtual ICacheController CacheController => Services.CacheController; | ||
|
||
public virtual IParseObjectClassController ClassController => Services.ClassController; | ||
|
||
public virtual IParseInstallationController InstallationController => Services.InstallationController; | ||
|
||
public virtual IParseCommandRunner CommandRunner => Services.CommandRunner; | ||
|
||
public virtual IParseCloudCodeController CloudCodeController => Services.CloudCodeController; | ||
|
||
public virtual IParseConfigurationController ConfigurationController => Services.ConfigurationController; | ||
|
||
public virtual IParseFileController FileController => Services.FileController; | ||
|
||
public virtual IParseObjectController ObjectController => Services.ObjectController; | ||
|
||
public virtual IParseQueryController QueryController => Services.QueryController; | ||
|
||
public virtual IParseSessionController SessionController => Services.SessionController; | ||
|
||
public virtual IParseUserController UserController => Services.UserController; | ||
|
||
public virtual IParseCurrentUserController CurrentUserController => Services.CurrentUserController; | ||
|
||
public virtual IParseAnalyticsController AnalyticsController => Services.AnalyticsController; | ||
|
||
public virtual IParseInstallationCoder InstallationCoder => Services.InstallationCoder; | ||
|
||
public virtual IParsePushChannelsController PushChannelsController => Services.PushChannelsController; | ||
|
||
public virtual IParsePushController PushController => Services.PushController; | ||
|
||
public virtual IParseCurrentInstallationController CurrentInstallationController => Services.CurrentInstallationController; | ||
|
||
public virtual IServerConnectionData ServerConnectionData => Services.ServerConnectionData; | ||
|
||
public virtual IParseDataDecoder Decoder => Services.Decoder; | ||
|
||
public virtual IParseInstallationDataFinalizer InstallationDataFinalizer => Services.InstallationDataFinalizer; | ||
} |
15 changes: 15 additions & 0 deletions
15
ParseLiveQuery/Parse/Abstractions/Infrastructure/Data/IParseDataDecoder.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,15 @@ | ||
namespace Parse.Abstractions.Infrastructure.Data; | ||
|
||
/// <summary> | ||
/// A generalized input data decoding interface for the Parse SDK. | ||
/// </summary> | ||
public interface IParseDataDecoder | ||
{ | ||
/// <summary> | ||
/// Decodes input data into Parse-SDK-related entities, such as <see cref="ParseObject"/> instances, which is why an <see cref="IServiceHub"/> implementation instance is sometimes required. | ||
/// </summary> | ||
/// <param name="data">The target input data to decode.</param> | ||
/// <param name="serviceHub">A <see cref="IServiceHub"/> implementation instance to use when instantiating <see cref="ParseObject"/>s.</param> | ||
/// <returns>A Parse SDK entity such as a <see cref="ParseObject"/>.</returns> | ||
object Decode(object data, IServiceHub serviceHub); | ||
} |
21 changes: 21 additions & 0 deletions
21
ParseLiveQuery/Parse/Abstractions/Infrastructure/Execution/IParseCommandRunner.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,21 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Net; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Parse.Infrastructure.Execution; | ||
|
||
namespace Parse.Abstractions.Infrastructure.Execution; | ||
|
||
public interface IParseCommandRunner | ||
{ | ||
/// <summary> | ||
/// Executes <see cref="ParseCommand"/> and convert the result into Dictionary. | ||
/// </summary> | ||
/// <param name="command">The command to be run.</param> | ||
/// <param name="uploadProgress">Upload progress callback.</param> | ||
/// <param name="downloadProgress">Download progress callback.</param> | ||
/// <param name="cancellationToken">The cancellation token for the request.</param> | ||
/// <returns></returns> | ||
Task<Tuple<HttpStatusCode, IDictionary<string, object>>> RunCommandAsync(ParseCommand command, IProgress<IDataTransferLevel> uploadProgress = null, IProgress<IDataTransferLevel> downloadProgress = null, CancellationToken cancellationToken = default); | ||
} |
21 changes: 21 additions & 0 deletions
21
ParseLiveQuery/Parse/Abstractions/Infrastructure/Execution/IWebClient.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,21 @@ | ||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Parse.Infrastructure.Execution; | ||
using Status = System.Net.HttpStatusCode; | ||
|
||
namespace Parse.Abstractions.Infrastructure.Execution; | ||
|
||
public interface IWebClient | ||
{ | ||
/// <summary> | ||
/// Executes HTTP request to a <see cref="WebRequest.Target"/> with <see cref="WebRequest.Method"/> HTTP verb | ||
/// and <see cref="WebRequest.Headers"/>. | ||
/// </summary> | ||
/// <param name="httpRequest">The HTTP request to be executed.</param> | ||
/// <param name="uploadProgress">Upload progress callback.</param> | ||
/// <param name="downloadProgress">Download progress callback.</param> | ||
/// <param name="cancellationToken">The cancellation token.</param> | ||
/// <returns>A task that resolves to Htt</returns> | ||
Task<Tuple<Status, string>> ExecuteAsync(WebRequest httpRequest, IProgress<IDataTransferLevel> uploadProgress, IProgress<IDataTransferLevel> downloadProgress, CancellationToken cancellationToken = default); | ||
} |
46 changes: 46 additions & 0 deletions
46
ParseLiveQuery/Parse/Abstractions/Infrastructure/ICacheController.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,46 @@ | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Threading.Tasks; | ||
|
||
namespace Parse.Abstractions.Infrastructure; | ||
|
||
// TODO: Move TransferAsync to IDiskFileCacheController and find viable alternative for use in ICacheController if needed. | ||
|
||
/// <summary> | ||
/// An abstraction for accessing persistent storage in the Parse SDK. | ||
/// </summary> | ||
public interface ICacheController | ||
{ | ||
/// <summary> | ||
/// Cleans up any temporary files and/or directories created during SDK operation. | ||
/// </summary> | ||
public void Clear(); | ||
|
||
/// <summary> | ||
/// Gets the file wrapper for the specified <paramref name="path"/>. | ||
/// </summary> | ||
/// <param name="path">The relative path to the target file</param> | ||
/// <returns>An instance of <see cref="FileInfo"/> wrapping the the <paramref name="path"/> value</returns> | ||
FileInfo GetRelativeFile(string path); | ||
|
||
/// <summary> | ||
/// Transfers a file from <paramref name="originFilePath"/> to <paramref name="targetFilePath"/>. | ||
/// </summary> | ||
/// <param name="originFilePath"></param> | ||
/// <param name="targetFilePath"></param> | ||
/// <returns>A task that completes once the file move operation form <paramref name="originFilePath"/> to <paramref name="targetFilePath"/> completes.</returns> | ||
Task TransferAsync(string originFilePath, string targetFilePath); | ||
|
||
/// <summary> | ||
/// Load the contents of this storage controller asynchronously. | ||
/// </summary> | ||
/// <returns></returns> | ||
Task<IDataCache<string, object>> LoadAsync(); | ||
|
||
/// <summary> | ||
/// Overwrites the contents of this storage controller asynchronously. | ||
/// </summary> | ||
/// <param name="contents"></param> | ||
/// <returns></returns> | ||
Task<IDataCache<string, object>> SaveAsync(IDictionary<string, object> contents); | ||
} |
6 changes: 6 additions & 0 deletions
6
ParseLiveQuery/Parse/Abstractions/Infrastructure/ICustomServiceHub.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,6 @@ | ||
namespace Parse.Abstractions.Infrastructure; | ||
|
||
public interface ICustomServiceHub : IServiceHub | ||
{ | ||
IServiceHub Services { get; } | ||
} |
29 changes: 29 additions & 0 deletions
29
ParseLiveQuery/Parse/Abstractions/Infrastructure/IDataCache.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,29 @@ | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
|
||
namespace Parse.Abstractions.Infrastructure; | ||
|
||
// IGeneralizedDataCache | ||
|
||
/// <summary> | ||
/// An interface for a dictionary that is persisted to disk asynchronously. | ||
/// </summary> | ||
/// <typeparam name="TKey">They key type of the dictionary.</typeparam> | ||
/// <typeparam name="TValue">The value type of the dictionary.</typeparam> | ||
public interface IDataCache<TKey, TValue> : IDictionary<TKey, TValue> | ||
{ | ||
/// <summary> | ||
/// Adds a key to this dictionary, and saves it asynchronously. | ||
/// </summary> | ||
/// <param name="key">The key to insert.</param> | ||
/// <param name="value">The value to insert.</param> | ||
/// <returns></returns> | ||
Task AddAsync(TKey key, TValue value); | ||
|
||
/// <summary> | ||
/// Removes a key from this dictionary, and saves it asynchronously. | ||
/// </summary> | ||
/// <param name="key"></param> | ||
/// <returns></returns> | ||
Task RemoveAsync(TKey key); | ||
} |
6 changes: 6 additions & 0 deletions
6
ParseLiveQuery/Parse/Abstractions/Infrastructure/IDataTransferLevel.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,6 @@ | ||
namespace Parse.Abstractions.Infrastructure; | ||
|
||
public interface IDataTransferLevel | ||
{ | ||
double Amount { get; set; } | ||
} |
25 changes: 25 additions & 0 deletions
25
ParseLiveQuery/Parse/Abstractions/Infrastructure/IDiskFileCacheController.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,25 @@ | ||
using System; | ||
|
||
namespace Parse.Abstractions.Infrastructure; | ||
|
||
/// <summary> | ||
/// An <see cref="ICacheController"/> which stores the cache on disk via a file. | ||
/// </summary> | ||
public interface IDiskFileCacheController : ICacheController | ||
{ | ||
/// <summary> | ||
/// The path to a persistent user-specific storage location specific to the final client assembly of the Parse library. | ||
/// </summary> | ||
public string AbsoluteCacheFilePath { get; set; } | ||
|
||
/// <summary> | ||
/// The relative path from the <see cref="Environment.SpecialFolder.LocalApplicationData"/> on the device an to application-specific persistent storage folder. | ||
/// </summary> | ||
public string RelativeCacheFilePath { get; set; } | ||
|
||
/// <summary> | ||
/// Refreshes this cache controller's internal tracked cache file to reflect the <see cref="AbsoluteCacheFilePath"/> and/or <see cref="RelativeCacheFilePath"/>. | ||
/// </summary> | ||
/// <remarks>This will not delete the active tracked cache file that will be un-tracked after a call to this method. To do so, call <see cref="ICacheController.Clear()"/>.</remarks> | ||
void RefreshPaths(); | ||
} |
23 changes: 23 additions & 0 deletions
23
ParseLiveQuery/Parse/Abstractions/Infrastructure/IEnvironmentData.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,23 @@ | ||
namespace Parse.Abstractions.Infrastructure; | ||
|
||
/// <summary> | ||
/// Information about the environment in which the library will be operating. | ||
/// </summary> | ||
public interface IEnvironmentData | ||
{ | ||
/// <summary> | ||
/// The currently active time zone when the library will be used. | ||
/// </summary> | ||
string TimeZone { get; } | ||
|
||
/// <summary> | ||
/// The operating system version of the platform the SDK is operating in. | ||
/// </summary> | ||
string OSVersion { get; } | ||
|
||
/// <summary> | ||
/// An identifier of the platform. | ||
/// </summary> | ||
/// <remarks>Expected to be one of ios, android, winrt, winphone, or dotnet.</remarks> | ||
public string Platform { get; set; } | ||
} |
27 changes: 27 additions & 0 deletions
27
ParseLiveQuery/Parse/Abstractions/Infrastructure/IHostManifestData.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,27 @@ | ||
namespace Parse.Abstractions.Infrastructure; | ||
|
||
/// <summary> | ||
/// Information about the application using the Parse SDK. | ||
/// </summary> | ||
public interface IHostManifestData | ||
{ | ||
/// <summary> | ||
/// The build number of your app. | ||
/// </summary> | ||
string Version { get; } | ||
|
||
/// <summary> | ||
/// The human friendly version number of your app. | ||
/// </summary> | ||
string ShortVersion { get; } | ||
|
||
/// <summary> | ||
/// A unique string representing your app. | ||
/// </summary> | ||
string Identifier { get; } | ||
|
||
/// <summary> | ||
/// The name of your app. | ||
/// </summary> | ||
string Name { get; } | ||
} |
15 changes: 15 additions & 0 deletions
15
ParseLiveQuery/Parse/Abstractions/Infrastructure/IJsonConvertible.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,15 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace Parse.Abstractions.Infrastructure; | ||
|
||
/// <summary> | ||
/// Represents an object that can be converted into JSON. | ||
/// </summary> | ||
public interface IJsonConvertible | ||
{ | ||
/// <summary> | ||
/// Converts the object to a data structure that can be converted to JSON. | ||
/// </summary> | ||
/// <returns>An object to be JSONified.</returns> | ||
IDictionary<string, object> ConvertToJSON(IServiceHub serviceHub=default); | ||
} |
Oops, something went wrong.