コード例 #1
0
        /***************************************************/
        /**** Private Methods                           ****/
        /***************************************************/

        private static void ExtractAllMethods()
        {
            Compute.LoadAllAssemblies();

            m_BHoMMethodList = new List <MethodInfo>();
            m_AllMethodList  = new List <MethodBase>();
            m_EngineTypeList = new List <Type>();

            BindingFlags bindingBHoM = BindingFlags.Public | BindingFlags.DeclaredOnly | BindingFlags.Static;

            foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies())
            {
                try
                {
                    // Save BHoM objects only
                    string name = asm.GetName().Name;
                    if (name.EndsWith("_Engine"))
                    {
                        foreach (Type type in asm.GetTypes())
                        {
                            // Get only the BHoM methods
                            if (!type.IsInterface && type.IsAbstract)
                            {
                                MethodInfo[] typeMethods = type.GetMethods(bindingBHoM);
                                m_BHoMMethodList.AddRange(typeMethods.Where(x => x.IsLegal()));
                            }

                            if (type.Name == "External")
                            {
                                MethodInfo getExternalMethods = type.GetMethod("Methods");
                                if (getExternalMethods != null)
                                {
                                    m_ExternalMethodList.AddRange((List <MethodInfo>)getExternalMethods.Invoke(null, null));
                                }
                                MethodInfo getExternalCtor = type.GetMethod("Constructors");
                                if (getExternalCtor != null)
                                {
                                    m_ExternalMethodList.AddRange((List <ConstructorInfo>)getExternalCtor.Invoke(null, null));
                                }
                            }
                            // Get everything
                            StoreAllMethods(type);
                        }
                    }
                    else if (name.EndsWith("oM") || name.EndsWith("_Adapter") || name.EndsWith("_UI") || name.EndsWith("_Test"))
                    {
                        foreach (Type type in asm.GetTypes())
                        {
                            StoreAllMethods(type);
                        }
                    }
                }
                catch (Exception)
                {
                    Compute.RecordWarning("Cannot load types from assembly " + asm.GetName().Name);
                }
            }
        }