Added XML documentation.

This commit is contained in:
2017-06-06 18:04:08 +01:00
parent 29d1e5fe2c
commit fa8d47d615
5 changed files with 106 additions and 6 deletions

View File

@@ -27,8 +27,16 @@ using System;
using System.Text;
namespace Claunia.RsrcFork
{
/// <summary>
/// Contains convertes between .NET and Pascal strings. Only ASCII supported right now.
/// </summary>
public static class PascalString
{
/// <summary>
/// Converts an ASCII Pascal string to a .NET string.
/// </summary>
/// <returns>The .NET string.</returns>
/// <param name="PStr">The ASCII Pascal string.</param>
public static string GetString(byte[] PStr)
{
if(PStr == null || PStr[0] >= PStr.Length)
@@ -37,6 +45,11 @@ namespace Claunia.RsrcFork
return Encoding.ASCII.GetString(PStr, 1, PStr[0]);
}
/// <summary>
/// Converts a .NET string to an ASCII Pascal string.
/// </summary>
/// <returns>The ASCII Pascal string.</returns>
/// <param name="str">The .NET string.</param>
public static byte[] GetBytes(string str)
{
if(str == null)

View File

@@ -32,6 +32,9 @@ using System.Text;
namespace Claunia.RsrcFork
{
/// <summary>
/// This class represents a resource type.
/// </summary>
public class Resource
{
readonly Dictionary<short, string> resourceNames;
@@ -47,7 +50,7 @@ namespace Claunia.RsrcFork
}
/// <summary>
/// Initializates the specified resource type
/// Initializates the specified resource type.
/// </summary>
/// <param name="stream">Stream where the resources of this reside.</param>
/// <param name="resources">How many resource of this type are.</param>
@@ -116,7 +119,7 @@ namespace Claunia.RsrcFork
}
/// <summary>
/// Gets the name of the specified resource id, or null if there is no name
/// Gets the name of the specified resource id, or null if there is no name.
/// </summary>
/// <returns>The name.</returns>
/// <param name="id">Identifier.</param>
@@ -127,7 +130,7 @@ namespace Claunia.RsrcFork
}
/// <summary>
/// Gets the resource contents
/// Gets the resource contents.
/// </summary>
/// <returns>The resource.</returns>
/// <param name="id">Identifier.</param>
@@ -152,17 +155,31 @@ namespace Claunia.RsrcFork
return resource;
}
/// <summary>
/// Gets the length of the resource specified by ID.
/// </summary>
/// <returns>The length.</returns>
/// <param name="id">Resource identifier.</param>
public long GetLength(short id)
{
ResourceData data;
return !resources.TryGetValue(id, out data) ? 0 : data.length;
}
/// <summary>
/// Gets the IDs of all the resources contained by this instance.
/// </summary>
/// <returns>The identifiers.</returns>
public short[] GetIds()
{
return ids.ToArray();
}
/// <summary>
/// Checks if the resource specified by ID is contained by this instance.
/// </summary>
/// <returns><c>true</c>, if the resource is contained in this instance, <c>false</c> otherwise.</returns>
/// <param name="id">Resource identifier.</param>
public bool ContainsId(short id)
{
return ids.Contains(id);

View File

@@ -30,6 +30,9 @@ using System.Linq;
namespace Claunia.RsrcFork
{
/// <summary>
/// This class represents a resource fork.
/// </summary>
public class ResourceFork
{
Stream rsrcStream;
@@ -40,7 +43,7 @@ namespace Claunia.RsrcFork
List<uint> osTypes;
/// <summary>
/// Initializates a resource fork using a byte array as backend
/// Initializates a resource fork using a byte array as backend.
/// </summary>
/// <param name="buffer">Buffer.</param>
public ResourceFork(byte[] buffer)
@@ -50,7 +53,7 @@ namespace Claunia.RsrcFork
}
/// <summary>
/// Initializates a resource fork using a stream as backed
/// Initializates a resource fork using a stream as backed.
/// </summary>
/// <param name="stream">Stream.</param>
public ResourceFork(Stream stream)
@@ -65,7 +68,10 @@ namespace Claunia.RsrcFork
rsrcStream.Close();
}
public void Init()
/// <summary>
/// Initializes this instance.
/// </summary>
void Init()
{
header = new ResourceHeader();
byte[] tmp = new byte[4];

View File

@@ -30,28 +30,71 @@ using Claunia.RsrcFork;
namespace Resources
{
/// <summary>
/// This class handles the "VERS" resource fork
/// </summary>
public class Version
{
static uint ostype = 0x76657273;
#region On-disk structure
/// <summary>
/// Major version.
/// </summary>
public byte MajorVersion;
/// <summary>
/// Minor version.
/// </summary>
public byte MinorVersion;
/// <summary>
/// Development stage.
/// </summary>
public DevelopmentStage DevStage;
/// <summary>
/// Pre-release version.
/// </summary>
public byte PreReleaseVersion;
/// <summary>
/// Region code.
/// </summary>
public ushort RegionCode;
/// <summary>
/// Version string.
/// </summary>
public string VersionString;
/// <summary>
/// Version message.
/// </summary>
public string VersionMessage;
#endregion
/// <summary>
/// Known development stages
/// </summary>
public enum DevelopmentStage : byte
{
/// <summary>
/// Pre-alpha.
/// </summary>
PreAlpha = 0x20,
/// <summary>
/// Alpha.
/// </summary>
Alpha = 0x40,
/// <summary>
/// Beta.
/// </summary>
Beta = 0x60,
/// <summary>
/// Final release.
/// </summary>
Final = 0x80
}
/// <summary>
/// Initializes a new instance of the <see cref="T:Resources.Version"/> class.
/// </summary>
/// <param name="resource">Byte array containing the "VERS" resource.</param>
public Version(byte[] resource)
{
byte[] tmpShort, tmpStr, tmpMsg;
@@ -72,6 +115,10 @@ namespace Resources
VersionMessage = PascalString.GetString(tmpMsg);
}
/// <summary>
/// Gets a byte array with the "VERS" resource contained by this instance.
/// </summary>
/// <returns>The "VERS" resource.</returns>
public byte[] GetBytes()
{
byte[] tmpShort, tmpStr, tmpMsg;
@@ -92,6 +139,10 @@ namespace Resources
return vers;
}
/// <summary>
/// Gets the OSTYPE of this resource.
/// </summary>
/// <value>The OSTYPE.</value>
public static uint OSType {
get {
return ostype;

View File

@@ -30,8 +30,16 @@ using System.Linq;
namespace Claunia.RsrcFork
{
/// <summary>
/// This class contains static methods for OSTYPE handling.
/// </summary>
public static class Types
{
/// <summary>
/// Gets a descriptive name of a resource from its OSTYPE.
/// </summary>
/// <returns>The name corresponding to the specified OSTYPE.</returns>
/// <param name="OSType">The OSTYPE.</param>
public static string GetName(uint OSType)
{
switch(OSType) {
@@ -680,6 +688,11 @@ namespace Claunia.RsrcFork
}
}
/// <summary>
/// Gets a descriptive name of a resource from its OSTYPE.
/// </summary>
/// <returns>The name corresponding to the specified OSTYPE.</returns>
/// <param name="OSType">The OSTYPE.</param>
public static string GetName(string OSType)
{
if(OSType.Length != 4)