Added some documentation to some stuff

This commit is contained in:
Lucas Nicodemus 2012-05-26 11:04:36 -06:00
parent 8ecabb7f2e
commit 1fb554a804
2 changed files with 32 additions and 1 deletions

View file

@ -233,6 +233,11 @@ namespace TShockAPI
[Description("Prevent players from interacting with the world if dead")] public bool PreventDeadModification = [Description("Prevent players from interacting with the world if dead")] public bool PreventDeadModification =
false; false;
/// <summary>
/// Reads a configuration file from a given path
/// </summary>
/// <param name="path">string path</param>
/// <returns>ConfigFile object</returns>
public static ConfigFile Read(string path) public static ConfigFile Read(string path)
{ {
if (!File.Exists(path)) if (!File.Exists(path))
@ -243,6 +248,11 @@ namespace TShockAPI
} }
} }
/// <summary>
/// Reads the configuration file from a stream
/// </summary>
/// <param name="stream">stream</param>
/// <returns>ConfigFile object</returns>
public static ConfigFile Read(Stream stream) public static ConfigFile Read(Stream stream)
{ {
using (var sr = new StreamReader(stream)) using (var sr = new StreamReader(stream))
@ -254,6 +264,10 @@ namespace TShockAPI
} }
} }
/// <summary>
/// Writes the configuration to a given path
/// </summary>
/// <param name="path">string path - Location to put the config file</param>
public void Write(string path) public void Write(string path)
{ {
using (var fs = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Write)) using (var fs = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Write))
@ -262,6 +276,10 @@ namespace TShockAPI
} }
} }
/// <summary>
/// Writes the configuration to a stream
/// </summary>
/// <param name="stream">stream</param>
public void Write(Stream stream) public void Write(Stream stream)
{ {
var str = JsonConvert.SerializeObject(this, Formatting.Indented); var str = JsonConvert.SerializeObject(this, Formatting.Indented);
@ -271,9 +289,14 @@ namespace TShockAPI
} }
} }
/// <summary>
/// On config read hook
/// </summary>
public static Action<ConfigFile> ConfigRead; public static Action<ConfigFile> ConfigRead;
/// <summary>
/// Dumps all configuration options to a text file in Markdown format
/// </summary>
public static void DumpDescriptions() public static void DumpDescriptions()
{ {
var sb = new StringBuilder(); var sb = new StringBuilder();

View file

@ -180,6 +180,11 @@ namespace TShockAPI
restapi = "api"; restapi = "api";
} }
/// <summary>
/// Lists all commands associated with a given permission
/// </summary>
/// <param name="perm">string permission - the permission to get information on</param>
/// <returns>List of commands</returns>
private static List<Command> GetCommands(string perm) private static List<Command> GetCommands(string perm)
{ {
if (Commands.ChatCommands.Count < 1) if (Commands.ChatCommands.Count < 1)
@ -187,6 +192,9 @@ namespace TShockAPI
return Commands.ChatCommands.Where(c => c.Permission == perm).ToList(); return Commands.ChatCommands.Where(c => c.Permission == perm).ToList();
} }
/// <summary>
/// Dumps the descriptions of each permission to a file in Markdown format.
/// </summary>
public static void DumpDescriptions() public static void DumpDescriptions()
{ {
var sb = new StringBuilder(); var sb = new StringBuilder();