Skip to content

Commit

Permalink
Finally Fixed for .net 9 and MAUI
Browse files Browse the repository at this point in the history
Will Do Docs later
  • Loading branch information
YBTopaz8 committed Dec 2, 2024
1 parent b5057d4 commit 1c29bc1
Show file tree
Hide file tree
Showing 40 changed files with 3,719 additions and 3,389 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public interface IParseObjectController

Task<IObjectState> SaveAsync(IObjectState state, IDictionary<string, IParseFieldOperation> operations, string sessionToken, IServiceHub serviceHub, CancellationToken cancellationToken = default);

IList<Task<IObjectState>> SaveAllAsync(IList<IObjectState> states, IList<IDictionary<string, IParseFieldOperation>> operationsList, string sessionToken, IServiceHub serviceHub, CancellationToken cancellationToken = default);
Task<IList<Task<IObjectState>>> SaveAllAsync(IList<IObjectState> states, IList<IDictionary<string, IParseFieldOperation>> operationsList, string sessionToken, IServiceHub serviceHub, CancellationToken cancellationToken = default);

Task DeleteAsync(IObjectState state, string sessionToken, CancellationToken cancellationToken = default);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,51 @@
using System.Threading.Tasks;
using Parse.Abstractions.Infrastructure;

namespace Parse.Abstractions.Platform.Objects
namespace Parse.Abstractions.Platform.Objects;

/// <summary>
/// <code>IParseObjectCurrentController</code> controls the single-instance <see cref="ParseObject"/>
/// persistence used throughout the code-base. Sample usages are <see cref="ParseUser.CurrentUser"/> and
/// <see cref="ParseInstallation.CurrentInstallation"/>.
/// </summary>
/// <typeparam name="T">Type of object being persisted.</typeparam>
public interface IParseObjectCurrentController<T> where T : ParseObject
{
/// <summary>
/// <code>IParseObjectCurrentController</code> controls the single-instance <see cref="ParseObject"/>
/// persistence used throughout the code-base. Sample usages are <see cref="ParseUser.CurrentUser"/> and
/// <see cref="ParseInstallation.CurrentInstallation"/>.
/// Persists current <see cref="ParseObject"/>.
/// </summary>
/// <typeparam name="T">Type of object being persisted.</typeparam>
public interface IParseObjectCurrentController<T> where T : ParseObject
{
/// <summary>
/// Persists current <see cref="ParseObject"/>.
/// </summary>
/// <param name="obj"><see cref="ParseObject"/> to be persisted.</param>
/// <param name="cancellationToken">The cancellation token.</param>
Task SetAsync(T obj, CancellationToken cancellationToken = default);
/// <param name="obj"><see cref="ParseObject"/> to be persisted.</param>
/// <param name="cancellationToken">The cancellation token.</param>
Task SetAsync(T obj, CancellationToken cancellationToken = default);

/// <summary>
/// Gets the persisted current <see cref="ParseObject"/>.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
Task<T> GetAsync(IServiceHub serviceHub, CancellationToken cancellationToken = default);
/// <summary>
/// Gets the persisted current <see cref="ParseObject"/>.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
Task<T> GetAsync(IServiceHub serviceHub, CancellationToken cancellationToken = default);

/// <summary>
/// Returns a <see cref="Task"/> that resolves to <code>true</code> if current
/// <see cref="ParseObject"/> exists.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
Task<bool> ExistsAsync(CancellationToken cancellationToken = default);
/// <summary>
/// Returns a <see cref="Task"/> that resolves to <code>true</code> if current
/// <see cref="ParseObject"/> exists.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
Task<bool> ExistsAsync(CancellationToken cancellationToken = default);

/// <summary>
/// Returns <code>true</code> if the given <see cref="ParseObject"/> is the persisted current
/// <see cref="ParseObject"/>.
/// </summary>
/// <param name="obj">The object to check.</param>
/// <returns>true if <code>obj</code> is the current persisted <see cref="ParseObject"/>.</returns>
bool IsCurrent(T obj);
/// <summary>
/// Returns <code>true</code> if the given <see cref="ParseObject"/> is the persisted current
/// <see cref="ParseObject"/>.
/// </summary>
/// <param name="obj">The object to check.</param>
/// <returns>true if <code>obj</code> is the current persisted <see cref="ParseObject"/>.</returns>
bool IsCurrent(T obj);

/// <summary>
/// Nullifies the current <see cref="ParseObject"/> from memory.
/// </summary>
void ClearFromMemory();
/// <summary>
/// Nullifies the current <see cref="ParseObject"/> from memory.
/// </summary>
void ClearFromMemory();

/// <summary>
/// Clears current <see cref="ParseObject"/> from disk.
/// </summary>
void ClearFromDisk();
}
/// <summary>
/// Clears current <see cref="ParseObject"/> from disk.
/// </summary>
Task ClearFromDiskAsync();
}
15 changes: 7 additions & 8 deletions Parse/Abstractions/Platform/Sessions/IParseSessionController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@
using Parse.Abstractions.Infrastructure;
using Parse.Abstractions.Platform.Objects;

namespace Parse.Abstractions.Platform.Sessions
namespace Parse.Abstractions.Platform.Sessions;

public interface IParseSessionController
{
public interface IParseSessionController
{
Task<IObjectState> GetSessionAsync(string sessionToken, IServiceHub serviceHub, CancellationToken cancellationToken = default);
Task<IObjectState> GetSessionAsync(string sessionToken, IServiceHub serviceHub, CancellationToken cancellationToken = default);

Task RevokeAsync(string sessionToken, CancellationToken cancellationToken = default);
Task RevokeAsync(string sessionToken, CancellationToken cancellationToken = default);

Task<IObjectState> UpgradeToRevocableSessionAsync(string sessionToken, IServiceHub serviceHub, CancellationToken cancellationToken = default);
Task<IObjectState> UpgradeToRevocableSessionAsync(string sessionToken, IServiceHub serviceHub, CancellationToken cancellationToken = default);

bool IsRevocableSessionToken(string sessionToken);
}
bool IsRevocableSessionToken(string sessionToken);
}
11 changes: 5 additions & 6 deletions Parse/Abstractions/Platform/Users/IParseCurrentUserController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
using Parse.Abstractions.Infrastructure;
using Parse.Abstractions.Platform.Objects;

namespace Parse.Abstractions.Platform.Users
namespace Parse.Abstractions.Platform.Users;

public interface IParseCurrentUserController : IParseObjectCurrentController<ParseUser>
{
public interface IParseCurrentUserController : IParseObjectCurrentController<ParseUser>
{
Task<string> GetCurrentSessionTokenAsync(IServiceHub serviceHub, CancellationToken cancellationToken = default);
Task<string> GetCurrentSessionTokenAsync(IServiceHub serviceHub, CancellationToken cancellationToken = default);

Task LogOutAsync(IServiceHub serviceHub, CancellationToken cancellationToken = default);
}
Task LogOutAsync(IServiceHub serviceHub, CancellationToken cancellationToken = default);
}
20 changes: 9 additions & 11 deletions Parse/Abstractions/Platform/Users/IParseUserController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,20 @@
using Parse.Abstractions.Infrastructure;
using Parse.Abstractions.Platform.Objects;

namespace Parse.Abstractions.Platform.Users
namespace Parse.Abstractions.Platform.Users;

public interface IParseUserController
{
public interface IParseUserController
{
Task<IObjectState> SignUpAsync(IObjectState state, IDictionary<string, IParseFieldOperation> operations, IServiceHub serviceHub, CancellationToken cancellationToken = default);
Task<IObjectState> SignUpAsync(IObjectState state, IDictionary<string, IParseFieldOperation> operations, IServiceHub serviceHub, CancellationToken cancellationToken = default);

Task<IObjectState> LogInAsync(string username, string password, IServiceHub serviceHub, CancellationToken cancellationToken = default);
Task<IObjectState> LogInAsync(string username, string password, IServiceHub serviceHub, CancellationToken cancellationToken = default);

Task<IObjectState> LogInAsync(string authType, IDictionary<string, object> data, IServiceHub serviceHub, CancellationToken cancellationToken = default);
Task<IObjectState> LogInAsync(string authType, IDictionary<string, object> data, IServiceHub serviceHub, CancellationToken cancellationToken = default);

Task<IObjectState> GetUserAsync(string sessionToken, IServiceHub serviceHub, CancellationToken cancellationToken = default);
Task<IObjectState> GetUserAsync(string sessionToken, IServiceHub serviceHub, CancellationToken cancellationToken = default);

Task RequestPasswordResetAsync(string email, CancellationToken cancellationToken = default);
Task RequestPasswordResetAsync(string email, CancellationToken cancellationToken = default);

bool RevocableSessionEnabled { get; set; }
bool RevocableSessionEnabled { get; set; }

object RevocableSessionEnabledMutex { get; }
}
}
27 changes: 18 additions & 9 deletions Parse/Infrastructure/CacheController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,29 +192,38 @@ FileBackedCache EnsureCacheExists(FileInfo file = default)
/// Loads a settings dictionary from the file wrapped by <see cref="File"/>.
/// </summary>
/// <returns>A storage dictionary containing the deserialized content of the storage file targeted by the <see cref="CacheController"/> instance</returns>
public Task<IDataCache<string, object>> LoadAsync()
public async Task<IDataCache<string, object>> LoadAsync()
{
// Check if storage dictionary is already created from the controllers file (create if not)
// Ensure the cache is created before loading
EnsureCacheExists();

// Load storage dictionary content async and return the resulting dictionary type
return Queue.Enqueue(toAwait => toAwait.ContinueWith(_ => Cache.LoadAsync().OnSuccess(__ => Cache as IDataCache<string, object>)).Unwrap(), CancellationToken.None);
// Load the cache content asynchronously
return await Queue.Enqueue(async (toAwait) =>
{
await toAwait.ConfigureAwait(false); // Wait for any prior tasks in the queue
await Cache.LoadAsync().ConfigureAwait(false); // Load the cache
return Cache as IDataCache<string, object>; // Return the cache as IDataCache
}, CancellationToken.None).ConfigureAwait(false);
}

/// <summary>
/// Saves the requested data.
/// </summary>
/// <param name="contents">The data to be saved.</param>
/// <returns>A data cache containing the saved data.</returns>
public Task<IDataCache<string, object>> SaveAsync(IDictionary<string, object> contents)
{
return Queue.Enqueue(toAwait => toAwait.ContinueWith(_ =>
public async Task<IDataCache<string, object>> SaveAsync(IDictionary<string, object> contents)
{
// Ensure the cache exists and update it with the provided contents
EnsureCacheExists().Update(contents);
return Cache.SaveAsync().OnSuccess(__ => Cache as IDataCache<string, object>);
}).Unwrap());

// Save the cache asynchronously
await Cache.SaveAsync().ConfigureAwait(false);

// Return the cache as IDataCache<string, object>
return Cache as IDataCache<string, object>;
}


/// <summary>
/// <inheritdoc/>
/// </summary>
Expand Down
35 changes: 17 additions & 18 deletions Parse/Infrastructure/Control/ParseSetOperation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,26 @@
using Parse.Abstractions.Infrastructure.Control;
using Parse.Infrastructure.Data;

namespace Parse.Infrastructure.Control
{
public class ParseSetOperation : IParseFieldOperation
{
public ParseSetOperation(object value) => Value = value;
namespace Parse.Infrastructure.Control;

public object Encode(IServiceHub serviceHub)
{
return PointerOrLocalIdEncoder.Instance.Encode(Value, serviceHub);
}
public class ParseSetOperation : IParseFieldOperation
{
public ParseSetOperation(object value) => Value = value;

public IParseFieldOperation MergeWithPrevious(IParseFieldOperation previous)
{
return this;
}
public object Encode(IServiceHub serviceHub)
{
return PointerOrLocalIdEncoder.Instance.Encode(Value, serviceHub);
}

public object Apply(object oldValue, string key)
{
return Value;
}
public IParseFieldOperation MergeWithPrevious(IParseFieldOperation previous)
{
return this;
}

public object Value { get; private set; }
public object Apply(object oldValue, string key)
{
return Value;
}

public object Value { get; private set; }
}
Loading

0 comments on commit 1c29bc1

Please sign in to comment.