diff --git a/EPS.SDK/Caching/Cache.cs b/EPS.SDK/Caching/Cache.cs
new file mode 100644
index 0000000..9f31b3b
--- /dev/null
+++ b/EPS.SDK/Caching/Cache.cs
@@ -0,0 +1,40 @@
+using ExtensiblePortfolioSite.SDK.Resources;
+
+using System;
+using System.Collections.Generic;
+
+namespace ExtensiblePortfolioSite.SDK.Caching
+{
+ ///
+ /// Global Item Cache
+ ///
+ public static class Cache
+ {
+ internal static TimeSpan GitUserLifetime = TimeSpan.FromMinutes(1440);
+ internal static TimeSpan GitRepositoryLifetime = TimeSpan.FromMinutes(120);
+
+ private static readonly SortedDictionary CacheLookup = new();
+
+ ///
+ /// Retrives the specified for the given provider
+ ///
+ /// Git Service Provider Name
+ /// Git Service Cache
+ public static GitServiceCache GetGitServiceCache(String ServiceProvider)
+ {
+ if (CacheLookup.TryGetValue(ServiceProvider, out GitServiceCache? cache))
+ return cache;
+ lock (CacheLookup)
+ {
+ if (CacheLookup.TryGetValue(ServiceProvider, out cache))
+ return cache;
+
+ ServiceProvider = string.Intern(ServiceProvider);
+
+ cache = new GitServiceCache(ServiceProvider);
+ CacheLookup.Add(ServiceProvider, cache);
+ return cache;
+ }
+ }
+ }
+}
diff --git a/EPS.SDK/Caching/CacheRepo.cs b/EPS.SDK/Caching/CacheRepo.cs
new file mode 100644
index 0000000..8dafb78
--- /dev/null
+++ b/EPS.SDK/Caching/CacheRepo.cs
@@ -0,0 +1,16 @@
+using ExtensiblePortfolioSite.SDK.Git;
+
+using System;
+
+namespace ExtensiblePortfolioSite.SDK.Caching
+{
+ internal sealed class CacheRepo : GitCacheItemBase
+ {
+ private readonly Uri Repository;
+
+ internal CacheRepo(GitServiceCache Parent, Uri Repository) : base(Parent) => this.Repository = Repository;
+
+ protected override TimeSpan Lifetime => Cache.GitRepositoryLifetime;
+ protected override IRepository RetriveValue() => this.Parent.ServiceProvider.GetRepository(this.Repository);
+ }
+}
diff --git a/EPS.SDK/Caching/CacheUser.cs b/EPS.SDK/Caching/CacheUser.cs
new file mode 100644
index 0000000..bd29f7a
--- /dev/null
+++ b/EPS.SDK/Caching/CacheUser.cs
@@ -0,0 +1,16 @@
+using ExtensiblePortfolioSite.SDK.Git;
+
+using System;
+
+namespace ExtensiblePortfolioSite.SDK.Caching
+{
+ internal sealed class CacheUser : GitCacheItemBase
+ {
+ private readonly Uri User;
+
+ internal CacheUser(GitServiceCache Parent, Uri User) : base(Parent) => this.User = User;
+
+ protected override TimeSpan Lifetime => Cache.GitRepositoryLifetime;
+ protected override IUser RetriveValue() => this.Parent.ServiceProvider.GetUser(this.User);
+ }
+}
diff --git a/EPS.SDK/Caching/GitCacheItemBase.cs b/EPS.SDK/Caching/GitCacheItemBase.cs
new file mode 100644
index 0000000..15e8188
--- /dev/null
+++ b/EPS.SDK/Caching/GitCacheItemBase.cs
@@ -0,0 +1,80 @@
+using System;
+
+namespace ExtensiblePortfolioSite.SDK.Caching
+{
+ ///
+ /// Base Git Cache Item Class
+ ///
+ public abstract class GitCacheItemBase : IDisposable, ICacheItem
+ {
+ ///
+ /// the this Item is bound to
+ ///
+ protected readonly GitServiceCache Parent;
+
+ ///
+ /// that this Item is boud to
+ public GitCacheItemBase(GitServiceCache Parent)
+ {
+ this.Parent = Parent;
+ Parent.Register(this);
+ }
+ ///
+ ~GitCacheItemBase() => this.Disposing();
+
+ ///
+ public abstract void Invalidate();
+
+ ///
+ public void Dispose()
+ {
+ GC.SuppressFinalize(this);
+ this.Disposing();
+ }
+ private void Disposing() => this.Parent.Unregister(this);
+
+ }
+
+ ///
+ /// Base Git Cache Item Class
+ ///
+ /// Cache
+ public abstract class GitCacheItemBase : GitCacheItemBase, ICacheItem
+ {
+ private T CacheValue;
+ private DateTime RetrivedTime;
+
+ internal GitCacheItemBase(GitServiceCache Parent) : base(Parent)
+ {
+ this.RetrivedTime = DateTime.MinValue;
+ this.CacheValue = default!;
+ }
+
+ ///
+ public override void Invalidate()
+ {
+ this.CacheValue = default!;
+ this.RetrivedTime = DateTime.MinValue;
+ }
+ ///
+ public T GetValue()
+ {
+ if (DateTime.Now - this.RetrivedTime > this.Lifetime)
+ {
+ this.CacheValue = RetriveValue();
+ this.RetrivedTime = DateTime.Now;
+ }
+ return this.CacheValue!;
+ }
+
+ ///
+ /// Get Expected Cache Item Lifetime
+ ///
+ protected abstract TimeSpan Lifetime { get; }
+ ///
+ /// Retrive the Cache Item
+ ///
+ /// Cache Item
+ protected abstract T RetriveValue();
+ }
+}
diff --git a/EPS.SDK/Caching/GitServiceCache.cs b/EPS.SDK/Caching/GitServiceCache.cs
new file mode 100644
index 0000000..5a22d93
--- /dev/null
+++ b/EPS.SDK/Caching/GitServiceCache.cs
@@ -0,0 +1,107 @@
+using ExtensiblePortfolioSite.SDK.Git;
+
+using System;
+using System.Collections.Generic;
+
+namespace ExtensiblePortfolioSite.SDK.Caching
+{
+ ///
+ /// Git Service Cache Provider
+ ///
+ public sealed class GitServiceCache : IGitCacheProvider, IDisposable
+ {
+ ///
+ public GitService ServiceProvider { get; }
+ private readonly LinkedList CacheItems = new();
+ private Boolean _disposing = false;
+
+ internal GitServiceCache(String Provider) : this(GitManager.GetService(Provider)) { }
+ internal GitServiceCache(GitService ServiceProvider)
+ {
+ this.ServiceProvider = ServiceProvider;
+ this.ServiceProvider.OnChange += ServiceProvider_OnChange;
+ }
+
+ private void ServiceProvider_OnChange(GitService Git)
+ {
+ lock(this.CacheItems)
+ {
+ foreach (GitCacheItemBase Item in this.CacheItems)
+ Item.Invalidate();
+ }
+ }
+
+
+ private readonly SortedDictionary> UserCaches = new();
+ private readonly SortedDictionary> RepositoryCaches = new();
+
+
+ ///
+ public GitCacheItemBase GetUser(Uri UserProfile)
+ {
+ String url = UserProfile.ToString();
+ if (UserCaches.TryGetValue(url, out GitCacheItemBase? cache))
+ return cache;
+
+ lock (UserCaches)
+ {
+ if (UserCaches.TryGetValue(url, out cache))
+ return cache;
+
+ cache = new CacheUser(this, UserProfile);
+ UserCaches.Add(url, cache);
+ return cache;
+ }
+ }
+ ///
+ public GitCacheItemBase GetRepository(Uri RepositoryURL)
+ {
+ String url = RepositoryURL.ToString();
+ if (RepositoryCaches.TryGetValue(url, out GitCacheItemBase? cache))
+ return cache;
+
+ lock (RepositoryCaches)
+ {
+ if (RepositoryCaches.TryGetValue(url, out cache))
+ return cache;
+
+ cache = new CacheRepo(this, RepositoryURL);
+ RepositoryCaches.Add(url, cache);
+ return cache;
+ }
+ }
+
+
+ ///
+ public void Register(GitCacheItemBase CacheItem)
+ {
+ if (!_disposing)
+ lock (CacheItems)
+ {
+ this.CacheItems.AddFirst(CacheItem);
+ }
+ }
+ ///
+ public void Unregister(GitCacheItemBase CacheItem)
+ {
+ if (!_disposing)
+ lock (CacheItems)
+ if (this.CacheItems.Remove(CacheItem)) ;
+ }
+
+
+ ///
+ public void Dispose()
+ {
+ _disposing = true;
+ lock (CacheItems)
+ {
+ this.ServiceProvider.OnChange -= ServiceProvider_OnChange;
+ this.RepositoryCaches.Clear();
+ this.UserCaches.Clear();
+ foreach (GitCacheItemBase Item in CacheItems)
+ Item.Dispose();
+ }
+ }
+ }
+}
diff --git a/EPS.SDK/Caching/interfaces.cs b/EPS.SDK/Caching/interfaces.cs
new file mode 100644
index 0000000..b314917
--- /dev/null
+++ b/EPS.SDK/Caching/interfaces.cs
@@ -0,0 +1,79 @@
+using ExtensiblePortfolioSite.SDK.Git;
+
+using System;
+
+namespace ExtensiblePortfolioSite.SDK.Caching
+{
+ ///
+ /// Represents a Cache Item Provider
+ ///
+ /// Cache Item Base Type
+ public interface ICacheProvider where TCacheItemType : ICacheItem
+ {
+ ///
+ /// Registers a Cache Item
+ ///
+ ///
+ void Register(TCacheItemType Item);
+
+ ///
+ /// Unregisters a Cache Item
+ ///
+ ///
+ void Unregister(TCacheItemType Item);
+ }
+
+ ///
+ /// Represents a Cache Item
+ ///
+ public interface ICacheItem
+ {
+ ///
+ /// Invalidates the Cache Item
+ ///
+ void Invalidate();
+ }
+
+ ///
+ /// Represents a Cache Item of Type
+ ///
+ /// Cache Item Type
+ public interface ICacheItem : ICacheItem
+ {
+ ///
+ /// Gets the Requested Cache Item
+ ///
+ ///
+ T GetValue();
+ }
+
+ ///
+ /// Git Cache Invalidate or Changed Delegate Callback
+ ///
+ public delegate void GitCacheInvalidateDelegate();
+
+ ///
+ /// A Git Cache Provider
+ ///
+ public interface IGitCacheProvider : ICacheProvider
+ {
+ ///
+ /// The Service Provider tied to this Cache
+ ///
+ public GitService ServiceProvider { get; }
+
+ ///
+ /// Get a User by its URL
+ ///
+ /// User Profile URL
+ ///
+ public GitCacheItemBase GetUser(Uri UserProfile);
+ ///
+ /// Get a Repositroy by its URL
+ ///
+ /// Repository URL
+ ///
+ public GitCacheItemBase GetRepository(Uri RepositoryURL);
+ }
+
+}
diff --git a/EPS.SDK/Git/GitManager.cs b/EPS.SDK/Git/GitManager.cs
index d56cc29..770db29 100644
--- a/EPS.SDK/Git/GitManager.cs
+++ b/EPS.SDK/Git/GitManager.cs
@@ -1,4 +1,6 @@
-using System;
+using ExtensiblePortfolioSite.SDK.Plugins;
+
+using System;
using System.Collections.Generic;
namespace ExtensiblePortfolioSite.SDK.Git
@@ -7,34 +9,6 @@ namespace ExtensiblePortfolioSite.SDK.Git
{
private static readonly SortedDictionary Providers = new();
- public static void Register(String Service, IGitProvider Provider)
- {
- Console.WriteLine($"Registering service {Service}");
- if (Providers.TryGetValue(Service, out GitService? GitService))
- {
- GitService.addProvider(Provider);
- return;
- }
- lock (Providers)
- {
- if (Providers.TryGetValue(Service, out GitService))
- {
- GitService.addProvider(Provider);
- return;
- }
-
- GitService = new GitService(Service);
- GitService.addProvider(Provider);
- Providers.Add(Service, GitService);
- }
- }
-
- public static void Unregister(String Service, IGitProvider Provider)
- {
- if (Providers.TryGetValue(Service, out GitService? GitService))
- GitService.removeProvider(Provider);
- }
-
public static GitService GetService(String Website) => Providers[Website];
}
}
diff --git a/EPS.SDK/Git/GitService.cs b/EPS.SDK/Git/GitService.cs
index 529b792..baf7ccd 100644
--- a/EPS.SDK/Git/GitService.cs
+++ b/EPS.SDK/Git/GitService.cs
@@ -1,54 +1,99 @@
-using System;
+using ExtensiblePortfolioSite.SDK.Caching;
+using ExtensiblePortfolioSite.SDK.Plugins;
+
+using System;
using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace ExtensiblePortfolioSite.SDK.Git
{
- internal class GitService
+ ///
+ /// Git Service Changed Delegate/Callback
+ ///
+ /// Sender
+ public delegate void GitServiceChangedDelegate(GitService Git);
+
+ ///
+ /// Git Service
+ ///
+ public sealed class GitService
{
+ ///
+ /// Git Service Name
+ ///
public String Service { get; }
- public GitService(String Service)
+ ///
+ /// OnChanged Event Callback
+ ///
+ public event GitServiceChangedDelegate? OnChange;
+
+ internal GitService(String Service) => this.Service = Service;
+
+ private readonly SortedDictionary Providers = new();
+
+ internal void I_RemoveProvider(Plugin FromPlugin, IGitProvider provider)
{
- this.Service = Service;
+ lock (this.Providers)
+ this.Providers.Add(FromPlugin.Info.Name, provider);
+
+ OnChange?.Invoke(this);
+ }
+ internal void I_AddProvider(Plugin FromPlugin, IGitProvider provider)
+ {
+ lock (this.Providers)
+ this.Providers.Add(FromPlugin.Info.Name, provider);
+
+ OnChange?.Invoke(this);
}
- private readonly List Providers = new();
+ private GitServiceCache? ServiceCache;
- internal void removeProvider(IGitProvider provider)
+ ///
+ /// Gets the Service Cache
+ ///
+ ///
+ public GitServiceCache GetCache() => this.ServiceCache ??= Cache.GetGitServiceCache(this.Service);
+
+ ///
+ /// Attempt to Retrive a GitProvider by its PluginName
+ ///
+ ///
+ ///
+ ///
+ public void TryGetProviderByPlugin(String PluginName, out IGitProvider? Provider) => this.Providers.TryGetValue(PluginName, out Provider);
+
+ ///
+ /// Retrives a Specified User by URL
+ ///
+ ///
+ ///
+ ///
+ public IUser GetUser(Uri URL)
{
lock (this.Providers)
- this.Providers.Remove(provider);
- }
- internal void addProvider(IGitProvider provider)
- {
- lock (this.Providers)
- this.Providers.Add(provider);
- }
-
- public IUser GetUser(Uri Path)
- {
- lock (this.Providers)
- {
- foreach(IGitProvider Provider in this.Providers)
- if (Provider.TryGetUserByURL(Path, out IUser? User))
+ foreach (IGitProvider Provider in this.Providers.Values)
+ if (Provider.TryGetUserByURL(URL, out IUser? User))
return User!;
-
- throw new GitObjectNotFoundException(GitReferenceKind.User, Path);
- }
+
+ throw new GitObjectNotFoundException(GitReferenceKind.User, URL);
+
}
- public IRepository GetRepository(Uri Path)
+
+ ///
+ /// Retrives a Specified Repository by URL
+ ///
+ ///
+ ///
+ ///
+ public IRepository GetRepository(Uri URL)
{
lock (this.Providers)
- {
- foreach (IGitProvider Provider in this.Providers)
- if (Provider.TryGetRepositoryByURL(Path, out IRepository? Repository))
+ foreach (IGitProvider Provider in this.Providers.Values)
+ if (Provider.TryGetRepositoryByURL(URL, out IRepository? Repository))
return Repository!;
- throw new GitObjectNotFoundException(GitReferenceKind.User, Path);
- }
+ throw new GitObjectNotFoundException(GitReferenceKind.Repository, URL);
+
}
}
}
diff --git a/EPS.SDK/Git/IGitProvider.cs b/EPS.SDK/Git/IGitProvider.cs
index 47116fd..2bce2e2 100644
--- a/EPS.SDK/Git/IGitProvider.cs
+++ b/EPS.SDK/Git/IGitProvider.cs
@@ -1,8 +1,4 @@
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace ExtensiblePortfolioSite.SDK.Git
{
@@ -30,19 +26,19 @@ namespace ExtensiblePortfolioSite.SDK.Git
///
/// Attempts to Get a User Profile by its Website URL
///
- public Boolean TryGetRepositoryByURL(Uri UserProfile, out IRepository? Repository);
+ public Boolean TryGetRepositoryByURL(Uri URL, out IRepository? Repository);
///
/// Get a User Profile by its Website URL
///
- public IUser GetUserByURL(Uri UserProfile) =>
- TryGetUserByURL(UserProfile, out IUser? user)
+ public IUser GetUserByURL(Uri URL) =>
+ TryGetUserByURL(URL, out IUser? user)
? user!
- : throw new GitObjectNotFoundException(GitReferenceKind.User, UserProfile);
+ : throw new GitObjectNotFoundException(GitReferenceKind.User, URL);
///
/// Attempts to Get a User Profile by its Website URL
///
- public Boolean TryGetUserByURL(Uri UserProfile, out IUser? User);
+ public Boolean TryGetUserByURL(Uri URL, out IUser? User);
}
}
diff --git a/EPS.SDK/Json.cs b/EPS.SDK/Json.cs
index 3ac487c..fa6ff7a 100644
--- a/EPS.SDK/Json.cs
+++ b/EPS.SDK/Json.cs
@@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
-using System.Linq;
-using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Threading;
diff --git a/EPS.SDK/Plugins/Plugin.cs b/EPS.SDK/Plugins/Plugin.cs
index 4b60d1f..fd9b5a3 100644
--- a/EPS.SDK/Plugins/Plugin.cs
+++ b/EPS.SDK/Plugins/Plugin.cs
@@ -9,6 +9,7 @@ using System.Text.Json.Serialization;
namespace ExtensiblePortfolioSite.SDK.Plugins
{
+ internal delegate void PluginUnloadDelegate(Plugin plugin);
internal class Plugin : IPluginManagedLibrary
{
private class PluginLoadContext : AssemblyLoadContext
@@ -42,6 +43,8 @@ namespace ExtensiblePortfolioSite.SDK.Plugins
public Assembly Assembly { get; private set; }
public EPSPluginAttribute Info { get; private set; }
+ public event PluginUnloadDelegate? OnUnloading;
+
public IList Dependents { get; } = new List();
IReadOnlyList IPluginLibrary.References => References.AsReadOnly();
public List References = new();
@@ -58,8 +61,8 @@ namespace ExtensiblePortfolioSite.SDK.Plugins
}
private readonly List JsonConverters = new();
- private readonly List> ResourceContainers = new();
- private readonly List> GitProviders = new();
+ private readonly Dictionary ResourceContainers = new();
+ private readonly Dictionary GitProviders = new();
public void Init()
{
if (Initialized)
@@ -76,8 +79,9 @@ namespace ExtensiblePortfolioSite.SDK.Plugins
if (t.IsAssignableTo(typeof(IGitProvider)) && t.GetConstructor(Type.EmptyTypes) != null)
if (Activator.CreateInstance(t, true) is IGitProvider Provider)
{
- GitManager.Register(GitProviderAttr.ServiceName, Provider);
- GitProviders.Add(new(GitProviderAttr.ServiceName, Provider));
+ GitService Service = GitManager.GetService(GitProviderAttr.ServiceName);
+ GitProviders.Add(Service, Provider);
+ Service.I_AddProvider(this, Provider);
}
else
PluginManager.LogMessage(PluginErrorSeverity.Error, this, "Failed to Instantiate GitProvider", t, null);
@@ -105,13 +109,14 @@ namespace ExtensiblePortfolioSite.SDK.Plugins
{
try
{
+ ResourceContainers.Add(t, ResourceContainerAttr.Schemes);
ResourceManager.Register(t, ResourceContainerAttr.Schemes);
- ResourceContainers.Add(new(t, ResourceContainerAttr.Schemes));
}
catch (Exception ex)
{
- PluginManager.LogMessage(PluginErrorSeverity.Fatal, this, "Faield to Create ResoruceContainer Factory", t, ex);
- throw new Exception("Runtime Unstable!", ex);
+ PluginManager.LogMessage(PluginErrorSeverity.Fatal, this, "Failed to Create ResoruceContainer Factory", t, ex);
+ Console.Error.WriteLine("Runtime Unstable, Exitting!");
+ Environment.Exit(5);
}
}
else
@@ -122,8 +127,10 @@ namespace ExtensiblePortfolioSite.SDK.Plugins
public void Disposing()
{
- foreach (KeyValuePair provider in GitProviders)
- GitManager.Unregister(provider.Key, provider.Value);
+ OnUnloading?.Invoke(this);
+
+ foreach (KeyValuePair provider in GitProviders)
+ provider.Key.I_RemoveProvider(this, provider.Value);
this.GitProviders.Clear();
foreach (KeyValuePair resourceContainer in ResourceContainers)
diff --git a/EPS.SDK/Plugins/PluginManager.cs b/EPS.SDK/Plugins/PluginManager.cs
index 7949be8..403d8ec 100644
--- a/EPS.SDK/Plugins/PluginManager.cs
+++ b/EPS.SDK/Plugins/PluginManager.cs
@@ -55,9 +55,7 @@ namespace ExtensiblePortfolioSite.SDK.Plugins
Directory.CreateDirectory(RootPath);
LibraryPaths.Add(RootPath);
foreach (String Dll in Directory.EnumerateFiles(RootPath, "*.dll", SearchOption.TopDirectoryOnly))
- {
TryLoadPlugin(Path.GetFullPath(Dll, RootPath), out Plugin? _);
- }
}
public static Boolean TryLoadPlugin(string AsmPath, out Plugin? plugin)
{
@@ -380,5 +378,15 @@ namespace ExtensiblePortfolioSite.SDK.Plugins
// we want to throw when its trying to load something we don't explicitly allow!
throw new FileNotFoundException($"Unable to Load Assembly '{Name}'");
}
+
+ internal static Plugin? ResolveTypeToPlugin(Type type)
+ {
+ String fname = type.Assembly.GetName().FullName;
+ lock (_plugins)
+ foreach (Plugin plugin in _plugins)
+ if (plugin.Assembly.GetName().FullName == fname)
+ return plugin;
+ return null;
+ }
}
}
\ No newline at end of file
diff --git a/ExtensiblePortfolioSite/Config.cs b/ExtensiblePortfolioSite/Config.cs
index 650c68b..6ce9208 100644
--- a/ExtensiblePortfolioSite/Config.cs
+++ b/ExtensiblePortfolioSite/Config.cs
@@ -1,6 +1,7 @@
using ExtensiblePortfolioSite.SDK;
+using ExtensiblePortfolioSite.SDK.Caching;
+using ExtensiblePortfolioSite.SDK.Git;
-using System.Text.Json;
using System.Text.Json.Serialization;
namespace ExtensiblePortfolioSite
@@ -111,6 +112,8 @@ namespace ExtensiblePortfolioSite
if (Repository == null) throw new Exception("GitRepo Repository missing!");
if (Description == null) throw new Exception("GitRepo Description missing!");
}
+
+ public IRepository Resolve() => GitManager.GetService(this.ServiceProvider).GetRepository(this.Repository);
}
[Serializable]
@@ -138,10 +141,6 @@ namespace ExtensiblePortfolioSite
[Serializable]
public class Cache
{
- [JsonPropertyName("GitCommit")]
- [JsonIgnore(Condition = JsonIgnoreCondition.Never)]
- public Int32 GitCommit = 30;
-
[JsonPropertyName("GitRepo")]
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public Int32 GitRepo = 120;
@@ -196,6 +195,10 @@ namespace ExtensiblePortfolioSite
Conf = Json.Deserialize(File.ReadAllText(ConfigFile));
if (Conf == null)
throw new Exception("Failed to Load Config!");
+
+ // Load Config
+ Cache.GitUserLifetime = TimeSpan.FromMinutes(Conf.CacheSection.GitUser);
+ Cache.GitRepositoryLifetime = TimeSpan.FromMinutes(Conf.CacheSection.GitRepo);
}
}
}
diff --git a/ExtensiblePortfolioSite/ExtensiblePortfolioSite.csproj b/ExtensiblePortfolioSite/ExtensiblePortfolioSite.csproj
index b2a2be9..2b39b14 100644
--- a/ExtensiblePortfolioSite/ExtensiblePortfolioSite.csproj
+++ b/ExtensiblePortfolioSite/ExtensiblePortfolioSite.csproj
@@ -27,8 +27,12 @@
+
+
+
+
-
+
diff --git a/ExtensiblePortfolioSite/Logging.cs b/ExtensiblePortfolioSite/Logging.cs
index 36ecc0f..1062f14 100644
--- a/ExtensiblePortfolioSite/Logging.cs
+++ b/ExtensiblePortfolioSite/Logging.cs
@@ -25,14 +25,14 @@ namespace ExtensiblePortfolioSite
{
this.Parent = Parent;
this.Identifier = Identifier;
- this.Parent.ScopeStack.AddLast(this);
+ lock (this.Parent.ScopeStack)
+ this.Parent.ScopeStack.AddLast(this);
}
public void Dispose()
{
- // we shouldn't need this but we evidently do...
- // some form of race condition is causing a null ref Exception
- try { this.Parent.ScopeStack.Remove(this); } catch { }
+ lock (this.Parent.ScopeStack)
+ this.Parent.ScopeStack.Remove(this);
}
}
diff --git a/ExtensiblePortfolioSite/Pages/About/Index.cshtml.cs b/ExtensiblePortfolioSite/Pages/About/Index.cshtml.cs
index 7380829..d30d436 100644
--- a/ExtensiblePortfolioSite/Pages/About/Index.cshtml.cs
+++ b/ExtensiblePortfolioSite/Pages/About/Index.cshtml.cs
@@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Mvc.RazorPages;
namespace ExtensiblePortfolioSite.Pages.About
{
+ [ResponseCache(Duration = 60, Location = ResponseCacheLocation.Any, NoStore = false)]
public class AboutModel : PageModel
{
public void OnGet()
diff --git a/ExtensiblePortfolioSite/Pages/Index.cshtml.cs b/ExtensiblePortfolioSite/Pages/Index.cshtml.cs
index 922588a..9290b66 100644
--- a/ExtensiblePortfolioSite/Pages/Index.cshtml.cs
+++ b/ExtensiblePortfolioSite/Pages/Index.cshtml.cs
@@ -1,7 +1,9 @@
-using Microsoft.AspNetCore.Mvc.RazorPages;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Mvc.RazorPages;
namespace ExtensiblePortfolioSite.Pages
{
+ [ResponseCache(Duration = 60, Location = ResponseCacheLocation.Any, NoStore = false)]
public class IndexModel : PageModel
{
private readonly ILogger _logger;
@@ -13,7 +15,7 @@ namespace ExtensiblePortfolioSite.Pages
public void OnGet()
{
-
+
}
}
}
\ No newline at end of file
diff --git a/ExtensiblePortfolioSite/Pages/Projects/Index.cshtml.cs b/ExtensiblePortfolioSite/Pages/Projects/Index.cshtml.cs
index acb0f9f..7a6c01f 100644
--- a/ExtensiblePortfolioSite/Pages/Projects/Index.cshtml.cs
+++ b/ExtensiblePortfolioSite/Pages/Projects/Index.cshtml.cs
@@ -1,7 +1,9 @@
+using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace ExtensiblePortfolioSite.Pages
{
+ [ResponseCache(Duration = 60, Location = ResponseCacheLocation.Any, NoStore = false)]
public class ProjectsModel : PageModel
{
private readonly ILogger _logger;
diff --git a/ExtensiblePortfolioSite/Pages/Socials/Index.cshtml.cs b/ExtensiblePortfolioSite/Pages/Socials/Index.cshtml.cs
index b12b9f0..8d08c0e 100644
--- a/ExtensiblePortfolioSite/Pages/Socials/Index.cshtml.cs
+++ b/ExtensiblePortfolioSite/Pages/Socials/Index.cshtml.cs
@@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Mvc.RazorPages;
namespace ExtensiblePortfolioSite.Pages.Socials
{
+ [ResponseCache(Duration = 60, Location = ResponseCacheLocation.Any, NoStore = false)]
public class SocialsModel : PageModel
{
public void OnGet()
diff --git a/ExtensiblePortfolioSite/Program.cs b/ExtensiblePortfolioSite/Program.cs
index fb95e52..21965de 100644
--- a/ExtensiblePortfolioSite/Program.cs
+++ b/ExtensiblePortfolioSite/Program.cs
@@ -93,12 +93,14 @@ namespace ExtensiblePortfolioSite
// TODO: [Plugin] Web Static Files Provider
// TODO: [Plugin] Web Hook Provider
// TODO: [Plugin] API Endpoint Provider
- // TODO: [Plugin] Standard Cache Provider
// TODO: [Plugin] Reloading/Updating/Disabling
// Add services to the container.
builder.Services.AddRazorPages();
+ // Add Responce Cache
+ builder.Services.AddResponseCaching();
+
var app = builder.Build();
// Configure the HTTP request pipeline.
@@ -115,6 +117,8 @@ namespace ExtensiblePortfolioSite
app.UseRouting();
+ app.UseResponseCaching();
+
//app.UseAuthorization(); // not needed
app.MapRazorPages();
diff --git a/ExtensiblePortfolioSite/Properties/launchSettings.json b/ExtensiblePortfolioSite/Properties/launchSettings.json
index 716fbec..61ba3e5 100644
--- a/ExtensiblePortfolioSite/Properties/launchSettings.json
+++ b/ExtensiblePortfolioSite/Properties/launchSettings.json
@@ -7,6 +7,13 @@
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:58428;http://localhost:58429"
+ },
+ "Docker": {
+ "commandName": "Docker",
+ "launchBrowser": true,
+ "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}",
+ "publishAllPorts": true,
+ "useSSL": true
}
}
}
\ No newline at end of file
diff --git a/ExtensiblePortfolioSite/eps_host_config.json b/ExtensiblePortfolioSite/eps_host_config.json
index 00fa043..9e41d01 100644
--- a/ExtensiblePortfolioSite/eps_host_config.json
+++ b/ExtensiblePortfolioSite/eps_host_config.json
@@ -78,7 +78,6 @@
// Caching Options
"Cache": {
// Lifetimes given in minutes (0 = disabled)
- "GitCommit": 30, //30m
"GitRepo": 120, //2h
"GitUser": 1440 //1d
}
diff --git a/GithubPlugin/GithubProvider.cs b/GithubPlugin/GithubProvider.cs
index 322e33d..9126611 100644
--- a/GithubPlugin/GithubProvider.cs
+++ b/GithubPlugin/GithubProvider.cs
@@ -147,5 +147,6 @@ namespace GithubPlugin
{
return httpClient.GetAsync(resourceLocation).Result;
}
+
}
}
\ No newline at end of file