public void GenerateTypesPage(ITextBuilder htmlBuilder) { Int32 enumTypeCount = 0, objectTypeCount = 0; foreach (KeyValuePair <String, Type> pair in npcExecutor.EnumAndObjectTypes) { if (pair.Value.IsEnum) { enumTypeCount++; } else { objectTypeCount++; } } htmlBuilder.AppendAscii("<br/><br/><hr/>"); if (enumTypeCount <= 0) { htmlBuilder.AppendAscii("<h2>There are no enum types</h2><hr/>"); } else { //htmlBuilder.AppendFormat("<h2>{0} enum types</h2><hr/>", enumTypeCount); htmlBuilder.AppendAscii("<h2>"); htmlBuilder.AppendNumber(enumTypeCount); htmlBuilder.AppendAscii(" enum types</h2><hr/>"); foreach (KeyValuePair <String, Type> pair in npcExecutor.EnumAndObjectTypes) { if (pair.Value.IsEnum) { htmlBuilder.AppendAscii(TypeAsHtml(pair.Value)); htmlBuilder.AppendAscii("<br/>"); } } } htmlBuilder.AppendAscii("<br/><br/><hr/>"); if (objectTypeCount <= 0) { htmlBuilder.AppendAscii("<h2>There are no object types</h2><hr/>"); } else { //htmlBuilder.AppendFormat("<h2>{0} object types</h2><hr/>", objectTypeCount); htmlBuilder.AppendAscii("<h2>"); htmlBuilder.AppendNumber(objectTypeCount); htmlBuilder.AppendAscii(" object types</h2><hr/>"); foreach (KeyValuePair <String, Type> pair in npcExecutor.EnumAndObjectTypes) { if (!pair.Value.IsEnum) { htmlBuilder.AppendAscii(TypeAsHtml(pair.Value)); htmlBuilder.AppendAscii("<br/>"); } } } }
static void AppendNpcError(ITextBuilder responseBuilder, NpcErrorCode errorCode, String errorMessage) { responseBuilder.AppendAscii(NpcReturnObject.NpcReturnLineNpcErrorPrefix); responseBuilder.AppendNumber((byte)errorCode); responseBuilder.AppendAscii(' '); responseBuilder.AppendAscii(errorCode.ToString()); responseBuilder.AppendAscii(errorMessage.Replace("\n", "\\n")); responseBuilder.AppendAscii('\n'); }
public void GenerateMethodsPage(ITextBuilder htmlBuilder) { htmlBuilder.AppendAscii("<div class=\"methodgroups\">"); Int32 tabIndex = 1; foreach (NpcExecutionObject executionObject in npcExecutor.ExecutionObjects) { htmlBuilder.AppendAscii("<div class=\"methods\"><hr/><h2>"); htmlBuilder.AppendAscii(executionObject.objectName); htmlBuilder.AppendAscii("</h2><hr/>"); for (int interfaceIndex = 0; interfaceIndex < executionObject.ancestorNpcInterfaces.Count; interfaceIndex++) { NpcInterfaceInfo interfaceInfo = executionObject.ancestorNpcInterfaces[interfaceIndex]; for (int methodIndex = 0; methodIndex < interfaceInfo.npcMethods.Length; methodIndex++) { NpcMethodInfo npcMethodInfo = interfaceInfo.npcMethods[methodIndex]; ParameterInfo[] parameters = npcMethodInfo.parameters; Int32 parameterCount = (parameters == null) ? 0 : parameters.Length; //htmlBuilder.AppendFormat("<form class=\"methodform\" action=\"call/{0}.{1}\" method=\"get\">", executionObject.objectName, npcMethodInfo.methodName); htmlBuilder.AppendAscii("<form class=\"methodform\" action=\"call/"); htmlBuilder.AppendAscii(executionObject.objectName); htmlBuilder.AppendAscii("."); htmlBuilder.AppendAscii(npcMethodInfo.methodName); htmlBuilder.AppendAscii("\" method=\"get\">"); //htmlBuilder.AppendFormat("<input class=\"executebutton\" type=\"submit\" value=\"Execute\" tabindex=\"{0}\"/>", tabIndex + parameterCount); htmlBuilder.AppendAscii("<input class=\"executebutton\" type=\"submit\" value=\"Execute\" tabindex=\""); htmlBuilder.AppendNumber(tabIndex + parameterCount); htmlBuilder.AppendAscii("\"/>"); #if WindowsCE htmlBuilder.Append(TypeAsHtml(npcMethodInfo.methodInfo.ReturnType)); #else htmlBuilder.AppendAscii(TypeAsHtml(npcMethodInfo.methodInfo.ReturnParameter.ParameterType)); #endif //htmlBuilder.AppendFormat(" <font class=\"bold\">{0}</font>(", npcMethodInfo.methodInfo.Name); htmlBuilder.AppendAscii(" <font class=\"bold\">"); htmlBuilder.AppendAscii(npcMethodInfo.methodInfo.Name); htmlBuilder.AppendAscii("</font>("); if (parameterCount > 0) { htmlBuilder.AppendAscii("<div style=\"padding-left:50px;\"><table class=\"methodtable\">"); for (UInt16 j = 0; j < parameterCount; j++) { ParameterInfo parameterInfo = parameters[j]; //htmlBuilder.AppendFormat("<tr><td>{0}</td><td> {1}</td><td> = </td><td width=\"100%\"><input style=\"width:100%;\" tabindex=\"{3}\" name=\"{2}\"/></td></tr>", // TypeAsHtml(parameterInfo.ParameterType), parameterInfo.Name, j, tabIndex++); htmlBuilder.AppendAscii("<tr><td>"); htmlBuilder.AppendAscii(TypeAsHtml(parameterInfo.ParameterType)); htmlBuilder.AppendAscii("</td><td> "); htmlBuilder.AppendAscii(parameterInfo.Name); htmlBuilder.AppendAscii("</td><td> = </td><td width=\"100%\"><input style=\"width:100%;\" tabindex=\""); htmlBuilder.AppendNumber(tabIndex++); htmlBuilder.AppendAscii("\" name=\""); htmlBuilder.AppendNumber(j); htmlBuilder.AppendAscii("\"/></td></tr>"); } htmlBuilder.AppendAscii("</table></div>"); } htmlBuilder.AppendAscii(")</form>"); } } tabIndex++; htmlBuilder.AppendAscii("</div>"); } htmlBuilder.AppendAscii("</div>"); htmlBuilder.AppendAscii("<div id=\"executeframe\"></div>"); }