反射

   Assembly importAssembly = Assembly.LoadFrom(@"D:\testProject\WindowsApplication1\DBAccess\bin\Debug\DBHelper.dll");
            Module[] importModules = importAssembly.GetModules();
            foreach (Module importModule in importModules)
            {
                Type[] importClasses = importModule.GetTypes();
                foreach (Type importClass in importClasses)
                {
                    MethodInfo[] importMethods =importClass.GetMethods();
                    foreach (MethodInfo importMethod in importMethods)
                    {
                       
                        if (importMethod.Name.Contains("RetrieveDataTable"))
                        {
                            string[] ary = new string[] { @"SELECT  top 10
                                    [FileName],
                                    '\\cndminputfs11\DataManagerXML\SEC\Filing\edgar\data\'+
                                    cast((CIK / 10000) * 10000 as varchar(10)) + '\' +
                                    cast(CIK as varchar(10)) + '\' as Path
                                    FROM dbo.Form13F f
                                    INNER JOIN dbo.SECEdgar s
                                    ON f.FilingId=s.FilingId
                                    where EffectiveDate > '2010-10-01'" };
                           
                            DataTable dt =(DataTable)importClass.InvokeMember("RetrieveDataTable", BindingFlags.Public | BindingFlags.Static | BindingFlags.InvokeMethod,null,null,ary);
                           
                        }
                    }
                }
            }

posted on 2011-02-24 13:30  Gsun  阅读(184)  评论(0编辑  收藏  举报

导航