public TypeBindingInfo(BindingManager bindingManager, Type type, TypeBindingFlags bindingFlags) { this.bindingManager = bindingManager; this.type = type; this.bindingFlags = bindingFlags; this.transform = bindingManager.GetTypeTransform(type); var naming = this.transform?.GetTypeNaming() ?? GetNamingAttribute(type); var indexOfTypeName = naming.LastIndexOf('.'); if (indexOfTypeName >= 0) // 内部类 { this.jsNamespace = naming.Substring(0, indexOfTypeName); this.jsName = naming.Substring(indexOfTypeName + 1); } else { if (type.DeclaringType != null) { if (string.IsNullOrEmpty(type.Namespace)) { this.jsNamespace = type.DeclaringType.Name; } else { this.jsNamespace = $"{type.Namespace}.{type.DeclaringType.Name}"; } } else { this.jsNamespace = type.Namespace ?? ""; } if (type.IsGenericType) { this.jsName = naming.Substring(0, naming.IndexOf('`')); foreach (var gp in type.GetGenericArguments()) { this.jsName += "_" + gp.Name; } } else { this.jsName = naming; } } this.name = bindingManager.prefs.typeBindingPrefix + (this.jsNamespace + "_" + this.jsName).Replace('.', '_').Replace('+', '_').Replace('<', '_').Replace('>', '_'); this.constructors = new ConstructorBindingInfo(type); }
public ConstructorCodeGen(CodeGenerator cg, TypeBindingInfo bindingInfo) : base(cg) { // WriteInstanceEvents(bindingInfo); this.bindingInfo = bindingInfo.constructors; if (this.bindingInfo.count > 0) { WriteAllVariants(this.bindingInfo); WriteTSAllVariants(this.bindingInfo); } else { WriteDefaultConstructorBinding(); } }