diff --git a/Runtime/AbstractAuthentication.cs b/Runtime/AbstractAuthentication.cs index 8b85a25..deb4752 100644 --- a/Runtime/AbstractAuthentication.cs +++ b/Runtime/AbstractAuthentication.cs @@ -1,24 +1,61 @@ // Licensed under the MIT License. See LICENSE in the project root for license information. +using System; using System.IO; using UnityEngine; namespace Utilities.WebRequestRest.Interfaces { - public abstract class AbstractAuthentication : IAuthentication + public abstract class AbstractAuthentication : IAuthentication where TAuthentication : IAuthentication where TAuthInfo : IAuthInfo + where TConfiguration : ScriptableObject, IConfiguration { /// public abstract TAuthInfo Info { get; } + /// + /// Attempts to load the default authentication based on order of precedence.
+ /// 1. ScriptableObject
+ /// 2. Directory
+ /// 3. User Directory
+ /// 4. Environment Variables
+ ///
+ /// + /// The loaded or . + /// + public virtual TAuthentication LoadDefault() + => LoadFromAsset() ?? + LoadFromDirectory() ?? + LoadFromDirectory(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)) ?? + LoadFromEnvironment(); + + /// + /// Attempts to load the default authentication based on order of precedence.
+ /// 1. Environment Variables
+ /// 2. User Directory
+ /// 3. Directory
+ /// 4. ScriptableObject
+ ///
+ /// + /// The loaded or . + /// + public virtual TAuthentication LoadDefaultsReversed() + => LoadFromEnvironment() ?? + LoadFromDirectory(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)) ?? + LoadFromAsset() ?? + LoadFromDirectory(); + + [Obsolete("Use LoadFromAsset (remove angle bracket type specification)")] + public TAuthentication LoadFromAsset() => LoadFromAsset(); + /// /// Attempts to load the authentication from a asset that implements . /// /// /// The loaded or . /// - public abstract TAuthentication LoadFromAsset(T asset = null) where T : ScriptableObject, IConfiguration; + public abstract TAuthentication LoadFromAsset(TConfiguration configuration = null); /// /// Attempts to load the authentication from the system environment variables. diff --git a/package.json b/package.json index 0e372a9..d528c61 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "displayName": "Utilities.Rest", "description": "This package contains useful RESTful utilities for the Unity Game Engine.", "keywords": [], - "version": "2.2.7", + "version": "2.3.0", "unity": "2021.3", "documentationUrl": "https://github.com/RageAgainstThePixel/com.utilities.rest#documentation", "changelogUrl": "https://github.com/RageAgainstThePixel/com.utilities.rest/releases",