Skip to content

Commit 842bf58

Browse files
authored
Merge pull request #1915 from johnhenley/dev10/features/DI-1913
TASK: Implement ServiceLocatorService/DI
2 parents a012602 + 6490313 commit 842bf58

171 files changed

Lines changed: 3313 additions & 1664 deletions

File tree

Some content is hidden

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

.github/copilot-instructions.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,21 @@
108108
- Use imperative mood.
109109
- Reference issue numbers with # prefix and link to the issue when applicable.
110110

111+
## Commit Messages
112+
- Use subject line format "TYPE: description".
113+
- Use types: FIX, ENH, TASK, DOC, TEST.
114+
- Keep subject lines under 50 characters where possible.
115+
- Use imperative mood (for example, "Add feature" not "Added feature").
116+
- Reference issue numbers with # prefix and link to the issue when applicable.
117+
118+
## Pull Requests
119+
- Use .github/PULL_REQUEST_TEMPLATE.md.
120+
- Use subject line format "TYPE: description".
121+
- Use types: FIX, ENH, TASK, DOC, TEST.
122+
- Keep subject lines under 50 characters where possible.
123+
- Use imperative mood.
124+
- Reference issue numbers with # prefix and link to the issue when applicable.
125+
111126
## Cross-repo references for `DotNetNuke`
112127

113128
When code references the DotNetNuke namespace and required types/source files are not present in this workspace, consult:

Dnn.CommunityForums/ActiveForumViewer.ascx.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ protected override void OnLoad(EventArgs e)
5050
else
5151
{
5252
viewType = Views.ForumView;
53-
this.ctlForumLoader.ForumId = -1;
5453
this.ctlForumLoader.ForumGroupId = tmpForumOrGroupId;
5554
}
5655

Dnn.CommunityForums/ActiveForumViewerSettings.ascx.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ public override void UpdateSettings()
114114
public void LoadForums()
115115
{
116116
int i = 0;
117-
var mc = new DotNetNuke.Entities.Modules.ModuleController();
118-
var tc = new DotNetNuke.Entities.Tabs.TabController();
117+
var mc = DotNetNuke.Entities.Modules.ModuleController.Instance;
118+
var tc = DotNetNuke.Entities.Tabs.TabController.Instance;
119119
DotNetNuke.Entities.Tabs.TabInfo ti;
120120
foreach (DotNetNuke.Entities.Modules.ModuleInfo mi in mc.GetModules(this.PortalId))
121121
{
@@ -139,7 +139,7 @@ public void LoadForums()
139139
public void LoadForumGroups(int forumModuleID)
140140
{
141141
this.drpForum.Items.Insert(0, new ListItem("-- Select a Group or Forum --", "-1"));
142-
var forums = new DotNetNuke.Modules.ActiveForums.Controllers.ForumController().GetForums(forumModuleID).OrderBy(f => f.ForumGroup.SortOrder).ThenBy(f => f.SortOrder).ToList();
142+
var forums = DotNetNuke.Modules.ActiveForums.Controllers.ForumController.Instance.GetForums(forumModuleID).OrderBy(f => f.ForumGroup.SortOrder).ThenBy(f => f.SortOrder).ToList();
143143

144144
int i = 1;
145145
string groupName = string.Empty;

Dnn.CommunityForums/Classic.ascx.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ protected override void OnLoad(EventArgs e)
5656

5757
#if DEBUG
5858
//ForumsConfig.Install_Upgrade_CreateForumDefaultSettingsAndSecurity_080200();
59-
//new DotNetNuke.Modules.ActiveForums.Controllers.PermissionController().RemoveUnused(this.ForumModuleId);
59+
//DotNetNuke.Modules.ActiveForums.Controllers.PermissionController.Instance.RemoveUnused(this.ForumModuleId);
6060
//DotNetNuke.Modules.ActiveForums.Helpers.UpgradeModuleSettings.AddUrlPrefixLikes_080200();
6161
//ForumsConfig.Install_LikeNotificationType_080200();
6262
//ForumsConfig.Install_PinNotificationType_080200();
@@ -85,11 +85,11 @@ protected override void OnLoad(EventArgs e)
8585
if (this.Request.QueryString[Literals.GroupId] != null && Utilities.IsNumeric(this.Request.QueryString[Literals.GroupId]))
8686
{
8787
this.SocialGroupId = Convert.ToInt32(this.Request.QueryString[Literals.GroupId]);
88-
this.ForumIds = DotNetNuke.Modules.ActiveForums.Controllers.ForumController.GetForumIdsBySocialGroup(this.ForumModuleId, this.SocialGroupId);
88+
this.ForumIds = DotNetNuke.Modules.ActiveForums.Controllers.ForumController.Instance.GetForumIdsBySocialGroup(this.ForumModuleId, this.SocialGroupId);
8989
if (this.ForumIds.Any())
9090
{
9191
this.ForumIds = new System.Collections.Generic.HashSet<int> { this.ForumIds.First() };
92-
this.ForumInfo = new DotNetNuke.Modules.ActiveForums.Controllers.ForumController().GetById(this.ForumIds.First(), this.ForumModuleId);
92+
this.ForumInfo = DotNetNuke.Modules.ActiveForums.Controllers.ForumController.Instance.GetById(this.ForumModuleId, this.ForumIds.First());
9393
this.ForumId = this.ForumInfo.ForumID;
9494
}
9595
}
@@ -282,7 +282,7 @@ private void GetControl(string view, string options)
282282
ctl.SocialGroupId = this.SocialGroupId;
283283
if (this.SocialGroupId > 0)
284284
{
285-
this.ForumIds = DotNetNuke.Modules.ActiveForums.Controllers.ForumController.GetForumIdsBySocialGroup(this.ForumModuleId, this.SocialGroupId);
285+
this.ForumIds = DotNetNuke.Modules.ActiveForums.Controllers.ForumController.Instance.GetForumIdsBySocialGroup(this.ForumModuleId, this.SocialGroupId);
286286

287287
if (!this.ForumIds.Any())
288288
{
@@ -301,13 +301,13 @@ private void GetControl(string view, string options)
301301
else
302302
{
303303
DotNetNuke.Modules.ActiveForums.Controllers.ForumController.CreateSocialGroupForum(this.PortalId, this.ModuleId, this.SocialGroupId, Convert.ToInt32(htSettings[SettingKeys.SocialGroupModeForumGroupTemplate].ToString()), role.RoleName + " Discussions", role.Description, !role.IsPublic, htSettings[SettingKeys.SocialGroupModeForumConfig].ToString());
304-
this.ForumIds = DotNetNuke.Modules.ActiveForums.Controllers.ForumController.GetForumIdsBySocialGroup(this.ForumModuleId, this.SocialGroupId);
304+
this.ForumIds = DotNetNuke.Modules.ActiveForums.Controllers.ForumController.Instance.GetForumIdsBySocialGroup(this.ForumModuleId, this.SocialGroupId);
305305
}
306306
}
307307
}
308308
else if (this.ForumGroupId > 0)
309309
{
310-
this.ForumIds = new DotNetNuke.Modules.ActiveForums.Controllers.ForumController().GetForums(this.ForumModuleId).Where(f => f.Active && !f.Hidden && f.ForumGroup != null && !f.ForumGroup.Hidden).Select(forum => forum.ForumID).ToHashSet();
310+
this.ForumIds = DotNetNuke.Modules.ActiveForums.Controllers.ForumController.Instance.GetForums(this.ForumModuleId).Where(f => f.Active && !f.Hidden && f.ForumGroup != null && !f.ForumGroup.Hidden).Select(forum => forum.ForumID).ToHashSet();
311311
}
312312
else if (!this.ForumIds.Any())
313313
{

Dnn.CommunityForums/Controllers/ArchivedUrlController.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,17 @@
2020

2121
namespace DotNetNuke.Modules.ActiveForums.Controllers
2222
{
23+
using System;
2324
using System.Linq;
24-
using System.Runtime.Remoting.Messaging;
2525

26-
using DotNetNuke.Modules.ActiveForums.Entities;
27-
28-
internal class ArchivedUrlController : RepositoryControllerBase<DotNetNuke.Modules.ActiveForums.Entities.ArchivedURLInfo>
26+
internal class ArchivedURLController : RepositoryServiceLocatorBase<DotNetNuke.Modules.ActiveForums.Entities.ArchivedURLInfo, IArchivedURLController, ArchivedURLController>, IArchivedURLController
2927
{
30-
internal DotNetNuke.Modules.ActiveForums.Entities.ArchivedURLInfo FindByURL(int portalId, string url)
28+
protected override Func<IArchivedURLController> GetFactory()
29+
{
30+
return () => new ArchivedURLController();
31+
}
32+
33+
public DotNetNuke.Modules.ActiveForums.Entities.ArchivedURLInfo FindByURL(int portalId, string url)
3134
{
3235
string cachekey = string.Format(CacheKeys.ArchivedUrl, portalId, url);
3336
DotNetNuke.Modules.ActiveForums.Entities.ArchivedURLInfo archivedURLInfo = DotNetNuke.Modules.ActiveForums.DataCache.ContentCacheRetrieve(portalId, cachekey) as DotNetNuke.Modules.ActiveForums.Entities.ArchivedURLInfo;
@@ -43,7 +46,7 @@ internal DotNetNuke.Modules.ActiveForums.Entities.ArchivedURLInfo FindByURL(int
4346
normalizedUrl = normalizedUrl + '/';
4447
}
4548

46-
archivedURLInfo = this.Find("WHERE PortalId = @0 AND URL_Hash = CONVERT(binary(16), HASHBYTES('MD5', CONVERT(varbinary(8000), @1))) AND URL = @1", portalId, normalizedUrl).FirstOrDefault();
49+
archivedURLInfo = this._repositoryControllerBase.Find("WHERE PortalId = @0 AND URL_Hash = CONVERT(binary(16), HASHBYTES('MD5', CONVERT(varbinary(8000), @1))) AND URL = @1", portalId, normalizedUrl).FirstOrDefault();
4750
}
4851

4952
DotNetNuke.Modules.ActiveForums.DataCache.ContentCacheStore(portalId, cachekey, archivedURLInfo);

Dnn.CommunityForums/Controllers/AttachmentController.cs

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -38,59 +38,64 @@ namespace DotNetNuke.Modules.ActiveForums.Controllers
3838
/// <summary>
3939
/// Controller for managing Attachments in the DNN Community Forums module.
4040
/// </summary>
41-
internal class AttachmentController : DotNetNuke.Modules.ActiveForums.Controllers.RepositoryControllerBase<DotNetNuke.Modules.ActiveForums.Entities.AttachmentInfo>
41+
internal class AttachmentController : RepositoryServiceLocatorBase<DotNetNuke.Modules.ActiveForums.Entities.AttachmentInfo, IAttachmentController, AttachmentController>, IAttachmentController
4242
{
4343
private readonly DotNetNuke.Services.FileSystem.IFolderManager folderManager;
4444
private readonly DotNetNuke.Services.FileSystem.IFileManager fileManager;
45-
private readonly DotNetNuke.Modules.ActiveForums.Controllers.ContentController contentController;
45+
private readonly DotNetNuke.Modules.ActiveForums.Controllers.IContentController contentController;
46+
47+
protected override Func<IAttachmentController> GetFactory()
48+
{
49+
return () => new AttachmentController();
50+
}
4651

4752
public AttachmentController()
4853
: this(
4954
DotNetNuke.Services.FileSystem.FolderManager.Instance,
5055
DotNetNuke.Services.FileSystem.FileManager.Instance,
51-
new DotNetNuke.Modules.ActiveForums.Controllers.ContentController())
56+
DotNetNuke.Modules.ActiveForums.Controllers.ContentController.Instance)
5257
{
5358
}
5459

5560
public AttachmentController(
5661
DotNetNuke.Services.FileSystem.IFolderManager folderManager,
5762
DotNetNuke.Services.FileSystem.IFileManager fileManager,
58-
DotNetNuke.Modules.ActiveForums.Controllers.ContentController contentController)
63+
DotNetNuke.Modules.ActiveForums.Controllers.IContentController contentController)
5964
{
6065
this.folderManager = folderManager;
6166
this.fileManager = fileManager;
6267
this.contentController = contentController;
6368
}
6469

65-
internal IEnumerable<DotNetNuke.Modules.ActiveForums.Entities.AttachmentInfo> GetByContentId(int contentId)
70+
public IEnumerable<DotNetNuke.Modules.ActiveForums.Entities.AttachmentInfo> GetByContentId(int contentId)
6671
{
67-
return this.Find("WHERE ContentId = @0", contentId);
72+
return this._repositoryControllerBase.Find("WHERE ContentId = @0", contentId);
6873
}
6974

7075
internal new void Delete(DotNetNuke.Modules.ActiveForums.Entities.AttachmentInfo attachmentInfo)
7176
{
72-
base.Delete(attachmentInfo);
77+
this._repositoryControllerBase.Delete(attachmentInfo);
7378
}
7479

75-
internal new DotNetNuke.Modules.ActiveForums.Entities.AttachmentInfo Insert(DotNetNuke.Modules.ActiveForums.Entities.AttachmentInfo attachmentInfo)
80+
public new DotNetNuke.Modules.ActiveForums.Entities.AttachmentInfo Insert(DotNetNuke.Modules.ActiveForums.Entities.AttachmentInfo attachmentInfo)
7681
{
77-
base.Insert(attachmentInfo);
78-
return this.GetById(attachmentInfo.AttachmentId);
82+
this._repositoryControllerBase.Insert(attachmentInfo);
83+
return this._repositoryControllerBase.GetById(attachmentInfo.AttachmentId);
7984
}
8085

81-
internal new DotNetNuke.Modules.ActiveForums.Entities.AttachmentInfo Update(DotNetNuke.Modules.ActiveForums.Entities.AttachmentInfo attachmentInfo)
86+
public new DotNetNuke.Modules.ActiveForums.Entities.AttachmentInfo Update(DotNetNuke.Modules.ActiveForums.Entities.AttachmentInfo attachmentInfo)
8287
{
83-
base.Update(attachmentInfo);
84-
return this.GetById(attachmentInfo.AttachmentId);
88+
this._repositoryControllerBase.Update(attachmentInfo);
89+
return this._repositoryControllerBase.GetById(attachmentInfo.AttachmentId);
8590
}
8691

87-
internal new DotNetNuke.Modules.ActiveForums.Entities.AttachmentInfo Save(DotNetNuke.Modules.ActiveForums.Entities.AttachmentInfo attachmentInfo)
92+
public new DotNetNuke.Modules.ActiveForums.Entities.AttachmentInfo Save(DotNetNuke.Modules.ActiveForums.Entities.AttachmentInfo attachmentInfo)
8893
{
89-
this.Save(attachmentInfo, attachmentInfo.AttachmentId);
90-
return this.GetById(attachmentInfo.AttachmentId);
94+
this._repositoryControllerBase.Save(attachmentInfo, attachmentInfo.AttachmentId);
95+
return this._repositoryControllerBase.GetById(attachmentInfo.AttachmentId);
9196
}
9297

93-
internal void RelocateAttachment(DotNetNuke.Modules.ActiveForums.Entities.AttachmentInfo attachment)
98+
public void RelocateAttachment(DotNetNuke.Modules.ActiveForums.Entities.AttachmentInfo attachment)
9499
{
95100
if (attachment == null)
96101
{
@@ -99,7 +104,7 @@ internal void RelocateAttachment(DotNetNuke.Modules.ActiveForums.Entities.Attach
99104

100105
DotNetNuke.Services.FileSystem.IFileInfo file = null;
101106

102-
var content = this.contentController.GetById(attachment.ContentId, DotNetNuke.Common.Utilities.Null.NullInteger);
107+
var content = this.contentController.GetById(DotNetNuke.Common.Utilities.Null.NullInteger, attachment.ContentId);
103108
if (content != null)
104109
{
105110
if (attachment.DisplayInline == true)
@@ -185,7 +190,7 @@ internal void RelocateAttachment(DotNetNuke.Modules.ActiveForums.Entities.Attach
185190
}
186191
}
187192

188-
internal void RelocateInlineAttachment(DotNetNuke.Modules.ActiveForums.Entities.AttachmentInfo attachment, DotNetNuke.Modules.ActiveForums.Entities.ContentInfo content)
193+
public void RelocateInlineAttachment(DotNetNuke.Modules.ActiveForums.Entities.AttachmentInfo attachment, DotNetNuke.Modules.ActiveForums.Entities.ContentInfo content)
189194
{
190195
if (attachment == null || attachment.DisplayInline == false)
191196
{

Dnn.CommunityForums/Controllers/BadgeController.cs

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,64 +23,65 @@ namespace DotNetNuke.Modules.ActiveForums.Controllers
2323
using System;
2424
using System.Collections.Generic;
2525
using System.Linq;
26-
using DotNetNuke.Modules.ActiveForums.Entities;
27-
using static DotNetNuke.Entities.Modules.DesktopModuleInfo;
2826

2927
/// <summary>
3028
/// Controller for managing badges in the DNN Community Forums module.
3129
/// </summary>
32-
internal class BadgeController : DotNetNuke.Modules.ActiveForums.Controllers.RepositoryControllerBase<DotNetNuke.Modules.ActiveForums.Entities.BadgeInfo>
30+
internal class BadgeController : RepositoryServiceLocatorBase<DotNetNuke.Modules.ActiveForums.Entities.BadgeInfo, IBadgeController, BadgeController>, IBadgeController
3331
{
34-
internal override string cacheKeyTemplate => CacheKeys.BadgeInfo;
32+
protected override Func<IBadgeController> GetFactory()
33+
{
34+
return () => new BadgeController();
35+
}
3536

3637
/// <summary>
3738
/// Gets all active badges.
3839
/// </summary>
3940
/// <returns>List of active badges.</returns>
4041
public IEnumerable<DotNetNuke.Modules.ActiveForums.Entities.BadgeInfo> GetActiveBadges(int moduleId)
4142
{
42-
return this.Get().Where(b => b.ModuleId.Equals(moduleId));
43+
return this._repositoryControllerBase.Get().Where(b => b.ModuleId.Equals(moduleId));
4344
}
4445

45-
internal DotNetNuke.Modules.ActiveForums.Entities.BadgeInfo GetById(int badgeId, int moduleId)
46+
public DotNetNuke.Modules.ActiveForums.Entities.BadgeInfo GetById(int moduleId, int badgeId)
4647
{
47-
var cachekey = this.GetCacheKey(moduleId: moduleId, id: badgeId);
48-
DotNetNuke.Modules.ActiveForums.Entities.BadgeInfo badgeInfo = DataCache.SettingsCacheRetrieve(moduleId, cachekey) as DotNetNuke.Modules.ActiveForums.Entities.BadgeInfo;
48+
var cachekey = string.Format(CacheKeys.BadgeInfo, moduleId, badgeId);
49+
var badgeInfo = DataCache.SettingsCacheRetrieve(moduleId, cachekey) as DotNetNuke.Modules.ActiveForums.Entities.BadgeInfo;
4950
if (badgeInfo == null)
5051
{
51-
badgeInfo = base.GetById(badgeId, moduleId);
52+
badgeInfo = this._repositoryControllerBase.GetById(badgeId, moduleId);
5253
DotNetNuke.Modules.ActiveForums.DataCache.SettingsCacheStore(moduleId, cachekey, badgeInfo);
5354
}
5455

5556
return badgeInfo;
5657
}
5758

58-
internal new void DeleteById<TProperty>(TProperty badgeId, int moduleId)
59+
public new void DeleteById<TProperty>(int moduleId, TProperty badgeId)
5960
{
60-
var cachekey = this.GetCacheKey(moduleId: moduleId, id: badgeId);
61+
var cachekey = string.Format(CacheKeys.BadgeInfo, moduleId, badgeId);
6162
DataCache.SettingsCacheClear(moduleId, cachekey);
62-
this.DeleteById(badgeId);
63+
this._repositoryControllerBase.DeleteById(badgeId);
6364
}
6465

65-
internal new void Delete(DotNetNuke.Modules.ActiveForums.Entities.BadgeInfo badgeInfo)
66+
public new void Delete(DotNetNuke.Modules.ActiveForums.Entities.BadgeInfo badgeInfo)
6667
{
67-
var cachekey = this.GetCacheKey(moduleId: badgeInfo.ModuleId, id: badgeInfo.BadgeId);
68+
var cachekey = string.Format(CacheKeys.BadgeInfo, badgeInfo.ModuleId, badgeInfo.BadgeId);
6869
DataCache.SettingsCacheClear(badgeInfo.ModuleId, cachekey);
69-
base.Delete(badgeInfo);
70+
this._repositoryControllerBase.Delete(badgeInfo);
7071
}
7172

72-
internal new DotNetNuke.Modules.ActiveForums.Entities.BadgeInfo Insert(DotNetNuke.Modules.ActiveForums.Entities.BadgeInfo badgeInfo)
73+
public new DotNetNuke.Modules.ActiveForums.Entities.BadgeInfo Insert(DotNetNuke.Modules.ActiveForums.Entities.BadgeInfo badgeInfo)
7374
{
74-
base.Insert(badgeInfo);
75-
return this.GetById(badgeInfo.BadgeId, badgeInfo.ModuleId);
75+
this._repositoryControllerBase.Insert(badgeInfo);
76+
return this.GetById(badgeInfo.ModuleId, badgeInfo.BadgeId);
7677
}
7778

78-
internal new DotNetNuke.Modules.ActiveForums.Entities.BadgeInfo Update(DotNetNuke.Modules.ActiveForums.Entities.BadgeInfo badgeInfo)
79+
public new DotNetNuke.Modules.ActiveForums.Entities.BadgeInfo Update(DotNetNuke.Modules.ActiveForums.Entities.BadgeInfo badgeInfo)
7980
{
80-
var cachekey = this.GetCacheKey(moduleId: badgeInfo.ModuleId, id: badgeInfo.BadgeId);
81+
var cachekey = string.Format(CacheKeys.BadgeInfo, badgeInfo.ModuleId, badgeInfo.BadgeId);
8182
DataCache.SettingsCacheClear(badgeInfo.ModuleId, cachekey);
82-
base.Update(badgeInfo);
83-
return this.GetById(badgeInfo.BadgeId, badgeInfo.ModuleId);
83+
this._repositoryControllerBase.Update(badgeInfo);
84+
return this.GetById(badgeInfo.ModuleId, badgeInfo.BadgeId);
8485
}
8586
}
8687
}

0 commit comments

Comments
 (0)