public void convertToInterface() { if (isInterface) { return; } isInterface = true; for (var i = 0; i < members.Count; i++) { var mem = members[i]; if (mem is TField) { var prop = new TProperty(this); prop.name = mem.name; //prop.modifier = ""; prop.resultType = mem.resultType; prop.canWrite = false; members[i] = prop; } else { //mem.modifier = ""; } } }
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); //} } } } } }
private TMember readMember() { bool vStatic = false; bool vConst = false; bool vFinal = false; bool vReadonly = false; bool vAttribute = false; TType type = null; string name = ""; TMember mem = null; var attrList = new TAttributeList(); while (true) { switch (currentToken.token) { case ECodeToken.brSmallBraceBegin: attrList = readAttributes(); break; case ECodeToken.kwStatic: vStatic = true; getNextToken(); break; case ECodeToken.kwConst: vConst = true; getNextToken(); break; case ECodeToken.kwAttribute: vAttribute = true; getNextToken(); break; case ECodeToken.kwReadonly: vReadonly = true; getNextToken(); break; //case ECodeToken.kwFinal: // vFinal = true; // break; case ECodeToken.ltString: type = readType(); name = currentToken.value; getNextToken(); if (currentToken.token == ECodeToken.brBraceBegin) { mem = new TMethod(currentInterfaceType); mem.name = name; mem.resultType = type; mem.attributes = attrList; readParameters((TMethod)mem); checkGotoEndOfStatement(); } else { if (vAttribute) { mem = new TProperty(currentInterfaceType); mem.name = name; mem.resultType = type; mem.attributes = attrList; var prop = (TProperty)mem; prop.canWrite = !vReadonly; checkGotoEndOfStatement(); return(mem); } else { mem = new TField(currentInterfaceType); mem.name = name; mem.resultType = type; mem.attributes = attrList; if (currentToken.token == ECodeToken.blEquals) { getNextToken(); string Value = currentToken.value; getNextToken(); if (currentToken.token == ECodeToken.ltString) { Value += currentToken.value; if (Value.ToLower() == "0xffffffff") { Value = "0xFFFFFFF"; } } ((TField)mem).value = Value; } return(mem); } } break; default: getNextToken(); break; } if ((currentToken == null) || (currentToken.token == ECodeToken.syEndOfCommand)) { break; } } return(mem); }