Skip to content

Commit

Permalink
Add documentation comments for ReasonStringBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
Kysluss committed Jul 13, 2024
1 parent c6cfece commit 245339c
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/FluentResults/Reasons/ReasonStringBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,31 @@
// ReSharper disable once CheckNamespace
namespace FluentResults
{
/// <summary>
/// Creates the text to dispay when serializing reason instances
/// </summary>
public class ReasonStringBuilder
{
private string _reasonType = string.Empty;
private readonly List<string> _infos = new List<string>();

/// <summary>
/// Specify the type of reason
/// </summary>
/// <param name="type">The type of reason</param>
/// <returns>Reference to the current Builder</returns>
public ReasonStringBuilder WithReasonType(Type type)
{
_reasonType = type.Name;
return this;
}

/// <summary>
/// Add an information label for the given value
/// </summary>
/// <param name="label">The label to display</param>
/// <param name="value">The value the label is for</param>
/// <returns>A reference to the current Builder</returns>
public ReasonStringBuilder WithInfo(string label, string value)
{
var infoString = value.ToLabelValueStringOrEmpty(label);
Expand All @@ -28,6 +42,10 @@ public ReasonStringBuilder WithInfo(string label, string value)
return this;
}

/// <summary>
/// Create the reason string from the current information
/// </summary>
/// <returns>The reason string</returns>
public string Build()
{
var reasonInfoText = _infos.Any()
Expand Down

0 comments on commit 245339c

Please sign in to comment.