Пример #1
0
 public void Dispose()
 {
     if (m_LightBind != null)
     {
         LightBindEntry.Return(m_Type, m_LightBind);
         m_LightBind = null;
     }
 }
Пример #2
0
 public IBindable Resolve()
 {
     if (m_LightBind == null)
     {
         m_LightBind = LightBindEntry.Get(m_Type);
         m_LightBind.Init(m_Target, m_Path);
     }
     return(m_LightBind as IBindable);
 }
Пример #3
0
        public static void Register <T>(int maxPoolCount = 64) where T : ILightBind, new()
        {
            var key = ToKey(typeof(T));

            if (!s_Dic.TryGetValue(key, out var entry))
            {
                s_Dic[key]     = entry = new LightBindEntry();
                entry.TypeName = key;
                entry.Type     = typeof(T);
            }
            entry.m_Instantiate  = () => new T();
            entry.m_MaxPoolCount = maxPoolCount;
        }
Пример #4
0
        public static LightBindEntry GetEntry(string key)
        {
            LightBindEntry entry;

            if (s_Dic.TryGetValue(key, out entry))
            {
                return(entry);
            }
            var assemblies = s_Assemblies ?? (s_Assemblies = AppDomain.CurrentDomain.GetAssemblies());
            var type       = assemblies.Select(x => x.GetType(key)).FirstOrDefault(x => x != null);

            s_Dic[key]          = entry = new LightBindEntry();
            entry.m_Instantiate = () => System.Activator.CreateInstance(type) as ILightBind;
            entry.Type          = type;
            entry.TypeName      = key;
            return(entry);
        }