Merge branch 'main' of https://git.bibko.uk/Pasha/Pacore
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace PashaBibko.Pacore
|
namespace PashaBibko.Pacore
|
||||||
@@ -9,6 +10,15 @@ namespace PashaBibko.Pacore
|
|||||||
public static class ClassAttributeCache
|
public static class ClassAttributeCache
|
||||||
{
|
{
|
||||||
private static Dictionary<Type, List<Type>> AttributeCache { get; set; }
|
private static Dictionary<Type, List<Type>> AttributeCache { get; set; }
|
||||||
|
private static DelegateFunction OnCacheInstantiated = LogCacheInformation;
|
||||||
|
|
||||||
|
private static int AttributeCount;
|
||||||
|
private static int ClassCount;
|
||||||
|
private static long TimeTaken;
|
||||||
|
|
||||||
|
private static void LogCacheInformation()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public static ReadOnlyCollection<Type> GetAttributesOf<T>()
|
public static ReadOnlyCollection<Type> GetAttributesOf<T>()
|
||||||
{
|
{
|
||||||
@@ -20,6 +30,8 @@ namespace PashaBibko.Pacore
|
|||||||
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterAssembliesLoaded)]
|
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterAssembliesLoaded)]
|
||||||
private static void ScanAllAssemblies()
|
private static void ScanAllAssemblies()
|
||||||
{
|
{
|
||||||
|
Stopwatch timer = Stopwatch.StartNew();
|
||||||
|
|
||||||
/* Fetches all the class types in all loaded assemblies */
|
/* Fetches all the class types in all loaded assemblies */
|
||||||
Type[] classes = AppDomain.CurrentDomain.GetAssemblies() // Assembly[]
|
Type[] classes = AppDomain.CurrentDomain.GetAssemblies() // Assembly[]
|
||||||
.SelectMany(assembly => assembly.GetTypes()) // IEnumerable<Type>
|
.SelectMany(assembly => assembly.GetTypes()) // IEnumerable<Type>
|
||||||
@@ -52,6 +64,14 @@ namespace PashaBibko.Pacore
|
|||||||
AttributeCache[type].Add(current);
|
AttributeCache[type].Add(current);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Stores all relevant info for logging */
|
||||||
|
TimeTaken = timer.ElapsedMilliseconds;
|
||||||
|
AttributeCount = AttributeCache.Count;
|
||||||
|
ClassCount = classes.Length;
|
||||||
|
|
||||||
|
/* Calls the delegate function for any dependencies */
|
||||||
|
OnCacheInstantiated.Invoke();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
4
Assets/Pacore/Runtime/DelegateFunction.cs
Normal file
4
Assets/Pacore/Runtime/DelegateFunction.cs
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
namespace PashaBibko.Pacore
|
||||||
|
{
|
||||||
|
public delegate void DelegateFunction();
|
||||||
|
}
|
||||||
3
Assets/Pacore/Runtime/DelegateFunction.cs.meta
Normal file
3
Assets/Pacore/Runtime/DelegateFunction.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 627efc92baea4fec9e576642408e796c
|
||||||
|
timeCreated: 1769701523
|
||||||
Reference in New Issue
Block a user