protected void GenProperties() { Type type = _bindType.type; //props var propList = type.GetProperties(BindingFlags.GetProperty | BindingFlags.SetProperty | BindingFlags.Instance | BindingFlags.Public | BindingFlags.IgnoreCase | BindingFlags.Static | BindingFlags.DeclaredOnly); var propFilter = new GeneralFilter <PropertyInfo>(propList) .Exclude(new BlackListMemberNameFilter <PropertyInfo>()) .Exclude(new ObsoleteFilter <PropertyInfo>()); propFilter.Each(GenProperty); //fields var fields = type.GetFields(BindingFlags.GetField | BindingFlags.SetField | BindingFlags.Instance | BindingFlags.Public | BindingFlags.Static); var fieldFilter = new GeneralFilter <FieldInfo>(fields) .Exclude(new BlackListMemberNameFilter <FieldInfo>()) .Exclude(new ObsoleteFilter <FieldInfo>()); fieldFilter.Each(GenField); //events var events = type.GetEvents(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.Static); var evtFilter = new GeneralFilter <EventInfo>(events) .Exclude(new BlackListMemberNameFilter <EventInfo>()) .Exclude(new ObsoleteFilter <EventInfo>()); evtFilter.Each(GenEvent); }
public static void DoIt() { Filter <Type> baseFilter = new GeneralFilter <Type> (ToLuaMenu.baseType); Filter <Type> dropFilter = new GeneralFilter <Type> (ToLuaMenu.dropType); string dirPath = "LuaAPI"; if (Directory.Exists(dirPath)) { Directory.Delete(dirPath, true); } var directory = Directory.CreateDirectory(dirPath); var collection = new BindTypeCollection(CustomSettings.customTypeList); var bindTypes = collection.CollectBindType(baseFilter, dropFilter); foreach (var bindType in bindTypes) { var generator = new LuaAPIGenerator(); generator.Gen(bindType); } string[] removes = { "/View.lua" }; for (int i = 0; i < removes.Length; i++) { if (File.Exists(directory.FullName + removes [i])) { File.Delete(directory.FullName + removes [i]); } } Debug.LogFormat("API 生成完毕. {0}", directory.FullName); }
protected void GenMethods() { var flags = BindingFlags.Public | BindingFlags.Static | BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.DeclaredOnly; Dictionary <string, MethodDataSet> allMethods = new Dictionary <string, MethodDataSet>(); Action <MethodInfo, bool> methodCollector = (mi, isExtend) => { MethodDataSet set; if (allMethods.TryGetValue(mi.Name, out set)) { set.Add(mi, isExtend); } else { set = new MethodDataSet(); set.Add(mi, isExtend); allMethods.Add(mi.Name, set); } }; //extend if (_bindType.extendList != null) { foreach (var type in _bindType.extendList) { MethodInfo[] methodInfos = type.GetMethods(flags); var extFilter = new GeneralFilter <MethodInfo>(methodInfos) .Exclude(methodExcludeFilter) .And(new ExtendMethodFilter(_bindType.type)); extFilter.Each(mi => { methodCollector(mi, true); }); } } //base var methods = _bindType.type.GetMethods(flags); var filter = new GeneralFilter <MethodInfo>(methods); var methodFilter = filter.Exclude(methodExcludeFilter); methodFilter.Each(mi => { methodCollector(mi, false); }); foreach (var pair in allMethods) { GenMethod(pair.Key, pair.Value); } }
static void DoIt() { Filter <Type> baseFilter = new GeneralFilter <Type>(ToLuaMenu.baseType); Filter <Type> dropFilter = new GeneralFilter <Type>(ToLuaMenu.dropType); var collection = new BindTypeCollection(CustomSettings.customTypeList); var bindTypes = collection.CollectBindType(baseFilter, dropFilter); foreach (var bindType in bindTypes) { var generator = new LuaAPIGenerator(); generator.Gen(bindType); } }
static void DoIt() { Filter <Type> baseFilter = new GeneralFilter <Type>(ToLuaMenu.baseType); Filter <Type> dropFilter = new GeneralFilter <Type>(ToLuaMenu.dropType); var directory = Directory.CreateDirectory("LuaAPI"); var collection = new BindTypeCollection(CustomSettings.customTypeList); var bindTypes = collection.CollectBindType(baseFilter, dropFilter); foreach (var bindType in bindTypes) { var generator = new LuaAPIGenerator(); generator.Gen(bindType); } Debug.LogFormat("API 生成完毕. {0}", directory.FullName); }