Skip to content

Commit

Permalink
feat (Rendering): renames item type to view type.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamiepollock committed Feb 12, 2024
1 parent 19902ab commit f5e78c7
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
34 changes: 17 additions & 17 deletions src/Rhythm.Drop.Web/Helpers/Rendering/ViewPathHelperBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ public virtual string GetViewPath(MetaData metaData)
{
var options = _optionsMonitor.CurrentValue;
var viewName = GetViewName(metaData);
var itemType = GetItemType(metaData);
var ViewType = GetViewType(metaData);

return options.ViewPathPattern
.Replace("{Theme}", metaData.Theme)
.Replace("{ItemType}", itemType)
.Replace("{ViewType}", ViewType)
.Replace("{ViewName}", viewName);
}

Expand All @@ -48,19 +48,19 @@ protected virtual string GetViewName(MetaData metaData)
}

/// <summary>
/// Gets the item type for the a given <see cref="MetaData"/>.
/// Gets the view type for the a given <see cref="MetaData"/>.
/// </summary>
/// <param name="metaData">The meta data.</param>
/// <returns>A <see cref="string"/>.</returns>
/// <exception cref="NotSupportedException">When an unsupported meta data is provided as the <paramref name="metaData"/>.</exception>
protected virtual string GetItemType(MetaData metaData)
protected virtual string GetViewType(MetaData metaData)
{
return metaData switch
{
ComponentMetaData componentMetaData => GetComponentItemType(componentMetaData),
SubcomponentMetaData subcomponentMetaData => GetSubcomponentItemType(subcomponentMetaData),
ModalMetaData modalMetaData => GetModalItemType(modalMetaData),
_ => throw new NotSupportedException($"Unable to get item type for metadata type {metaData.GetType()}")
ComponentMetaData componentMetaData => GetComponentViewType(componentMetaData),
SubcomponentMetaData subcomponentMetaData => GetSubcomponentViewType(subcomponentMetaData),
ModalMetaData modalMetaData => GetModalViewType(modalMetaData),
_ => throw new NotSupportedException($"Unable to get view type for metadata type {metaData.GetType()}")
};
}

Expand Down Expand Up @@ -95,33 +95,33 @@ protected virtual string GetSubcomponentViewName(SubcomponentMetaData metaData)
}

/// <summary>
/// Gets the item type for a given <see cref="ComponentMetaData"/>.
/// Gets the view type for a given <see cref="ComponentMetaData"/>.
/// </summary>
/// <param name="metaData">The meta data</param>
/// <returns>A <see cref="string"/>.</returns>
protected virtual string GetComponentItemType(ComponentMetaData metaData)
protected virtual string GetComponentViewType(ComponentMetaData metaData)
{
return _optionsMonitor.CurrentValue.ItemTypes.Components;
return _optionsMonitor.CurrentValue.ViewTypes.Components;
}

/// <summary>
/// Gets the item type for a given <see cref="ModalMetaData"/>.
/// Gets the view type for a given <see cref="ModalMetaData"/>.
/// </summary>
/// <param name="metaData">The meta data</param>
/// <returns>A <see cref="string"/>.</returns>
protected virtual string GetModalItemType(ModalMetaData metaData)
protected virtual string GetModalViewType(ModalMetaData metaData)
{
return _optionsMonitor.CurrentValue.ItemTypes.Modals;
return _optionsMonitor.CurrentValue.ViewTypes.Modals;
}

/// <summary>
/// Gets the item type for a given <see cref="SubcomponentMetaData"/>.
/// Gets the view type for a given <see cref="SubcomponentMetaData"/>.
/// </summary>
/// <param name="metaData">The meta data</param>
/// <returns>A <see cref="string"/>.</returns>
protected virtual string GetSubcomponentItemType(SubcomponentMetaData metaData)
protected virtual string GetSubcomponentViewType(SubcomponentMetaData metaData)
{
return _optionsMonitor.CurrentValue.ItemTypes.Subcomponents;
return _optionsMonitor.CurrentValue.ViewTypes.Subcomponents;
}
}

6 changes: 3 additions & 3 deletions src/Rhythm.Drop.Web/Options/RenderingOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ public sealed class RenderingOptions
/// <summary>
/// Gets or sets the pattern to find a view.
/// </summary>
public string ViewPathPattern { get; set; } = "~/Views/Drop/{Theme}/{ItemType}/{ViewName}.cshtml";
public string ViewPathPattern { get; set; } = "~/Views/Drop/{Theme}/{ViewType}/{ViewName}.cshtml";

/// <summary>
/// Gets or sets the item types.
/// Gets or sets the view types.
/// </summary>
public RenderingItemTypeOptions ItemTypes { get; set; } = new RenderingItemTypeOptions();
public RenderingViewTypeOptions ViewTypes { get; set; } = new RenderingViewTypeOptions();
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
namespace Rhythm.Drop.Web.Options;

/// <summary>
/// Configuration options for Rhythm Drop Rendering Item Types.
/// Configuration options for Rhythm Drop Rendering View Types.
/// </summary>
public sealed class RenderingItemTypeOptions
public sealed class RenderingViewTypeOptions
{
/// <summary>
/// Gets or sets the item type name for Modals.
/// Gets or sets the view type name for Modals.
/// </summary>
public string Components { get; set; } = "Components";

/// <summary>
/// Gets or sets the item type name for Subcomponents.
/// Gets or sets the view type name for Subcomponents.
/// </summary>
public string Subcomponents { get; set; } = "Subcomponents";

/// <summary>
/// Gets or sets the item type name for Modals.
/// Gets or sets the view type name for Modals.
/// </summary>
public string Modals { get; set; } = "Modals";
}

0 comments on commit f5e78c7

Please sign in to comment.