c#反射应用

static void TestReflect() 
        {
            DirectoryInfo dir = new DirectoryInfo("dll");
            FileInfo[] fiArr=dir.GetFiles();
            for (int i = 0; i < fiArr.Length; i++)
            {
                FileInfo info=fiArr[i];
                Assembly asm = Assembly.LoadFrom(info.FullName);
                String className = info.Name.Replace(".dll", "") + ".IPCrawler";
                IProxyIP.IIP iip = (IProxyIP.IIP)asm.CreateInstance(className);

                List<ProxyIP> list= iip.GetIPList();
                foreach (var item in list)
                {
                    Console.WriteLine(item);
                }                
            }
            Console.WriteLine();
        }

 

posted on 2013-04-18 12:36  雨渐渐  阅读(103)  评论(0编辑  收藏  举报

导航