public BindType(Type t) { //if (CustomSettings.staticClassTypes == null) //{ // Debug.LogError("\nCustomSettings.staticClassTypes is null ! "); // return; //} if (t == null) { throw new NotSupportedException("\nBindType Type is null ! "); } if (typeof(System.MulticastDelegate).IsAssignableFrom(t)) { throw new NotSupportedException(string.Format("\nDon't export Delegate {0} as a class, register it in customDelegateList", LuaMisc.GetTypeName(t))); } //if (IsObsolete(t)) //{ // throw new Exception(string.Format("\n{0} is obsolete, don't export it!", LuaMisc.GetTypeName(t))); //} type = t; nameSpace = ToLuaExport.GetNameSpace(t, out libName); name = ToLuaExport.CombineTypeStr(nameSpace, libName); libName = ToLuaExport.ConvertToLibSign(libName); if (name == "object") { wrapName = "System_Object"; name = "System.Object"; } else if (name == "string") { wrapName = "System_String"; name = "System.String"; } else { wrapName = name.Replace('.', '_'); wrapName = ToLuaExport.ConvertToLibSign(wrapName); } if ((type.IsAbstract && type.IsSealed)) { IsStatic = true; } baseType = LuaMisc.GetExportBaseType(type); }
public BindType(Type t) { // 如果是委托及其衍生类,抛出异常 if (typeof(System.MulticastDelegate).IsAssignableFrom(t)) { throw new NotSupportedException(string.Format("\nDon't export Delegate {0} as a class, register it in customDelegateList", LuaMisc.GetTypeName(t))); } //if (IsObsolete(t)) //{ // throw new Exception(string.Format("\n{0} is obsolete, don't export it!", LuaMisc.GetTypeName(t))); //} type = t; // 获取 type 的命名空间,并将 libName 更新为从完全限定名到命名空间后一位(也就是带'.'字符)的字符 nameSpace = ToLuaExport.GetNameSpace(t, out libName); // 用"."字符拼接参数 space 与 name 为一个字符串并返回 name = ToLuaExport.CombineTypeStr(nameSpace, libName); // 过滤、替换字符串中指定的字符并返回 libName = ToLuaExport.ConvertToLibSign(libName); // 按规律设置 name 和 wrapName 的值 if (name == "object") { wrapName = "System_Object"; name = "System.Object"; } else if (name == "string") { wrapName = "System_String"; name = "System.String"; } else { wrapName = name.Replace('.', '_'); wrapName = ToLuaExport.ConvertToLibSign(wrapName); } // 获取 CustomSettings.staticClassTypes(静态类型)中 type 的 index int index = CustomSettings.staticClassTypes.IndexOf(type); // 如果大等于 0(代表没有这个类型)或 type 是虚类、密封类,设置 IsStatic 为真 if (index >= 0 || (type.IsAbstract && type.IsSealed)) { IsStatic = true; } // 获取导出文件的基类 baseType = LuaMisc.GetExportBaseType(type); }
public BindType(Type t) { if (typeof(System.MulticastDelegate).IsAssignableFrom(t)) { string ex = string.Format("\nDon't export Delegate {0} as a class, register it in customDelegateList", LuaMisc.GetTypeName(t)); throw new NotSupportedException(ex); } if (IsObsolete(t)) { throw new Exception(string.Format("\n{0} is obsolete, don't export it!", LuaMisc.GetTypeName(t))); } type = t; nameSpace = ToLuaExport.GetNameSpace(t, out libName); name = ToLuaExport.CombineTypeStr(nameSpace, libName); libName = ToLuaExport.ConvertToLibSign(libName); if (name == "object") { wrapName = "System_Object"; name = "System.Object"; } else if (name == "string") { wrapName = "System_String"; name = "System.String"; } else { wrapName = name.Replace('.', '_'); wrapName = ToLuaExport.ConvertToLibSign(wrapName); } int index = CustomSettings.staticClassTypes.IndexOf(type); if (index >= 0 || (type.IsAbstract && type.IsSealed)) { IsStatic = true; } baseType = LuaMisc.GetExportBaseType(type); }