Skip to content

Commit e58a0b7

Browse files
committed
update
multitons via lazy factory methods
1 parent 555b7d0 commit e58a0b7

File tree

7 files changed

+51
-14
lines changed

7 files changed

+51
-14
lines changed

.gitignore

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
*.swp
2+
*.*~
3+
project.lock.json
4+
.DS_Store
5+
*.pyc
6+
nupkg/
7+
8+
# Visual Studio Code
9+
.vscode
10+
11+
# Rider
12+
.idea
13+
14+
# User-specific files
15+
*.suo
16+
*.user
17+
*.userosscache
18+
*.sln.docstates
19+
20+
# Build results
21+
[Dd]ebug/
22+
[Dd]ebugPublic/
23+
[Rr]elease/
24+
[Rr]eleases/
25+
x64/
26+
x86/
27+
build/
28+
bld/
29+
[Bb]in/
30+
[Oo]bj/
31+
[Oo]ut/
32+
msbuild.log
33+
msbuild.err
34+
msbuild.wrn
35+
36+
# Visual Studio 2015
37+
.vs/

PureMVC/Core/Controller.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public class Controller: IController
5959
public Controller(string key)
6060
{
6161
multitonKey = key;
62-
InstanceMap.TryAdd(multitonKey, new Lazy<IController>(this));
62+
InstanceMap.TryAdd(multitonKey, new Lazy<IController>(() => this));
6363
commandMap = new ConcurrentDictionary<string, Func<ICommand>>();
6464
InitializeController();
6565
}
@@ -97,7 +97,7 @@ protected virtual void InitializeController()
9797
/// <returns>the Multiton instance of <c>Controller</c></returns>
9898
public static IController GetInstance(string key, Func<string, IController> factory)
9999
{
100-
return InstanceMap.GetOrAdd(key, new Lazy<IController>(factory(key))).Value;
100+
return InstanceMap.GetOrAdd(key, new Lazy<IController>(() => factory(key))).Value;
101101
}
102102

103103
/// <summary>

PureMVC/Core/Model.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public class Model: IModel
4747
public Model(string key)
4848
{
4949
multitonKey = key;
50-
InstanceMap.TryAdd(key, new Lazy<IModel>(this));
50+
InstanceMap.TryAdd(key, new Lazy<IModel>(() => this));
5151
proxyMap = new ConcurrentDictionary<string, IProxy>();
5252
InitializeModel();
5353
}
@@ -75,7 +75,7 @@ protected virtual void InitializeModel()
7575
/// <returns>the instance for this Multiton key </returns>
7676
public static IModel GetInstance(string key, Func<string, IModel> factory)
7777
{
78-
return InstanceMap.GetOrAdd(key, new Lazy<IModel>(factory(key))).Value;
78+
return InstanceMap.GetOrAdd(key, new Lazy<IModel>(() => factory(key))).Value;
7979
}
8080

8181
/// <summary>

PureMVC/Core/View.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public class View: IView
4747
public View(string key)
4848
{
4949
multitonKey = key;
50-
InstanceMap.TryAdd(key, new Lazy<IView>(this));
50+
InstanceMap.TryAdd(key, new Lazy<IView>(() => this));
5151
mediatorMap = new ConcurrentDictionary<string, IMediator>();
5252
observerMap = new ConcurrentDictionary<string, IList<IObserver>>();
5353
InitializeView();
@@ -76,7 +76,7 @@ protected virtual void InitializeView()
7676
/// <returns>the instance for this Multiton key </returns>
7777
public static IView GetInstance(string key, Func<string, IView> factory)
7878
{
79-
return InstanceMap.GetOrAdd(key, new Lazy<IView>(factory(key))).Value;
79+
return InstanceMap.GetOrAdd(key, new Lazy<IView>(() => factory(key))).Value;
8080
}
8181

8282
/// <summary>

PureMVC/Patterns/Facade/Facade.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public class Facade: IFacade
3737
public Facade(string key)
3838
{
3939
InitializeNotifier(key);
40-
InstanceMap.TryAdd(key, new Lazy<IFacade>(this));
40+
InstanceMap.TryAdd(key, new Lazy<IFacade>(() => this));
4141
InitializeFacade();
4242
}
4343

@@ -66,7 +66,7 @@ protected virtual void InitializeFacade()
6666
/// <returns>the Multiton instance of the Facade</returns>
6767
public static IFacade GetInstance(string key, Func<string, IFacade> factory)
6868
{
69-
return InstanceMap.GetOrAdd(key, new Lazy<IFacade>(factory(key))).Value;
69+
return InstanceMap.GetOrAdd(key, new Lazy<IFacade>(() => factory(key))).Value;
7070
}
7171

7272
/// <summary>

PureMVC/PureMVC.csproj

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp3.0</TargetFramework>
4+
<TargetFramework>net5.0</TargetFramework>
55
<PackageId>PureMVC.Multicore</PackageId>
6-
<Version>2.1.0</Version>
6+
<Version>2.2.0</Version>
77
<Description>PureMVC is a lightweight framework for creating applications based upon the classic Model-View-Controller design meta-pattern.</Description>
88
<Copyright>Copyright © 2017 Saad Shams, Futurescale, Inc.</Copyright>
99
<license>Creative Commons Attribution 3.0</license>
@@ -15,8 +15,8 @@
1515
<Authors>Saad Shams</Authors>
1616
<Company>Futurescale, Inc.</Company>
1717
<PackageTags>PureMVC Multicore MVC</PackageTags>
18-
<AssemblyVersion>2.1.0.0</AssemblyVersion>
19-
<FileVersion>2.1.0.0</FileVersion>
18+
<AssemblyVersion>2.2.0.0</AssemblyVersion>
19+
<FileVersion>2.2.0.0</FileVersion>
2020
<NeutralLanguage>en-US</NeutralLanguage>
2121
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
2222
</PropertyGroup>

PureMVCTests/PureMVCTests.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp3.0</TargetFramework>
4+
<TargetFramework>net5.0</TargetFramework>
55

66
<IsPackable>false</IsPackable>
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0"/>
10+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0"/>
1111
<PackageReference Include="MSTest.TestAdapter" Version="1.4.0"/>
1212
<PackageReference Include="MSTest.TestFramework" Version="1.4.0"/>
1313
<PackageReference Include="coverlet.collector" Version="1.0.1"/>

0 commit comments

Comments
 (0)