com.alicizax.unity.framework/Runtime/UI/Constant/UIMetadataFactory.cs
2025-09-05 19:46:30 +08:00

34 lines
877 B
C#

using System;
using System.Collections.Generic;
using AlicizaX;
namespace AlicizaX.UI.Runtime
{
internal static class MetaTypeCache<T> where T : UIBase
{
public static readonly UIMetadata Metadata;
static MetaTypeCache()
{
var type = typeof(T);
Metadata = UIMetadataFactory.GetMetadata(type.TypeHandle);
}
}
internal static class UIMetadataFactory
{
private static readonly Dictionary<RuntimeTypeHandle, UIMetadata> UIWindowMetadata = new();
internal static UIMetadata GetMetadata(RuntimeTypeHandle handle)
{
if (!UIWindowMetadata.TryGetValue(handle, out var meta))
{
meta = new UIMetadata(Type.GetTypeFromHandle(handle));
UIWindowMetadata[handle] = meta;
}
return meta;
}
}
}