Skip to content

Commit

Permalink
Added xml docs to List and Count.
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard Simpson committed Sep 29, 2015
1 parent 973bfcc commit 6f503c9
Showing 1 changed file with 30 additions and 18 deletions.
48 changes: 30 additions & 18 deletions src/chocolatey/GetChocolatey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,36 @@ public void RunConsole(string[] args)
runner.run(args, configuration, _container);
}

/// <summary>
/// Run chocolatey after setting the options, and list the results.
/// </summary>
/// <typeparam name="T">The typer of results you're expecting back.</typeparam>
public IEnumerable<T> List<T>()
{
extract_resources();
var configuration = create_configuration(new List<string>());
configuration.RegularOutput = true;
var runner = new GenericRunner();
return runner.list<T>(configuration, _container, isConsole: false, parseArgs: null);
}

/// <summary>
/// Run chocolatey after setting the options,
/// and get the count of items that would be returned if you listed the results.
/// </summary>
/// <remarks>
/// Is intended to be more efficient then simply calling <see cref="List{T}">List</see> and then Count() on the returned list.
/// It also returns the full count as is ignores paging.
/// </remarks>
public int Count()
{
extract_resources();
var configuration = create_configuration(new List<string>());
configuration.RegularOutput = true;
var runner = new GenericRunner();
return runner.count(configuration, _container, isConsole: false, parseArgs: null);
}

private ChocolateyConfiguration create_configuration(IList<string> args)
{
var configuration = new ChocolateyConfiguration();
Expand Down Expand Up @@ -213,24 +243,6 @@ private void extract_resources()

AssemblyFileExtractor.extract_all_resources_to_relative_directory(_container.GetInstance<IFileSystem>(), Assembly.GetAssembly(typeof(ChocolateyResourcesAssembly)), ApplicationParameters.InstallLocation, folders, ApplicationParameters.ChocolateyFileResources);
}

public IEnumerable<T> List<T>()
{
extract_resources();
var configuration = create_configuration(new List<string>());
configuration.RegularOutput = true;
var runner = new GenericRunner();
return runner.list<T>(configuration, _container, isConsole: false, parseArgs: null);
}

public int Count()
{
extract_resources();
var configuration = create_configuration(new List<string>());
configuration.RegularOutput = true;
var runner = new GenericRunner();
return runner.count(configuration, _container, isConsole: false, parseArgs: null);
}
}

// ReSharper restore InconsistentNaming
Expand Down

0 comments on commit 6f503c9

Please sign in to comment.