Skip to content

Commit

Permalink
Full Merge.
Browse files Browse the repository at this point in the history
No More Dependency on Parse SDK.
Expect better updates and faster too.
  • Loading branch information
YBTopaz8 committed Dec 13, 2024
1 parent 7e13de6 commit b1c8f5c
Show file tree
Hide file tree
Showing 150 changed files with 14,856 additions and 105 deletions.
6 changes: 0 additions & 6 deletions ParseLiveQuery.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ VisualStudioVersion = 17.12.35521.163
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ParseLiveQuery", "ParseLiveQuery\ParseLiveQuery.csproj", "{D4B28D11-25E7-4430-ADFE-E2998DC63627}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Parse", "..\Parse-SDK-dotNETw\Parse\Parse.csproj", "{4782D57F-99EB-4AEF-B683-EFEFAF90B521}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -17,10 +15,6 @@ Global
{D4B28D11-25E7-4430-ADFE-E2998DC63627}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D4B28D11-25E7-4430-ADFE-E2998DC63627}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D4B28D11-25E7-4430-ADFE-E2998DC63627}.Release|Any CPU.Build.0 = Release|Any CPU
{4782D57F-99EB-4AEF-B683-EFEFAF90B521}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4782D57F-99EB-4AEF-B683-EFEFAF90B521}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4782D57F-99EB-4AEF-B683-EFEFAF90B521}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4782D57F-99EB-4AEF-B683-EFEFAF90B521}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
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

}
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;
}
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);
}
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);
}
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);
}
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);
}
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 ParseLiveQuery/Parse/Abstractions/Infrastructure/IDataCache.cs
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);
}
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; }
}
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();
}
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; }
}
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; }
}
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);
}
Loading

0 comments on commit b1c8f5c

Please sign in to comment.