Skip to content

Commit 555b7d0

Browse files
committed
update
Refactor factories
1 parent 8be3301 commit 555b7d0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+149
-83
lines changed

LICENSE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
* PureMVC MultiCore Framework for C# - Copyright © 2017 [Saad Shams](http://saad.io)
2-
* PureMVC - Copyright © 2017 [Futurescale, Inc](http://futurescale.com).
1+
* PureMVC MultiCore Framework for C# - Copyright © 2020 [Saad Shams](http://saad.io)
2+
* PureMVC - Copyright © 2020 [Futurescale, Inc](http://futurescale.com).
33
* All rights reserved.
44

55
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

PureMVC/Core/Controller.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// PureMVC C# Multicore
33
//
4-
// Copyright(c) 2017 Saad Shams <[email protected]>
4+
// Copyright(c) 2020 Saad Shams <[email protected]>
55
// Your reuse is governed by the Creative Commons Attribution 3.0 License
66
//
77

@@ -93,11 +93,11 @@ protected virtual void InitializeController()
9393
/// <c>Controller</c> Multiton Factory method.
9494
/// </summary>
9595
/// <param name="key">Key of controller</param>
96-
/// <param name="func">the <c>FuncDelegate</c> of the <c>IController</c></param>
96+
/// <param name="factory">the <c>FuncDelegate</c> of the <c>IController</c></param>
9797
/// <returns>the Multiton instance of <c>Controller</c></returns>
98-
public static IController GetInstance(string key, Func<string, IController> func)
98+
public static IController GetInstance(string key, Func<string, IController> factory)
9999
{
100-
return InstanceMap.GetOrAdd(key, new Lazy<IController>(() => func(key))).Value;
100+
return InstanceMap.GetOrAdd(key, new Lazy<IController>(factory(key))).Value;
101101
}
102102

103103
/// <summary>
@@ -107,9 +107,9 @@ public static IController GetInstance(string key, Func<string, IController> func
107107
/// <param name="notification">note an <c>INotification</c></param>
108108
public virtual void ExecuteCommand(INotification notification)
109109
{
110-
if (commandMap.TryGetValue(notification.Name, out var commandFunc))
110+
if (commandMap.TryGetValue(notification.Name, out var factory))
111111
{
112-
var commandInstance = commandFunc();
112+
var commandInstance = factory();
113113
commandInstance.InitializeNotifier(multitonKey);
114114
commandInstance.Execute(notification);
115115
}
@@ -131,14 +131,14 @@ public virtual void ExecuteCommand(INotification notification)
131131
/// </para>
132132
/// </remarks>
133133
/// <param name="notificationName">the name of the <c>INotification</c></param>
134-
/// <param name="commandFunc">the <c>Func Delegate</c> of the <c>ICommand</c></param>
135-
public virtual void RegisterCommand(string notificationName, Func<ICommand> commandFunc)
134+
/// <param name="factory">the <c>Func Delegate</c> of the <c>ICommand</c></param>
135+
public virtual void RegisterCommand(string notificationName, Func<ICommand> factory)
136136
{
137137
if (commandMap.TryGetValue(notificationName, out _) == false)
138138
{
139139
view.RegisterObserver(notificationName, new Observer(ExecuteCommand, this));
140140
}
141-
commandMap[notificationName] = commandFunc;
141+
commandMap[notificationName] = factory;
142142
}
143143

144144
/// <summary>

PureMVC/Core/Model.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// PureMVC C# Multicore
33
//
4-
// Copyright(c) 2017 Saad Shams <[email protected]>
4+
// Copyright(c) 2020 Saad Shams <[email protected]>
55
// Your reuse is governed by the Creative Commons Attribution 3.0 License
66
//
77

@@ -71,11 +71,11 @@ protected virtual void InitializeModel()
7171
/// <c>Model</c> Multiton Factory method.
7272
/// </summary>
7373
/// <param name="key">Key of model</param>
74-
/// <param name="func">the <c>FuncDelegate</c> of the <c>IModel</c></param>
74+
/// <param name="factory">the <c>FuncDelegate</c> of the <c>IModel</c></param>
7575
/// <returns>the instance for this Multiton key </returns>
76-
public static IModel GetInstance(string key, Func<string, IModel> func)
76+
public static IModel GetInstance(string key, Func<string, IModel> factory)
7777
{
78-
return InstanceMap.GetOrAdd(key, new Lazy<IModel>(() => func(key))).Value;
78+
return InstanceMap.GetOrAdd(key, new Lazy<IModel>(factory(key))).Value;
7979
}
8080

8181
/// <summary>

PureMVC/Core/View.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// PureMVC C# Multicore
33
//
4-
// Copyright(c) 2017 Saad Shams <[email protected]>
4+
// Copyright(c) 2020 Saad Shams <[email protected]>
55
// Your reuse is governed by the Creative Commons Attribution 3.0 License
66
//
77

@@ -72,11 +72,11 @@ protected virtual void InitializeView()
7272
/// <c>View</c> Multiton Factory method.
7373
/// </summary>
7474
/// <param name="key">Key of view</param>
75-
/// <param name="func">the <c>FuncDelegate</c> of the <c>IView</c></param>
75+
/// <param name="factory">the <c>FuncDelegate</c> of the <c>IView</c></param>
7676
/// <returns>the instance for this Multiton key </returns>
77-
public static IView GetInstance(string key, Func<string, IView> func)
77+
public static IView GetInstance(string key, Func<string, IView> factory)
7878
{
79-
return InstanceMap.GetOrAdd(key, new Lazy<IView>(() => func(key))).Value;
79+
return InstanceMap.GetOrAdd(key, new Lazy<IView>(factory(key))).Value;
8080
}
8181

8282
/// <summary>

PureMVC/Interfaces/ICommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// PureMVC C# Multicore
33
//
4-
// Copyright(c) 2017 Saad Shams <[email protected]>
4+
// Copyright(c) 2020 Saad Shams <[email protected]>
55
// Your reuse is governed by the Creative Commons Attribution 3.0 License
66
//
77

PureMVC/Interfaces/IController.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// PureMVC C# Multicore
33
//
4-
// Copyright(c) 2017 Saad Shams <[email protected]>
4+
// Copyright(c) 2020 Saad Shams <[email protected]>
55
// Your reuse is governed by the Creative Commons Attribution 3.0 License
66
//
77

@@ -43,8 +43,8 @@ public interface IController
4343
/// for a particular <c>INotification</c>.
4444
/// </summary>
4545
/// <param name="notificationName">the name of the <c>INotification</c></param>
46-
/// <param name="commandFunc">the FuncDelegate of the <c>ICommand</c></param>
47-
void RegisterCommand(string notificationName, Func<ICommand> commandFunc);
46+
/// <param name="factory">the FuncDelegate of the <c>ICommand</c></param>
47+
void RegisterCommand(string notificationName, Func<ICommand> factory);
4848

4949
/// <summary>
5050
/// Execute the <c>ICommand</c> previously registered as the

PureMVC/Interfaces/IFacade.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// PureMVC C# Multicore
33
//
4-
// Copyright(c) 2017 Saad Shams <[email protected]>
4+
// Copyright(c) 2020 Saad Shams <[email protected]>
55
// Your reuse is governed by the Creative Commons Attribution 3.0 License
66
//
77

PureMVC/Interfaces/IMediator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// PureMVC C# Multicore
33
//
4-
// Copyright(c) 2017 Saad Shams <[email protected]>
4+
// Copyright(c) 2020 Saad Shams <[email protected]>
55
// Your reuse is governed by the Creative Commons Attribution 3.0 License
66
//
77

PureMVC/Interfaces/IModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// PureMVC C# Multicore
33
//
4-
// Copyright(c) 2017 Saad Shams <[email protected]>
4+
// Copyright(c) 2020 Saad Shams <[email protected]>
55
// Your reuse is governed by the Creative Commons Attribution 3.0 License
66
//
77

PureMVC/Interfaces/INotification.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// PureMVC C# Multicore
33
//
4-
// Copyright(c) 2017 Saad Shams <[email protected]>
4+
// Copyright(c) 2020 Saad Shams <[email protected]>
55
// Your reuse is governed by the Creative Commons Attribution 3.0 License
66
//
77

0 commit comments

Comments
 (0)