Пример #1
0
 public void Close()
 {
     IsClose = true;
     AsyncWaitTimeOut.Clear();
     ClientManager.Close();
     Module.ModuleDiy.Clear();
     AsyncRunDiy.Clear();
     CallBackDiy.Clear();
     AsyncCallDiy.Clear();
     SyncWaitDic.Clear();
     FodyDir.Clear();
     Container.Dispose();
 }
Пример #2
0
        /// <summary>
        /// Need Nuget Install-Package Fody
        /// And Add xml file 'FodyWeavers.xml' to project
        /// context:
        /// \<?xml version="1.0" encoding="utf-8" ?\>
        /// \<Weavers\>
        /// \<Virtuosity\/\>
        /// \</Weavers\>
        ///
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public T Get <T>()
        {
            var interfaceType = typeof(T);

            if (!FodyDir.ContainsKey(interfaceType))
            {
                var assembly           = interfaceType.Assembly;
                var implementationType = assembly.GetType(interfaceType.FullName + "_Builder_Implementation");
                if (implementationType == null)
                {
                    throw new FodyInstallException("not find with {interfaceType.FullName} the Implementation", (int)ErrorTag.FodyInstallErr);
                }
                FodyDir.Add(interfaceType, implementationType);
                return((T)Activator.CreateInstance(implementationType, new Func <int, Type, object[], object>(Call)));
            }
            else
            {
                return((T)Activator.CreateInstance(FodyDir[interfaceType], new Func <int, Type, object[], object>(Call)));
            }
        }