public static void Init(string @namespace, Assembly assembly)
    {
        List <Type> ls = ClassUtil.GetClasses(@namespace, assembly);

        foreach (Type item in ls)
        {
            ProtoAttribute arr = (ProtoAttribute)ClassUtil.GetAttribute(item, typeof(ProtoAttribute));
            if (arr != null)
            {
                if (arr.response && !typeMapping.ContainsKey(arr.value))
                {
                    typeMapping.Add(arr.value, item);
                }
                cmdMapping.Add(item, arr.value);
            }
        }
    }
Esempio n. 2
0
    // Use this for initialization
    void Awake()
    {
        messageQueue = new Queue <QueueItem>();
        errorQueue   = new Queue <QueueItem>();
        typeMapping  = new Dictionary <short, Type>();
        cmdMapping   = new Dictionary <Type, short>();
        List <Type> ls = ClassUtil.GetClasses("protocol");

        foreach (Type item in ls)
        {
            ProtoAttribute arr = (ProtoAttribute)ClassUtil.GetAttribute(item, typeof(ProtoAttribute));
            if (arr != null)
            {
                typeMapping.Add((short)arr.value, item);
                cmdMapping.Add(item, (short)arr.value);
            }
        }
    }