反射

   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);
                           
                        }
                    }
                }
            }

你可能感兴趣的:(反射)