Exemple #1
0
        private void AddContainer(Type type, ContainerAttribute attrContainer, bool isNew = false)
        {
            var logger = new UnitLogger("IocManager");

            if (type.GetInterfaces().Where(p => p.FullName == attrContainer.BaseType.FullName).Count() == 0 && type.BaseType != attrContainer.BaseType)
            {
                logger.Error($"类型{type.FullName}没有继承自{attrContainer.BaseType.FullName},无法注册到容器");
            }
            else
            {
                var key = new ContainerKey(attrContainer.ModuleName, attrContainer.BaseType.FullName);
                if (ContainerDic.Keys.Contains(key))
                {
                    if (isNew)
                    {
                        ContainerDic.Remove(key);
                    }
                    else
                    {
                        logger.Warn($"类型:{type.FullName},模块:{attrContainer.ModuleName},继承自{attrContainer.BaseType.FullName},已经注册到容器,无法再次注册");
                    }
                }
                var args = new ContainerArgs(type, attrContainer);
                logger.Info($"类型:{type.FullName},模块:{attrContainer.ModuleName},继承自{attrContainer.BaseType.FullName},成功注册到容器");
                ContainerDic.Add(key, args);
            }
        }
Exemple #2
0
        static void Main(string[] args)
        {
            var a = new temp();
            var b = (temp)a.CloneReflection();

            Console.WriteLine(b.getta(fuckc.a | fuckc.c));
            b.index = 2;
            Console.Write(a.index);
            var sw = new Stopwatch();

            while (true)
            {
                sw.Reset();
                sw.Start();
                var testLog = new UnitLogger("testLog");//Logger.GetLogger("testLog");

                testLog.Info("fukc");
                sw.Stop();
                Console.WriteLine(sw.ElapsedMilliseconds);
                //InvokeWebService("http://localhost:8057/User", "", "", null);
                Thread.Sleep(1000);
            }
        }