Skip to content

Commit

Permalink
Added more XML document comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
cbrianball committed Jan 29, 2019
1 parent 27703cb commit 9e52e84
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 8 deletions.
11 changes: 11 additions & 0 deletions Args/ConventionBasedModelDefinitionInitializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,23 @@ public void Initialize<TModel>(IModelBindingDefinition<TModel> init)
init.SetOrdinalArguments(ordinalArguments.Select(a => a.Value));
}

/// <summary>
/// Returns the members for the movided model type
/// </summary>
/// <param name="modelType"></param>
/// <returns></returns>
protected virtual IEnumerable<MemberInfo> GetMembers(Type modelType)
{
return modelType.GetFields(BindingFlags.Instance | BindingFlags.Public)
.Concat(modelType.GetProperties(BindingFlags.Instance | BindingFlags.Public).Where(p => p.CanWrite).Cast<MemberInfo>());
}

/// <summary>
/// Detrmines the short version of a switch argument
/// </summary>
/// <param name="members"></param>
/// <param name="currentMember"></param>
/// <returns></returns>
protected virtual string DeriveShortName(IEnumerable<MemberInfo> members, MemberInfo currentMember)
{
return DeriveShortNameRecursive(members, currentMember, 1);
Expand Down
3 changes: 3 additions & 0 deletions Args/FluentModelBindingConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ public FluentMemberBindingConfiguration<TModel> ForMember<TResult>(Expression<Fu
}
}

/// <summary>
/// Helper methods for fluent configuration
/// </summary>
public static class FluentModelBindingConfigurationExtensions
{
/// <summary>
Expand Down
6 changes: 6 additions & 0 deletions Args/Help/HelpProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ public ModelHelp GenerateModelHelp<TModel>(IModelBindingDefinition<TModel> defin
return modelHelp;
}

/// <summary>
/// Generates help for members
/// </summary>
/// <typeparam name="TModel"></typeparam>
/// <param name="definition"></param>
/// <returns></returns>
public MemberHelp GenerateMemberHelp<TModel>(IMemberBindingDefinition<TModel> definition)
{
var memberHelp = new MemberHelp
Expand Down
12 changes: 12 additions & 0 deletions Args/Help/IHelpProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,19 @@ namespace Args.Help
/// </summary>
public interface IHelpProvider
{
/// <summary>
/// Generates help for the provided model definition
/// </summary>
/// <typeparam name="TModel"></typeparam>
/// <param name="definition"></param>
/// <returns></returns>
ModelHelp GenerateModelHelp<TModel>(IModelBindingDefinition<TModel> definition);
/// <summary>
/// Generates help for the provided member definition
/// </summary>
/// <typeparam name="TModel"></typeparam>
/// <param name="definition"></param>
/// <returns></returns>
MemberHelp GenerateMemberHelp<TModel>(IMemberBindingDefinition<TModel> definition);
}
}
23 changes: 19 additions & 4 deletions Args/Help/MemberHelp.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Generic;

namespace Args.Help
{
/// <summary>
/// Holds help information for model members
/// </summary>
public class MemberHelp
{
/// <summary>
/// Name of the member
/// </summary>
public string Name { get; set; }
/// <summary>
/// List of switches configured for the member
/// </summary>
public IEnumerable<string> Switches { get; set; }
/// <summary>
/// The default value if no value is provided
/// </summary>
public string DefaultValue { get; set; }
/// <summary>
/// Help text for the member
/// </summary>
public string HelpText { get; set; }
/// <summary>
/// Ordinal position for the member
/// </summary>
public int? OrdinalIndex { get; set; }
}
}
17 changes: 13 additions & 4 deletions Args/Help/ModelHelp.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Generic;

namespace Args.Help
{
/// <summary>
/// Holds help information for the model
/// </summary>
public class ModelHelp
{
/// <summary>
/// The delimited for the switches
/// </summary>
public string SwitchDelimiter { get; set; }
/// <summary>
/// List of members that are configured
/// </summary>
public IEnumerable<MemberHelp> Members { get; set; }
/// <summary>
/// Help text for the entire model
/// </summary>
public string HelpText { get; set; }
}
}

0 comments on commit 9e52e84

Please sign in to comment.