private void DocumentProperties(LuaCommandModule commandModule) { Type type = commandModule.GetType(); var properties = from pi in type.GetProperties(BindingFlags.Public | BindingFlags.Instance) select pi; foreach (var property in properties) { var luaCommandAttribute = Attribute.GetCustomAttribute(property, typeof(LuaCommandAttribute)) as LuaCommandAttribute; if (luaCommandAttribute != null) { m_helpString.Append("\u2022 <color=#3255FFFF>"); m_helpString.Append(commandModule.Name); m_helpString.Append('.'); m_helpString.Append(property.Name); m_helpString.Append(" : "); string typeName = property.PropertyType.Name; if (TypeNameLookup.ContainsKey(typeName)) { typeName = TypeNameLookup[typeName]; } m_helpString.Append(typeName); m_helpString.Append("</color>"); m_helpString.AppendFormat(" - {0}", luaCommandAttribute.Help); m_helpString.Append('\n'); } } }
private void DocumentMethods(LuaCommandModule commandModule) { Type type = commandModule.GetType(); var methods = from mi in type.GetMethods(BindingFlags.Public | BindingFlags.Instance) select mi; foreach (var method in methods) { var luaCommandAttribute = Attribute.GetCustomAttribute(method, typeof(LuaCommandAttribute)) as LuaCommandAttribute; if (luaCommandAttribute != null) { m_helpString.Append("\u2022 <color=#3255FFFF>"); m_helpString.Append(commandModule.Name); m_helpString.Append('.'); m_helpString.Append(method.Name); m_helpString.Append('('); ParameterInfo[] parameters = method.GetParameters(); for (int i = 0; i < parameters.Length; i++) { string typeName = parameters[i].ParameterType.Name; if (TypeNameLookup.ContainsKey(typeName)) { typeName = TypeNameLookup[typeName]; } m_helpString.Append(typeName); m_helpString.Append(' '); m_helpString.Append(parameters[i].Name); if (i < parameters.Length - 1) { m_helpString.Append(", "); } } m_helpString.Append(")</color>"); m_helpString.AppendFormat(" - {0}", luaCommandAttribute.Help); m_helpString.Append('\n'); } } }