Skip to content

Commit

Permalink
Updated doc comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Pogromca-SCP committed May 25, 2024
1 parent ee89b44 commit 0c1270e
Show file tree
Hide file tree
Showing 14 changed files with 75 additions and 284 deletions.
6 changes: 3 additions & 3 deletions SLCommandScript.Core/Interfaces/IScriptsLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ namespace SLCommandScript.Core.Interfaces;
public interface IScriptsLoader : IDisposable
{
/// <summary>
/// Contains loader name to display.
/// Provides loader name to display.
/// </summary>
string LoaderName { get; }

/// <summary>
/// Contains current loader version.
/// Provides current loader version.
/// </summary>
string LoaderVersion { get; }

/// <summary>
/// Contains loader author.
/// Provides loader author.
/// </summary>
string LoaderAuthor { get; }

Expand Down
37 changes: 8 additions & 29 deletions SLCommandScript.Core/Iterables/EmptyIterable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,48 +13,27 @@ public class EmptyIterable : IIterable
/// </summary>
public static EmptyIterable Instance { get; } = new();

/// <summary>
/// <see langword="true" /> if last object was reached, <see langword="false" /> otherwise.
/// </summary>
/// <inheritdoc />
public bool IsAtEnd => true;

/// <summary>
/// Current amount of elements.
/// </summary>
/// <inheritdoc />
public int Count => 0;

/// <summary>
/// Performs next iteration step and loads new property values into provided dictionary.
/// </summary>
/// <param name="targetVars">Dictionary to insert properties into.</param>
/// <returns><see langword="true" /> if the iteration can continue, <see langword="false" /> otherwise.</returns>
/// <inheritdoc />
public bool LoadNext(IDictionary<string, string> targetVars) => false;

/// <summary>
/// Randomizes contained elements.
/// </summary>
/// <inheritdoc />
public void Randomize() {}

/// <summary>
/// Randomizes contained elements and limits their amount.
/// </summary>
/// <param name="amount">Amount of random elements to select from iterable object, negative values disable the limit, zero disables randomization.</param>
/// <inheritdoc />
public void Randomize(int amount) {}

/// <summary>
/// Randomizes contained elements and limits their amount.
/// </summary>
/// <param name="amount">Percentage of random elements to select from iterable object, negative values disable the limit, zero disables randomization.</param>
/// <inheritdoc />
public void Randomize(float amount) {}

/// <summary>
/// Randomizes contained elements and limits their amount.
/// </summary>
/// <param name="settings">Settings to use for randomization, negative values disable the limit, zero disables randomization.</param>
/// <inheritdoc />
public void Randomize(RandomSettings settings) {}

/// <summary>
/// Resets iteration process.
/// </summary>
/// <inheritdoc />
public void Reset() {}
}
37 changes: 8 additions & 29 deletions SLCommandScript.Core/Iterables/EnumIterable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ public class EnumIterable<TEnum>(bool enableNone) : IIterable where TEnum : Enum
/// <returns>Iterable object for specific enum.</returns>
public static EnumIterable<TEnum> GetWithNone() => new(true);

/// <summary>
/// <see langword="true" /> if last object was reached, <see langword="false" /> otherwise.
/// </summary>
/// <inheritdoc />
public bool IsAtEnd
{
get
Expand Down Expand Up @@ -58,9 +56,7 @@ public bool IsAtEnd
}
}

/// <summary>
/// Current amount of elements.
/// </summary>
/// <inheritdoc />
public int Count => _values is null ? 0 : _values.Length;

/// <summary>
Expand All @@ -83,11 +79,7 @@ public bool IsAtEnd
/// </summary>
private int _current = 0;

/// <summary>
/// Performs next iteration step and loads new property values into provided dictionary.
/// </summary>
/// <param name="targetVars">Dictionary to insert properties into.</param>
/// <returns><see langword="true" /> if the iteration can continue, <see langword="false" /> otherwise.</returns>
/// <inheritdoc />
public bool LoadNext(IDictionary<string, string> targetVars)
{
if (IsAtEnd)
Expand All @@ -104,36 +96,23 @@ public bool LoadNext(IDictionary<string, string> targetVars)
return true;
}

/// <summary>
/// Randomizes contained elements.
/// </summary>
/// <inheritdoc />
public void Randomize() => Randomize(new RandomSettings(-1));

/// <summary>
/// Randomizes contained elements and limits their amount.
/// </summary>
/// <param name="amount">Amount of random elements to select from iterable object, negative values disable the limit, zero disables randomization.</param>
/// <inheritdoc />
public void Randomize(int amount) => Randomize(new RandomSettings(amount));

/// <summary>
/// Randomizes contained elements and limits their amount.
/// </summary>
/// <param name="amount">Percentage of random elements to select from iterable object, negative values disable the limit, zero disables randomization.</param>
/// <inheritdoc />
public void Randomize(float amount) => Randomize(new RandomSettings(amount));

/// <summary>
/// Randomizes contained elements and limits their amount.
/// </summary>
/// <param name="settings">Settings to use for randomization, negative values disable the limit, zero disables randomization.</param>
/// <inheritdoc />
public void Randomize(RandomSettings settings)
{
_values = null;
_randomSettings = settings;
}

/// <summary>
/// Resets iteration process.
/// </summary>
/// <inheritdoc />
public void Reset()
{
if (_values is not null)
Expand Down
37 changes: 8 additions & 29 deletions SLCommandScript.Core/Iterables/IterableList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ namespace SLCommandScript.Core.Iterables;
/// <param name="mapper">Variable mapper to use to load variables.</param>
public class IterableList<TItem>(Func<IEnumerable<TItem>> source, Action<IDictionary<string, string>, TItem> mapper) : IIterable
{
/// <summary>
/// <see langword="true" /> if last object was reached, <see langword="false" /> otherwise.
/// </summary>
/// <inheritdoc />
public bool IsAtEnd
{
get
Expand Down Expand Up @@ -50,9 +48,7 @@ public bool IsAtEnd
}
}

/// <summary>
/// Current amount of elements.
/// </summary>
/// <inheritdoc />
public int Count { get; private set; } = 0;

/// <summary>
Expand Down Expand Up @@ -85,11 +81,7 @@ public bool IsAtEnd
/// </summary>
private int _current = 0;

/// <summary>
/// Performs next iteration step and loads new property values into provided dictionary.
/// </summary>
/// <param name="targetVars">Dictionary to insert properties into.</param>
/// <returns><see langword="true" /> if the iteration can continue, <see langword="false" /> otherwise.</returns>
/// <inheritdoc />
public bool LoadNext(IDictionary<string, string> targetVars)
{
if (IsAtEnd)
Expand All @@ -108,27 +100,16 @@ public bool LoadNext(IDictionary<string, string> targetVars)
return true;
}

/// <summary>
/// Randomizes contained elements.
/// </summary>
/// <inheritdoc />
public void Randomize() => Randomize(new RandomSettings(-1));

/// <summary>
/// Randomizes contained elements and limits their amount.
/// </summary>
/// <param name="amount">Amount of random elements to select from iterable object, negative values disable the limit, zero disables randomization.</param>
/// <inheritdoc />
public void Randomize(int amount) => Randomize(new RandomSettings(amount));

/// <summary>
/// Randomizes contained elements and limits their amount.
/// </summary>
/// <param name="amount">Percentage of random elements to select from iterable object, negative values disable the limit, zero disables randomization.</param>
/// <inheritdoc />
public void Randomize(float amount) => Randomize(new RandomSettings(amount));

/// <summary>
/// Randomizes contained elements and limits their amount.
/// </summary>
/// <param name="settings">Settings to use for randomization, negative values disable the limit, zero disables randomization.</param>
/// <inheritdoc />
public void Randomize(RandomSettings settings)
{
Count = 0;
Expand All @@ -137,9 +118,7 @@ public void Randomize(RandomSettings settings)
_randomSettings = settings;
}

/// <summary>
/// Resets iteration process.
/// </summary>
/// <inheritdoc />
public void Reset()
{
_enumerator = _objects?.GetEnumerator();
Expand Down
37 changes: 8 additions & 29 deletions SLCommandScript.Core/Iterables/PredefinedIterable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,10 @@ namespace SLCommandScript.Core.Iterables;
/// <param name="mapper">Variable mapper to use to load variables.</param>
public class PredefinedIterable<TItem>(IEnumerable<TItem> source, Action<IDictionary<string, string>, TItem> mapper) : IIterable
{
/// <summary>
/// <see langword="true" /> if last object was reached, <see langword="false" /> otherwise.
/// </summary>
/// <inheritdoc />
public bool IsAtEnd => _source is null || _current >= Count;

/// <summary>
/// Current amount of elements.
/// </summary>
/// <inheritdoc />
public int Count { get; } = source?.Count() ?? 0;

/// <summary>
Expand All @@ -43,11 +39,7 @@ public class PredefinedIterable<TItem>(IEnumerable<TItem> source, Action<IDictio
/// </summary>
private int _current = 0;

/// <summary>
/// Performs next iteration step and loads new property values into provided dictionary.
/// </summary>
/// <param name="targetVars">Dictionary to insert properties into.</param>
/// <returns><see langword="true" /> if the iteration can continue, <see langword="false" /> otherwise.</returns>
/// <inheritdoc />
public bool LoadNext(IDictionary<string, string> targetVars)
{
if (IsAtEnd)
Expand All @@ -66,32 +58,19 @@ public bool LoadNext(IDictionary<string, string> targetVars)
return true;
}

/// <summary>
/// Randomizes contained elements.
/// </summary>
/// <inheritdoc />
public void Randomize() => Reset();

/// <summary>
/// Randomizes contained elements and limits their amount.
/// </summary>
/// <param name="amount">Amount of random elements to select from iterable object, negative values disable the limit, zero disables randomization.</param>
/// <inheritdoc />
public void Randomize(int amount) => Reset();

/// <summary>
/// Randomizes contained elements and limits their amount.
/// </summary>
/// <param name="amount">Percentage of random elements to select from iterable object, negative values disable the limit, zero disables randomization.</param>
/// <inheritdoc />
public void Randomize(float amount) => Reset();

/// <summary>
/// Randomizes contained elements and limits their amount.
/// </summary>
/// <param name="settings">Settings to use for randomization, negative values disable the limit, zero disables randomization.</param>
/// <inheritdoc />
public void Randomize(RandomSettings settings) => Reset();

/// <summary>
/// Resets iteration process.
/// </summary>
/// <inheritdoc />
public void Reset()
{
_enumerator = _source?.GetEnumerator();
Expand Down
37 changes: 8 additions & 29 deletions SLCommandScript.Core/Iterables/SingleItemIterable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,10 @@ namespace SLCommandScript.Core.Iterables;
/// <typeparam name="TItem">Type of contained objects.</typeparam>
public class SingleItemIterable<TItem> : IIterable
{
/// <summary>
/// <see langword="true" /> if last object was reached, <see langword="false" /> otherwise.
/// </summary>
/// <inheritdoc />
public bool IsAtEnd { get; private set; }

/// <summary>
/// Current amount of elements.
/// </summary>
/// <inheritdoc />
public int Count { get; }

/// <summary>
Expand Down Expand Up @@ -63,11 +59,7 @@ public SingleItemIterable(TItem item, Action<IDictionary<string, string>, TItem>
_item = item;
}

/// <summary>
/// Performs next iteration step and loads new property values into provided dictionary.
/// </summary>
/// <param name="targetVars">Dictionary to insert properties into.</param>
/// <returns><see langword="true" /> if the iteration can continue, <see langword="false" /> otherwise.</returns>
/// <inheritdoc />
public bool LoadNext(IDictionary<string, string> targetVars)
{
if (IsAtEnd)
Expand All @@ -89,31 +81,18 @@ public bool LoadNext(IDictionary<string, string> targetVars)
return true;
}

/// <summary>
/// Randomizes contained elements.
/// </summary>
/// <inheritdoc />
public void Randomize() => Reset();

/// <summary>
/// Randomizes contained elements and limits their amount.
/// </summary>
/// <param name="amount">Amount of random elements to select from iterable object, negative values disable the limit, zero disables randomization.</param>
/// <inheritdoc />
public void Randomize(int amount) => Reset();

/// <summary>
/// Randomizes contained elements and limits their amount.
/// </summary>
/// <param name="amount">Percentage of random elements to select from iterable object, negative values disable the limit, zero disables randomization.</param>
/// <inheritdoc />
public void Randomize(float amount) => Reset();

/// <summary>
/// Randomizes contained elements and limits their amount.
/// </summary>
/// <param name="settings">Settings to use for randomization, negative values disable the limit, zero disables randomization.</param>
/// <inheritdoc />
public void Randomize(RandomSettings settings) => Reset();

/// <summary>
/// Resets iteration process.
/// </summary>
/// <inheritdoc />
public void Reset() => IsAtEnd = Count == 0;
}
Loading

0 comments on commit 0c1270e

Please sign in to comment.