| | |
| | | } |
| | | } |
| | | |
| | | // 基础泛型版本 |
| | | public static string Get<T1>(string _id, T1 arg1) |
| | | { |
| | | var content = Get(_id); |
| | | try |
| | | { |
| | | // 使用泛型可以避免装箱,编译器会为值类型生成特化版本 |
| | | return string.Format(content, arg1); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Debug.LogFormat("语言内容格式错误,id: {0}", _id); |
| | | return content; |
| | | } |
| | | } |
| | | |
| | | public static string Get<T1, T2>(string _id, T1 arg1, T2 arg2) |
| | | { |
| | | var content = Get(_id); |
| | | try |
| | | { |
| | | return string.Format(content, arg1, arg2); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Debug.LogFormat("语言内容格式错误,id: {0}", _id); |
| | | return content; |
| | | } |
| | | } |
| | | |
| | | // 继续扩展更多参数... |
| | | public static string Get<T1, T2, T3>(string _id, T1 arg1, T2 arg2, T3 arg3) |
| | | { |
| | | var content = Get(_id); |
| | | try |
| | | { |
| | | return string.Format(content, arg1, arg2, arg3); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Debug.LogFormat("语言内容格式错误,id: {0}", _id); |
| | | return content; |
| | | } |
| | | } |
| | | |
| | | public static string Get<T1, T2, T3, T4>(string _id, T1 arg1, T2 arg2, T3 arg3, T4 arg4) |
| | | { |
| | | var content = Get(_id); |
| | | try |
| | | { |
| | | return string.Format(content, arg1, arg2, arg3, arg4); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Debug.LogFormat("语言内容格式错误,id: {0}", _id); |
| | | return content; |
| | | } |
| | | } |
| | | |
| | | public static string Get<T1, T2, T3, T4, T5>(string _id, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) |
| | | { |
| | | var content = Get(_id); |
| | | try |
| | | { |
| | | return string.Format(content, arg1, arg2, arg3, arg4, arg5); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Debug.LogFormat("语言内容格式错误,id: {0}", _id); |
| | | return content; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | public static string GetFromLocal(int _id) |
| | | { |
| | | var languageInfo = PriorLanguageConfig.Get(_id); |