示例#1
0
    /// <summary>
    /// 获取协议数据对象,如果没缓存,则返回null
    /// 注意:这个是给PB用的
    /// </summary>
    /// <param name="protoType"></param>
    /// <returns></returns>
    public static object Get(Type protoType)
    {
        object     protoData = null;
        IProtoPool pool      = null;

        if (poolMap.TryGetValue(protoType, out pool))
        {
            protoData = pool.Get();
        }
        return(protoData);
    }
示例#2
0
    public static void AddProtoPool(Type protoType, IProtoPool protoPool)
    {
#if UNITY_EDITOR
        if (poolMap.ContainsKey(protoType))
        {
            throw new Exception(string.Format("poolMap already contains key <{0}>!", protoType));
        }
        if (protoPool == null)
        {
            throw new ArgumentNullException("protoPool");
        }
#endif
        if (!poolMap.ContainsKey(protoType))
        {
            poolMap.Add(protoType, protoPool);
        }
    }