public void createSubConstructors() { var subTypes = Generator.findByBaseType(name); foreach (var subType in subTypes) { var subCTorMemList = new TMemberList(); foreach (var baseMember in members) { if (baseMember.name == "ctor") { var baseCTor = (baseMember as TMethod); if (baseCTor.parameters.Count > 0) { var subCTor = new TMethod(subType); subCTor.name = baseCTor.name; subCTor.resultType = baseCTor.resultType; subCTor.baseMethod = baseCTor; subCTorMemList.Add(subCTor); } } } if (subCTorMemList.Count > 0) { subType.members.InsertRange(0, subCTorMemList); } } }
public void generateConstructors() { var memList = new TMemberList(); foreach (var attr in attributes) { if (attr is TConstructorAttribute) { var ctorAttr = attr as TConstructorAttribute; memList.Insert(0, ctorAttr.constructor); } } if (memList.Count == 0) { //if (name.StartsWith("Html") && name.EndsWith("Element")) // tryCreateElementMethod(memList, name.Substring(0, name.Length - ("Element".Length)).Substring("Html".Length).ToLower(), name); //if (name.StartsWith("Svg") && name.EndsWith("Element")) // tryCreateElementMethod(memList, name.Substring(0, name.Length - ("Element".Length)).Substring("Svg".Length).ToLower(), name); foreach (var entry in TransformationConfig.generateElementConstructor) { if (name.StartsWith(entry.Item1) && name.EndsWith(entry.Item2)) { tryCreateElementMethod(memList, name.Substring(0, name.Length - (entry.Item2.Length)).Substring(entry.Item1.Length).ToLower(), name); } } } if (memList.Count != 0) { members.InsertRange(0, memList); //createSubConstructors(); } }
private void tryCreateElementMethod(TMemberList memList, string tagName, string typeName) { var mem = createElementMethod(tagName, typeName); if (mem != null) { memList.Add(mem); } }
public void checkProp() { TMemberList memList = new TMemberList(); memList.AddRange(members); foreach (TMember mem in memList) { if (mem is TMethod) { TMethod func = (TMethod)mem; if ((func.name.StartsWith("get") && func.parameters.Count == 0) || (func.name == "item" || func.name == "namedItem")) { if (func.name == "item" || func.name == "namedItem") { TProperty prop = new TProperty(this); prop.name = "this"; prop.Parameters.AddRange(func.parameters); prop.resultType = func.resultType; prop.canRead = true; int idx = members.IndexOf(func); members[idx] = prop; } else { //string n1 = func.Name.Substring(3); //var propName = char.ToLower(n1[0]).ToString() + n1.Substring(1); //TProperty prop = new TProperty(); //prop.Name = propName; //prop.resultType = func.resultType; //prop.canRead = true; //int idx = Members.IndexOf(func); //Members[idx] = prop; //TMethod setMem = (TMethod)Members.Find("set" + n1); //if (setMem != null) { // prop.canWrite = true; // Members.Remove(setMem); //} } } } } }