init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
49
Framework/Entities/EntityAttributeCache.cs
Normal file
49
Framework/Entities/EntityAttributeCache.cs
Normal file
|
@ -0,0 +1,49 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
|
||||
namespace Kreta.Framework.Entities
|
||||
{
|
||||
internal static class EntityAttributeCache
|
||||
{
|
||||
private static Hashtable m_EntityAttributeCache = new Hashtable();
|
||||
|
||||
/// <summary>
|
||||
/// Visszaadja az entitás nevét a rajta lévő <see cref="EntityAttribute"/> attribútum alapján.
|
||||
/// </summary>
|
||||
/// <param name="entityType">Az entitás típusa</param>
|
||||
/// <returns>Az entitás neve, ha van <see cref="EntityAttribute"/> attribútuma; egyébként 'Ismeretlen'</returns>
|
||||
private static string GetEntityName(Type entityType)
|
||||
{
|
||||
EntityAttribute[] attributes = (EntityAttribute[])entityType.GetCustomAttributes(typeof(EntityAttribute), true);
|
||||
if (attributes.Length > 0)
|
||||
{
|
||||
return attributes[0].Name;
|
||||
}
|
||||
|
||||
if (entityType.BaseType != null)
|
||||
{
|
||||
return GetEntityName(entityType.BaseType);
|
||||
}
|
||||
|
||||
return "Ismeretlen";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Visszaadja az entitás nevét, cache-elve
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Az entitás nevét a rajta lévő <see cref="EntityAttribute"/> attribútum definiálja.
|
||||
/// A névnek rendszer szinten egyedinek kell lennie.
|
||||
/// </remarks>
|
||||
internal static string GetEntityNameFromCache(Type entityType)
|
||||
{
|
||||
string result = m_EntityAttributeCache[entityType] as string;
|
||||
if (result == null)
|
||||
{
|
||||
result = GetEntityName(entityType);
|
||||
m_EntityAttributeCache[entityType] = result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue