mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-07 20:30:41 +00:00
Class ApiOptionsSingleton was implemented in order to support proper unit tests.
Now ApiOptionsSingleton.Instance is used as ApiOptions.None static member instead of creation of new ApiOptions class each time when ApiOptions.None is invoked. Singleton pattern will allow write proper tests for methods that use ApiOptions.None as their parameter For instance, now "Arg.Is<ApiOptions>(options => options == ApiOptions.None)" construction can be used. Also, usage of sigleton has some posititve performance impact.
This commit is contained in:
@@ -7,9 +7,32 @@ namespace Octokit
|
||||
[DebuggerDisplay("{DebuggerDisplay,nq}")]
|
||||
public class ApiOptions
|
||||
{
|
||||
private class ApiOptionsSingleton
|
||||
{
|
||||
private static readonly ApiOptions _instance = new ApiOptions();
|
||||
|
||||
// Explicit static constructor to tell C# compiler
|
||||
// not to mark type as beforefieldinit
|
||||
static ApiOptionsSingleton()
|
||||
{
|
||||
}
|
||||
|
||||
private ApiOptionsSingleton()
|
||||
{
|
||||
}
|
||||
|
||||
public static ApiOptions Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static ApiOptions None
|
||||
{
|
||||
get { return new ApiOptions(); }
|
||||
get { return ApiOptionsSingleton.Instance; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user