Ejemplo n.º 1
0
        public static object CreateInstance(string typeFullName, BindingFlags bindingAttr = BindingFlags.CreateInstance, object[] args = null)
        {
            if (string.IsNullOrEmpty(typeFullName))
            {
                throw new ArgumentNullException("typeFullName");
            }

            Type type = ProjectAssemblies.GetType(typeFullName);

            return(ReflectionUtil.CreateInstance(type, bindingAttr, args));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Invokes the static method.
        /// </summary>
        /// <param name="typeName">Name of the type.</param>
        /// <param name="methodName">Name of the method.</param>
        /// <param name="parameters">The parameters.</param>
        /// <returns>The object of method return.</returns>
        public static object InvokeStaticMethod(string typeName,
                                                string methodName,
                                                object[] parameters = null)
        {
            Type type = ProjectAssemblies.GetType(typeName);

            if (type != null)
            {
                return(ReflectionUtil.InvokeStaticMethod(type, methodName, parameters));
            }

            return(null);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Generates the database files.
        /// </summary>
        private static void GenerateDBFiles()
        {
            string path            = ExcelFilesPath;
            string namespaceString = GetNamespace();

            DeleteOldDBFiles();

            ForEachExcelFile(path, (DataTable table, string fileName, int index, int length) =>
            {
                EditorUtility.DisplayProgressBar(importProgressBarTitle,
                                                 string.Format(savingDataProgressBarInfo, fileName, index + 1, length), (float)(index + 1) / length);
                List <DataTableRowInfo> rowInfos = GenerateDataTableRowInfos(table);
                List <DataTableRow> collection   = GenerateDataTableRowCollection(table, namespaceString, fileName, rowInfos);

                string classFullName = string.Format("{0}.{1}", namespaceString, fileName);
                Type type            = ProjectAssemblies.GetType(classFullName);

                if (type != null)
                {
                    ReflectionUtil.InvokeStaticGenericMethod(typeof(DataImport),
                                                             "SaveData",
                                                             type,
                                                             new object[] { fileName, rowInfos, collection, index });
                }
                else
                {
                    Debug.LogErrorFormat(null, "Can not find the Type: {0}", classFullName);
                }
            });

            DeleteDBConfigFiles();
            RenameDBFiles();
            AssetDatabase.Refresh();
            AssetDatabase.SaveAssets();
            EditorUtility.ClearProgressBar();
            QuickUnityEditorApplication.DisplaySimpleDialog("", DialogMessages.DataImportDoneMessage);
        }