Skip to content

Commit

Permalink
Lazy initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
tbarlow12 committed Mar 12, 2019
1 parent 99687b1 commit f1b1eab
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public sealed class AzDOBoardService : BoardService
{
AzDOService github;

private static readonly Lazy<AzDOBoardService> lazy = new Lazy<AzDOBoardService>();
private static readonly Lazy<AzDOBoardService> lazy = new Lazy<AzDOBoardService>(() => new AzDOBoardService());

public static AzDOBoardService Instance { get => lazy.Value; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class TrelloBoardService : BoardService
{
TrelloService trello;

private static readonly Lazy<TrelloBoardService> lazy = new Lazy<TrelloBoardService>();
private static readonly Lazy<TrelloBoardService> lazy = new Lazy<TrelloBoardService>(() => new TrelloBoardService());

public static TrelloBoardService Instance { get => lazy.Value; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class TrelloCardService : CardService
{
TrelloService trello;

private static readonly Lazy<TrelloCardService> lazy = new Lazy<TrelloCardService>();
private static readonly Lazy<TrelloCardService> lazy = new Lazy<TrelloCardService>(() => new TrelloCardService());

public static TrelloCardService Instance { get => lazy.Value; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class TrelloLabelService : LabelService
{
TrelloService trello;

private static readonly Lazy<TrelloLabelService> lazy = new Lazy<TrelloLabelService>();
private static readonly Lazy<TrelloLabelService> lazy = new Lazy<TrelloLabelService>(() => new TrelloLabelService());
public static TrelloLabelService Instance { get => lazy.Value; }

private TrelloLabelService()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class TrelloListService : ListService
{
TrelloService trello;

private static readonly Lazy<TrelloListService> lazy = new Lazy<TrelloListService>();
private static readonly Lazy<TrelloListService> lazy = new Lazy<TrelloListService>(() => new TrelloListService());

public static TrelloListService Instance { get => lazy.Value; }

Expand Down
2 changes: 1 addition & 1 deletion TaskBoardAssistant/Adapters/Trello/TrelloServiceFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace TaskBoardAssistant.Adapters.Trello
{
public class TrelloServiceFactory : ITaskBoardFactory
{
private static readonly Lazy<TrelloServiceFactory> lazy = new Lazy<TrelloServiceFactory>();
private static readonly Lazy<TrelloServiceFactory> lazy = new Lazy<TrelloServiceFactory>(() => new TrelloServiceFactory());
public static TrelloServiceFactory Instance { get => lazy.Value; }
private TrelloServiceFactory()
{
Expand Down
20 changes: 20 additions & 0 deletions TaskBoardAssistant/Assistant.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,26 @@ public static IEnumerable<PolicyResult> ExecuteFromBlob(string connectionString,
return Execute(policies);
}

public static IEnumerable<PolicyResult> ExecuteFromYmlString(string policies)
{
return Execute(PolicyService.YmlFromString(policies));
}

public static IEnumerable<PolicyResult> ExecuteFromJsonString(string policies)
{
return Execute(PolicyService.JsonFromString(policies));
}

public static IEnumerable<PolicyResult> ExecuteFromYmlPath(string path)
{
return Execute(PolicyService.YmlFromFile(path));
}

public static IEnumerable<PolicyResult> ExecuteFromJsonPath(string path)
{
return Execute(PolicyService.JsonFromFile(path));
}

private static IEnumerable<PolicyResult> Execute(PolicyCollection collection)
{
ServiceFactory serviceFactory = new ServiceFactory();
Expand Down
1 change: 1 addition & 0 deletions TaskBoardAssistant/TaskBoardAssistant.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<Authors>Tanner Barlow</Authors>
<Version>1.0.0</Version>
<Description>Create and execute policies to automate the management of your task board</Description>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>

<ItemGroup>
Expand Down
1 change: 0 additions & 1 deletion UnitTests/TestListService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@ public void TestFactory()
Assert.IsNotNull(listService);
}
}

}

0 comments on commit f1b1eab

Please sign in to comment.