Reorganizes Project (#41)

This commit is contained in:
Kamron Batman 2019-08-02 18:13:40 -07:00 • committed by GitHub
parent 08bf44af9a
commit 3614a66aee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3499 changed files with 79 additions and 55 deletions

View file

@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
namespace Server.Engines.MLQuests
{
[AttributeUsage(AttributeTargets.Class)]
public class QuesterNameAttribute : Attribute
{
private static readonly Type m_Type = typeof(QuesterNameAttribute);
private static readonly Dictionary<Type, string> m_Cache = new Dictionary<Type, string>();
public QuesterNameAttribute(string questerName)
{
QuesterName = questerName;
}
public string QuesterName{ get; }
public static string GetQuesterNameFor(Type t)
{
if (t == null)
return "";
if (m_Cache.TryGetValue(t, out string result))
return result;
object[] attributes = t.GetCustomAttributes(m_Type, false);
return m_Cache[t] = attributes.Length != 0 ? ((QuesterNameAttribute)attributes[0]).QuesterName : t.Name;
}
}
}