Example #1
0
        static (string, string) GetNames(DataTableProcessor.DataProcessor t1, DataTableProcessor.DataProcessor t2)
        {
            string t1Name = t1.IsEnum ? t1.LanguageKeyword : t1.Type.Name;
            string t2Name = t2.IsEnum ? t2.LanguageKeyword : t2.Type.Name;

            return(t1Name, t2Name);
        }
Example #2
0
        private static void GenerateExtension()
        {
            IDictionary <string, DataTableProcessor.DataProcessor> datableDataProcessors =
                new SortedDictionary <string, DataTableProcessor.DataProcessor>();
            IDictionary <string, DataTableProcessor.DataProcessor> binaryReaderDataProcessors =
                new SortedDictionary <string, DataTableProcessor.DataProcessor>();
            var dataProcessorBaseType = typeof(DataTableProcessor.DataProcessor);
            var types = GetTypeNames(dataProcessorBaseType);

            for (var i = 0; i < types.Count; i++)
            {
                if (!types[i].IsClass || types[i].IsAbstract || types[i].ContainsGenericParameters)
                {
                    continue;
                }

                if (dataProcessorBaseType.IsAssignableFrom(types[i]))
                {
                    DataTableProcessor.DataProcessor dataProcessor = null;
                    dataProcessor = (DataTableProcessor.DataProcessor)Activator.CreateInstance(types[i]);
                    if (dataProcessor.IsComment || dataProcessor.IsId || dataProcessor.IsEnum)
                    {
                        continue;
                    }
                    datableDataProcessors.Add(dataProcessor.LanguageKeyword, dataProcessor);
                }
            }

            AddEnumType(datableDataProcessors);
            NameSpaces.Add("System");
            NameSpaces.Add("System.IO");
            NameSpaces.Add("System.Collections.Generic");
            NameSpaces.Add("UnityEngine");
            NameSpaces = NameSpaces.Distinct().ToList();
            GenerateDataTableExtensionArray(datableDataProcessors);
            GenerateDataTableExtensionList(datableDataProcessors);
            GenerateBinaryReaderExtensionList(datableDataProcessors);
            GenerateBinaryReaderExtensionArray(datableDataProcessors);
            GenerateDataTableExtensionDictionary(datableDataProcessors);
            GenerateBinaryReaderExtensionDictionary(datableDataProcessors);
            AssetDatabase.Refresh();
        }
Example #3
0
        private static void AddEnumType(IDictionary <string, DataTableProcessor.DataProcessor> dataProcessors)
        {
            Type enumProcessorTypeBase = Type.GetType("DE.Editor.DataTableTools.DataTableProcessor+EnumProcessor`1");

            foreach (var assemblyName in AssemblyNames)
            {
                Assembly assembly = null;
                try
                {
                    assembly = Assembly.Load(assemblyName);
                }
                catch
                {
                    continue;
                }

                if (assembly == null)
                {
                    continue;
                }

                var types = assembly.GetTypes();
                foreach (var type in types)
                {
                    if (type.IsEnum)
                    {
                        Type enumProcessorType = enumProcessorTypeBase.MakeGenericType(type);
                        DataTableProcessor.DataProcessor dataProcessor =
                            (DataTableProcessor.DataProcessor)Activator.CreateInstance(enumProcessorType);
                        dataProcessors.Add(dataProcessor.LanguageKeyword, dataProcessor);
                        string nameSpace = dataProcessor.GetType().GetProperty("NameSpace")
                                           ?.GetValue(dataProcessor) as string;
                        if (!string.IsNullOrEmpty(nameSpace))
                        {
                            NameSpaces.Add(nameSpace);
                        }
                    }
                }
            }
        }