-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Typed PageIdentity with "Data" property to access the typed fie…
…lds.
- Loading branch information
1 parent
6fe6afc
commit a3e228b
Showing
8 changed files
with
162 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
MVC/MVC.Libraries/Services/Implementations/PageIdentityFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using AutoMapper; | ||
using Generic.Models; | ||
using Generic.Services.Interfaces; | ||
|
||
namespace Generic.Services.Implementations | ||
{ | ||
public class PageIdentityFactory : IPageIdentityFactory | ||
{ | ||
private readonly IMapper _mapper; | ||
|
||
public PageIdentityFactory(IMapper mapper) | ||
{ | ||
_mapper = mapper; | ||
} | ||
|
||
public PageIdentity<TData> Convert<TData, TOriginalData>(PageIdentity<TOriginalData> pageIdentity) | ||
{ | ||
// Convert data using AutoMapper | ||
TData data = (pageIdentity.Data != null ? _mapper.Map<TData>(pageIdentity.Data) : default); | ||
|
||
return new PageIdentity<TData>() | ||
{ | ||
Data = data, | ||
DocumentGUID = pageIdentity.DocumentGUID, | ||
DocumentID = pageIdentity.DocumentID, | ||
NodeGUID = pageIdentity.NodeGUID, | ||
NodeID = pageIdentity.NodeID, | ||
NodeLevel = pageIdentity.NodeLevel, | ||
AbsoluteUrl = pageIdentity.AbsoluteUrl, | ||
RelativeUrl = pageIdentity.RelativeUrl, | ||
Alias = pageIdentity.Alias, | ||
Name = pageIdentity.Name, | ||
Path = pageIdentity.Path | ||
}; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
MVC/MVC.Models/Services/Interfaces/IPageIdentityFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using Generic.Models; | ||
using MVCCaching; | ||
|
||
namespace Generic.Services.Interfaces | ||
{ | ||
public interface IPageIdentityFactory : IService | ||
{ | ||
PageIdentity<TData> Convert<TData, TOriginalData>(PageIdentity<TOriginalData> pageIdentity); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,18 @@ | ||
@model ComponentViewModel<Generic.Features.TabParent.TabParentPageTemplateProperties> | ||
@using CMS.DocumentEngine.Types.Generic; | ||
@using Generic.Models; | ||
@using Generic.Libraries.Extensions; | ||
@inject IPageIdentityFactory pageIdentityFactory | ||
@section head{ | ||
<vc:page-meta-data /> | ||
} | ||
<vc:tab-parent page=@Model.Page.ToPageIdentity() /> | ||
@{ | ||
// This component requires the Page be specifically a TabParent | ||
if (Model.Page is not TabParent tabParent) | ||
{ | ||
return; | ||
} | ||
// Convert to identity with our TabParentItem model | ||
var identity = pageIdentityFactory.Convert<TabParentItem, TabParent>(tabParent.ToPageIdentity()); | ||
} | ||
<vc:tab-parent page="identity" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters