Added even more XML documentaion tags.

This commit is contained in:
GoldenCrystal
2014-12-16 02:32:00 +01:00
parent 6b4e1da5bf
commit 04b03edee2
9 changed files with 166 additions and 2 deletions
@@ -7,13 +7,20 @@ using System.Threading.Tasks;
namespace System.Unicode
{
/// <summary>Provides extensions to the <see cref="UnicodeCategory"/> type.</summary>
public static class UnicodeCategoryExtensions
{
/// <summary>Gets the short name of the unicode category.</summary>
/// <param name="category">The category whose short name should be retrieved.</param>
/// <returns>The short name of the unicode category.</returns>
public static string GetShortName(this UnicodeCategory category)
{
return UnicodeCategoryInfo.Get(category).ShortName;
}
/// <summary>Gets the long name of the unicode category.</summary>
/// <param name="category">The category whose long name should be retrieved.</param>
/// <returns>The long name of the unicode category.</returns>
public static string GetLongName(this UnicodeCategory category)
{
return UnicodeCategoryInfo.Get(category).LongName;
+26
View File
@@ -7,6 +7,7 @@ using System.Threading.Tasks;
namespace System.Unicode
{
/// <summary>Provides complementary information on <see cref="UnicodeCategory"/> values.</summary>
public struct UnicodeCategoryInfo : IEquatable<UnicodeCategoryInfo>
{
private static readonly UnicodeCategoryInfo[] categories =
@@ -80,23 +81,35 @@ namespace System.Unicode
return unicodeLongNameToCategoryDictionary[name];
}
/// <summary>Gets an <see cref="UnicodeCategoryInfo"/> value providing information on the specified unicode category.</summary>
/// <param name="category">The category on which information should be retrieved.</param>
/// <returns>Information on the specified category.</returns>
public static UnicodeCategoryInfo Get(UnicodeCategory category)
{
return categories[(int)category];
}
/// <summary>Gets an <see cref="UnicodeCategoryInfo"/> value providing information on the unicode category, accessed by its short name, as per the Unicode standard.</summary>
/// <param name="name">The short name for which information should be retrieved .</param>
/// <returns>Information on the specified category.</returns>
public static UnicodeCategoryInfo FromShortName(string name)
{
return Get(GetCategoryFromShortName(name));
}
/// <summary>Gets an <see cref="UnicodeCategoryInfo"/> value providing information on the unicode category, accessed by its long name, as per the Unicode standard.</summary>
/// <param name="name">The long name for which information should be retrieved .</param>
/// <returns>Information on the specified category.</returns>
public static UnicodeCategoryInfo FromLongName(string name)
{
return Get(GetCategoryFromLongName(name));
}
/// <summary>The unicode category described.</summary>
public readonly UnicodeCategory Category;
/// <summary>Short name of the category, as per the Unicode standard.</summary>
public readonly string ShortName;
/// <summary>Long name of the category, as per the Unicode standard.</summary>
public readonly string LongName;
private UnicodeCategoryInfo(UnicodeCategory category, string shortName, string longName)
@@ -106,26 +119,39 @@ namespace System.Unicode
this.LongName = longName;
}
/// <summary>Returns a <see cref="System.String" /> that represents this instance.</summary>
/// <returns>A <see cref="System.String" /> that represents this instance.</returns>
public override string ToString()
{
return Category.ToString();
}
/// <summary>Determines whether the specified <see cref="System.Object" />, is equal to this instance.</summary>
/// <param name="obj">The <see cref="System.Object" /> to compare with this instance.</param>
/// <returns><see langword="true" /> if the specified <see cref="System.Object" /> is equal to this instance; otherwise, <see langword="false" />.</returns>
public override bool Equals(object obj)
{
return obj is UnicodeCategoryInfo && Equals((UnicodeCategoryInfo)obj);
}
/// <summary>Indicates whether the current object is equal to another object of the same type.</summary>
/// <param name="other">An object to compare with this object.</param>
/// <returns><see langword="true" /> if the current object is equal to the other parameter; otherwise, <see langword="false" />.</returns>
public bool Equals(UnicodeCategoryInfo other)
{
return other.Category == Category && (other.Category != 0 || other.ShortName != null);
}
/// <summary>Returns a hash code for this instance.</summary>
/// <returns>A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.</returns>
public override int GetHashCode()
{
return (int)Category;
}
/// <summary>Performs an implicit conversion from <see cref="UnicodeCategoryInfo"/> to <see cref="UnicodeCategory"/>.</summary>
/// <param name="info">The information.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator UnicodeCategory(UnicodeCategoryInfo info)
{
return info.Category;
+40 -2
View File
@@ -8,14 +8,19 @@ using System.Threading.Tasks;
namespace System.Unicode
{
/// <summary>Represents a range of Unicode code points.</summary>
public struct UnicodeCodePointRange : IEnumerable<int>
{
/// <summary>Represents an enumerator which enumerated through all the code points in the <see cref="UnicodeCodePointRange"/>.</summary>
public struct Enumerator : IEnumerator<int>
{
private readonly int start;
private readonly int end;
private int index;
/// <summary>Initializes a new instance of the <see cref="Enumerator"/> struct.</summary>
/// <param name="start">The start of the range.</param>
/// <param name="end">The end of the range.</param>
internal Enumerator(int start, int end)
{
this.start = start;
@@ -23,22 +28,34 @@ namespace System.Unicode
this.index = start - 1;
}
/// <summary>Does nothing.</summary>
public void Dispose() { }
/// <summary>Gets the element in the collection at the current position of the enumerator..</summary>
/// <value>The element in the collection at the current position of the enumerator.</value>
public int Current { get { return index; } }
object IEnumerator.Current { get { return index; } }
void IDisposable.Dispose() { }
/// <summary>Advances the enumerator to the next element of the collection.</summary>
/// <returns>true if the enumerator was successfully advanced to the next element; false if the enumerator has passed the end of the collection.</returns>
public bool MoveNext() { return index < end && ++index == index; }
void IEnumerator.Reset() { index = start - 1; }
}
/// <summary>The first code point in the range.</summary>
public readonly int FirstCodePoint;
/// <summary>The last code point in the range.</summary>
public readonly int LastCodePoint;
/// <summary>Gets a value indicating whether this value represents a single code point.</summary>
/// <value><see langword="true" /> if this value represents a single code point; otherwise, <see langword="false" />.</value>
public bool IsSingleCodePoint { get { return FirstCodePoint == LastCodePoint; } }
/// <summary>Initializes a new instance of the <see cref="UnicodeCodePointRange"/> struct for a single code point.</summary>
/// <param name="codePoint">The code point.</param>
/// <exception cref="System.ArgumentOutOfRangeException"></exception>
public UnicodeCodePointRange(int codePoint)
{
if (codePoint < 0 || codePoint > 0x10FFFF) throw new ArgumentOutOfRangeException(nameof(codePoint));
@@ -47,6 +64,13 @@ namespace System.Unicode
LastCodePoint = codePoint;
}
/// <summary>Initializes a new instance of the <see cref="UnicodeCodePointRange"/> struct with specified bounds.</summary>
/// <param name="firstCodePoint">The first code point in the range.</param>
/// <param name="lastCodePoint">The last code point in the range.</param>
/// <exception cref="System.ArgumentOutOfRangeException">
/// <paramref name="firstCodePoint"/> is less than 0 or greated than 0x10FFFF,
/// or <paramref name="lastCodePoint"/> is less than <paramref name="firstCodePoint"/> or greated than 0x10FFFF.
/// </exception>
public UnicodeCodePointRange(int firstCodePoint, int lastCodePoint)
{
if (firstCodePoint < 0 || firstCodePoint > 0x10FFFF) throw new ArgumentOutOfRangeException(nameof(firstCodePoint));
@@ -56,8 +80,13 @@ namespace System.Unicode
LastCodePoint = lastCodePoint;
}
/// <summary>Determines whether the range contains the specific code point.</summary>
/// <remarks>This method does not validate its inputs, but will always return <see langword="false"/> for any invalid code point.</remarks>
/// <param name="i">The integer to check against the range.</param>
/// <returns><see langword="true"/> if the range contains the specified code point; otherwise, <see langword="false"/>.</returns>
public bool Contains(int i)
{
// Since the first and last code points have been checked or are at their default value of zero, the method will always exlcude invalid code points.
return i >= FirstCodePoint & i <= LastCodePoint;
}
@@ -66,11 +95,18 @@ namespace System.Unicode
return FirstCodePoint <= codePoint ? LastCodePoint < codePoint ? 1 : 0 : -1;
}
/// <summary>Returns a <see cref="System.String" /> that represents this instance.</summary>
/// <returns>A <see cref="System.String" /> that represents this instance.</returns>
public override string ToString()
{
return FirstCodePoint == LastCodePoint ? FirstCodePoint.ToString("X4") : FirstCodePoint.ToString("X4") + ".." + LastCodePoint.ToString("X4");
}
/// <summary>Parses the specified into a <see cref="UnicodeCodePointRange"/>.</summary>
/// <remarks>Code point ranges are encoded as one unprefixed hexadecimal number for single code points, or a pair of unprefixed hexadecimal numbers separated by the characters "..".</remarks>
/// <param name="s">The text to parse.</param>
/// <returns>The parsed <see cref="UnicodeCodePointRange"/> value.</returns>
/// <exception cref="System.FormatException">The parameter <paramref name="s"/> was not in an allowed format.</exception>
public static UnicodeCodePointRange Parse(string s)
{
int start, end;
@@ -91,6 +127,8 @@ namespace System.Unicode
return new UnicodeCodePointRange(start, end);
}
/// <summary>Returns an enumerator that iterates through the collection.</summary>
/// <returns>A <see cref="Enumerator"/> that can be used to iterate through the collection.</returns>
public Enumerator GetEnumerator() { return new Enumerator(FirstCodePoint, LastCodePoint); }
IEnumerator<int> IEnumerable<int>.GetEnumerator() { return GetEnumerator(); }
IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); }
@@ -11,22 +11,30 @@ namespace System.Unicode
{
private static int[] EmptyArray = new int[0];
/// <summary>Represents an enumerator for the <see cref="UnicodeCrossReferenceCollection"/> class.</summary>
public struct Enumerator : IEnumerator<int>
{
private readonly int[] items;
private int index;
/// <summary>Initializes a new instance of the <see cref="Enumerator"/> struct.</summary>
/// <param name="items">The items to enumerate.</param>
internal Enumerator(int[] items)
{
this.items = items;
this.index = -1;
}
/// <summary>Does nothing.</summary>
public void Dispose() { }
/// <summary>Gets the element in the collection at the current position of the enumerator..</summary>
/// <value>The element in the collection at the current position of the enumerator.</value>
public int Current { get { return items[index]; } }
object IEnumerator.Current { get { return Current; } }
/// <summary>Advances the enumerator to the next element of the collection.</summary>
/// <returns>true if the enumerator was successfully advanced to the next element; false if the enumerator has passed the end of the collection.</returns>
public bool MoveNext() { return index < items.Length && ++index < items.Length; }
void IEnumerator.Reset() { this.index = -1; }
@@ -34,9 +42,14 @@ namespace System.Unicode
private readonly int[] items;
/// <summary>Initializes a new instance of the <see cref="UnicodeCrossReferenceCollection"/> struct.</summary>
public UnicodeCrossReferenceCollection() { items = EmptyArray; }
internal UnicodeCrossReferenceCollection(int[] items) { this.items = items ?? EmptyArray; }
/// <summary>Gets the cross-referenced code point at the specified index.</summary>
/// <value>The cross-referenced code point.</value>
/// <param name="index">The index.</param>
/// <returns>The cross-referenced code point at the specified index.</returns>
public int this[int index] { get { return items[index]; } }
int IList<int>.this[int index]
@@ -45,6 +58,8 @@ namespace System.Unicode
set { throw new NotSupportedException(); }
}
/// <summary>Gets the number of elements contained in the <see cref="UnicodeCrossReferenceCollection"/>.</summary>
/// <value>The number of elements contained in the <see cref="UnicodeCrossReferenceCollection"/>.</value>
public int Count { get { return items.Length; } }
bool ICollection<int>.IsReadOnly { get { return true; } }
@@ -57,11 +72,25 @@ namespace System.Unicode
void ICollection<int>.Clear() { throw new NotSupportedException(); }
/// <summary>Determines the index of a specific item in the <see cref="UnicodeCrossReferenceCollection"/>.</summary>
/// <param name="item">The object to locate in the <see cref="UnicodeCrossReferenceCollection"/>.</param>
/// <returns>The index of the item if found in the list; otherwise, -1.</returns>
public int IndexOf(int item) { return Array.IndexOf(items, item); }
/// <summary>Determines whether the <see cref="UnicodeCrossReferenceCollection"/> contains a specific value.</summary>
/// <param name="item">The object to locate in the <see cref="UnicodeCrossReferenceCollection"/>.</param>
/// <returns><see langword="true" /> if item is fount in the <see cref="UnicodeCrossReferenceCollection"/>; <see langword="false" /> otherwise.</returns>
public bool Contains(int item) { return IndexOf(item) >= 0; }
/// <summary>
/// Copies the elements of the UnicodeCrossReferenceCollection to an <see cref="System.Array" />, starting at a particular <see cref="System.Array" /> index.
/// </summary>
/// <param name="array">The one-dimensional <see cref="System.Array" /> that is the destination of the elements to copy from UnicodeCrossReferenceCollection. The <see cref="System.Array" /> must have zero-based indexing.</param>
/// <param name="arrayIndex">The zeo-based index in array at which copy begins.</param>
public void CopyTo(int[] array, int arrayIndex) { items.CopyTo(array, arrayIndex); }
/// <summary>Returns an enumerator that iterates through the collection.</summary>
/// <returns>A <see cref="Enumerator"/> that can be used to iterate through the collection.</returns>
public Enumerator GetEnumerator() { return new Enumerator(items); }
IEnumerator<int> IEnumerable<int>.GetEnumerator() { return GetEnumerator(); }
+5
View File
@@ -1,10 +1,15 @@
namespace System.Unicode
{
/// <summary>Represents a name alias for an Unicode code point.</summary>
public struct UnicodeNameAlias
{
internal static readonly UnicodeNameAlias[] EmptyArray = new UnicodeNameAlias[0];
/// <summary>Gets the alias name.</summary>
/// <value>The name.</value>
public string Name { get; }
/// <summary>Gets the kind of alias.</summary>
/// <value>The kind of alias.</value>
public UnicodeNameAliasKind Kind { get; }
internal UnicodeNameAlias(string name, UnicodeNameAliasKind kind)
@@ -71,9 +71,20 @@ namespace System.Unicode
void ICollection<UnicodeNameAlias>.Clear() { throw new NotSupportedException(); }
/// <summary>Determines the index of a specific item in the <see cref="UnicodeNameAliasCollection"/>.</summary>
/// <param name="item">The object to locate in the <see cref="UnicodeNameAliasCollection"/>.</param>
/// <returns>The index of the item if found in the list; otherwise, -1.</returns>
public int IndexOf(UnicodeNameAlias item) { return Array.IndexOf(items, item); }
/// <summary>Determines whether the <see cref="UnicodeNameAliasCollection"/> contains a specific value.</summary>
/// <param name="item">The object to locate in the <see cref="UnicodeNameAliasCollection"/>.</param>
/// <returns><see langword="true" /> if item is fount in the <see cref="UnicodeNameAliasCollection"/>; <see langword="false" /> otherwise.</returns>
public bool Contains(UnicodeNameAlias item) { return IndexOf(item) >= 0; }
/// <summary>
/// Copies the elements of the UnicodeNameAliasCollection to an <see cref="System.Array" />, starting at a particular <see cref="System.Array" /> index.
/// </summary>
/// <param name="array">The one-dimensional <see cref="System.Array" /> that is the destination of the elements to copy from UnicodeNameAliasCollection. The <see cref="System.Array" /> must have zero-based indexing.</param>
/// <param name="arrayIndex">The zeo-based index in array at which copy begins.</param>
public void CopyTo(UnicodeNameAlias[] array, int arrayIndex) { items.CopyTo(array, arrayIndex); }
/// <summary>Returns an enumerator that iterates through the collection.</summary>
+5
View File
@@ -6,11 +6,16 @@ using System.Threading.Tasks;
namespace System.Unicode
{
/// <summary>Represents the value of the Numeric_Type property.</summary>
public enum UnicodeNumericType : byte
{
/// <summary>The code point has no numeric value.</summary>
None = 0,
/// <summary>The code point represents a decimal digit which is part of a contiguous ascending range of characters from 0 to 9, and can be used in a decimal radix positional numeral system.</summary>
Decimal = 1,
/// <summary>The code point represents a digit between 0 and 9 and requires special handling.</summary>
Digit = 2,
/// <summary>The code point represents another kind of numeric value.</summary>
Numeric = 3
}
}
@@ -6,6 +6,8 @@ using System.Threading.Tasks;
namespace System.Unicode
{
/// <summary>Provides information on radical and additional stroke count for a code point.</summary>
/// <remarks>Values of this type are usually associated with the property kRSUnicode (aka. Unicode_Radical_Stroke).</remarks>
public struct UnicodeRadicalStrokeCount
{
internal static readonly UnicodeRadicalStrokeCount[] EmptyArray = new UnicodeRadicalStrokeCount[0];
@@ -26,8 +28,17 @@ namespace System.Unicode
this.strokeCount = strokeCount;
}
/// <summary>Gets the index of the Kangxi radical of the character.</summary>
/// <remarks>The Kangxi radicals are numbered from 1 to 214 inclusive.</remarks>
/// <value>The index of the Kangxi radical.</value>
public byte Radical { get { return radical; } }
/// <summary>Gets the additional stroke count.</summary>
/// <value>
/// The stroke count.
/// </value>
public byte StrokeCount { get { return (byte)(strokeCount & 0x7F); } }
/// <summary>Gets a value indicating whether the information is based on the simplified form of the radical.</summary>
/// <value><see langword="true" /> if the information is based on the simplified form of the radical; otherwise, <see langword="false" />.</value>
public bool IsSimplified { get { return (strokeCount & 0x80) != 0; } }
}
}
@@ -7,24 +7,33 @@ using System.Threading.Tasks;
namespace System.Unicode
{
/// <summary>Represents a collection of values for the kRSUnicode (aka. Unicode_Radical_Stroke) property.</summary>
public struct UnicodeRadicalStrokeCountCollection : IList<UnicodeRadicalStrokeCount>
{
/// <summary>Represents an enumerator for the <see cref="UnicodeRadicalStrokeCountCollection"/> class.</summary>
public struct Enumerator : IEnumerator<UnicodeRadicalStrokeCount>
{
private readonly UnicodeRadicalStrokeCount[] items;
private int index;
/// <summary>Initializes a new instance of the <see cref="Enumerator"/> struct.</summary>
/// <param name="items">The items to enumerate.</param>
internal Enumerator(UnicodeRadicalStrokeCount[] items)
{
this.items = items;
this.index = -1;
}
/// <summary>Does nothing.</summary>
public void Dispose() { }
/// <summary>Gets the element in the collection at the current position of the enumerator..</summary>
/// <value>The element in the collection at the current position of the enumerator.</value>
public UnicodeRadicalStrokeCount Current { get { return items[index]; } }
object IEnumerator.Current { get { return Current; } }
/// <summary>Advances the enumerator to the next element of the collection.</summary>
/// <returns>true if the enumerator was successfully advanced to the next element; false if the enumerator has passed the end of the collection.</returns>
public bool MoveNext() { return index < items.Length && ++index < items.Length; }
void IEnumerator.Reset() { this.index = -1; }
@@ -32,9 +41,14 @@ namespace System.Unicode
private readonly UnicodeRadicalStrokeCount[] items;
/// <summary>Initializes a new instance of the <see cref="UnicodeRadicalStrokeCountCollection"/> struct.</summary>
public UnicodeRadicalStrokeCountCollection() { items = UnicodeRadicalStrokeCount.EmptyArray; }
internal UnicodeRadicalStrokeCountCollection(UnicodeRadicalStrokeCount[] items) { this.items = items ?? UnicodeRadicalStrokeCount.EmptyArray; }
/// <summary>Gets the <see cref="UnicodeRadicalStrokeCount"/> at the specified index.</summary>
/// <value>The <see cref="UnicodeRadicalStrokeCount"/>.</value>
/// <param name="index">The index.</param>
/// <returns>The <see cref="UnicodeRadicalStrokeCount"/> at the specified index.</returns>
public UnicodeRadicalStrokeCount this[int index] { get { return items[index]; } }
UnicodeRadicalStrokeCount IList<UnicodeRadicalStrokeCount>.this[int index]
@@ -43,6 +57,8 @@ namespace System.Unicode
set { throw new NotSupportedException(); }
}
/// <summary>Gets the number of elements contained in the <see cref="UnicodeRadicalStrokeCountCollection"/>.</summary>
/// <value>The number of elements contained in the <see cref="UnicodeRadicalStrokeCountCollection"/>.</value>
public int Count { get { return items.Length; } }
bool ICollection<UnicodeRadicalStrokeCount>.IsReadOnly { get { return true; } }
@@ -55,11 +71,27 @@ namespace System.Unicode
void ICollection<UnicodeRadicalStrokeCount>.Clear() { throw new NotSupportedException(); }
/// <summary>Determines the index of a specific item in the <see cref="UnicodeRadicalStrokeCountCollection"/>.</summary>
/// <param name="item">The object to locate in the <see cref="UnicodeRadicalStrokeCountCollection"/>.</param>
/// <returns>The index of the item if found in the list; otherwise, -1.</returns>
public int IndexOf(UnicodeRadicalStrokeCount item) { return Array.IndexOf(items, item); }
/// <summary>Determines whether the <see cref="UnicodeRadicalStrokeCountCollection"/> contains a specific value.</summary>
/// <param name="item">The object to locate in the <see cref="UnicodeRadicalStrokeCountCollection"/>.</param>
/// <returns><see langword="true" /> if item is fount in the <see cref="UnicodeRadicalStrokeCountCollection"/>; <see langword="false" /> otherwise.</returns>
public bool Contains(UnicodeRadicalStrokeCount item) { return IndexOf(item) >= 0; }
/// <summary>Copies the elements of the UnicodeRadicalStrokeCountCollection to an <see cref="System.Array" />, starting at a particular <see cref="System.Array" /> index.</summary>
/// <param name="array">The one-dimensional <see cref="System.Array" /> that is the destination of the elements to copy from UnicodeRadicalStrokeCountCollection. The <see cref="System.Array" /> must have zero-based indexing.</param>
/// <param name="arrayIndex">The zeo-based index in array at which copy begins.</param>
public void CopyTo(UnicodeRadicalStrokeCount[] array, int arrayIndex) { items.CopyTo(array, arrayIndex); }
/// <summary>
/// Returns an enumerator that iterates through the collection.
/// </summary>
/// <returns>
/// A <see cref="Enumerator"/> that can be used to iterate through the collection.
/// </returns>
public Enumerator GetEnumerator() { return new Enumerator(items); }
IEnumerator<UnicodeRadicalStrokeCount> IEnumerable<UnicodeRadicalStrokeCount>.GetEnumerator() { return GetEnumerator(); }