diff --git a/src/AXSharp.abstractions/src/AXSharp.Abstractions/Presentation/Attributes/RenderTemplateOverrideAttribute.cs b/src/AXSharp.abstractions/src/AXSharp.Abstractions/Presentation/Attributes/RenderTemplateOverrideAttribute.cs
new file mode 100644
index 00000000..565b11c0
--- /dev/null
+++ b/src/AXSharp.abstractions/src/AXSharp.Abstractions/Presentation/Attributes/RenderTemplateOverrideAttribute.cs
@@ -0,0 +1,22 @@
+// AXSharp.Abstractions
+// Copyright (c) 2023 Peter Kurhajec (PTKu), MTS, and Contributors. All Rights Reserved.
+// Contributors: https://github.com/ix-ax/axsharp/graphs/contributors
+// See the LICENSE file in the repository root for more information.
+// https://github.com/ix-ax/axsharp/blob/dev/LICENSE
+// Third party licenses: https://github.com/ix-ax/axsharp/blob/master/notices.md
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+public class RenderTemplateOverrideAttribute : Attribute
+{
+
+ public RenderTemplateOverrideAttribute(string templateOverrideName)
+ {
+ this.TemplateOverrideName = templateOverrideName;
+ }
+
+ public string TemplateOverrideName { get; protected set; }
+
+}
+
diff --git a/src/AXSharp.blazor/src/AXSharp.Presentation.Blazor.Controls/RenderableContent/RenderableContentControl.razor b/src/AXSharp.blazor/src/AXSharp.Presentation.Blazor.Controls/RenderableContent/RenderableContentControl.razor
index 4757f309..61322efa 100644
--- a/src/AXSharp.blazor/src/AXSharp.Presentation.Blazor.Controls/RenderableContent/RenderableContentControl.razor
+++ b/src/AXSharp.blazor/src/AXSharp.Presentation.Blazor.Controls/RenderableContent/RenderableContentControl.razor
@@ -17,6 +17,44 @@
if (element == null)
return;
+ var overrideAttribute = AttributesHandler.GetRenderTemplateOverrideAttribute(element);
+
+ if (overrideAttribute != null)
+ {
+
+ if (!string.IsNullOrWhiteSpace(overrideAttribute.TemplateOverrideName))
+ {
+ var presentation = GetDisplayPresentationIfEmpty();
+ var pipeline = presentation.Split('-');
+
+ foreach (var item in pipeline) // apply pipeline
+ {
+ string fullPresentationType = overrideAttribute.TemplateOverrideName + GetDisplayPresentationIfEmpty() + "View";
+ var tcomponent = ComponentService.GetComponent(fullPresentationType);
+
+ if (tcomponent != null)
+ {
+ if (element is ITwinPrimitive)
+ {
+ @CreatePrimitiveComponent((ITwinPrimitive)element, tcomponent)
+ ;
+ return;
+ }
+ if (element is ITwinObject)
+ {
+ @CreateComplexComponent((ITwinObject)element, tcomponent)
+ ;
+ return;
+ }
+
+ }
+ }
+
+ }
+
+ }
+
+
// if it is primitive type, just generate
if (element is ITwinPrimitive)
{
diff --git a/src/AXSharp.blazor/src/AXSharp.Presentation.Blazor/Services/AttributesHandler.cs b/src/AXSharp.blazor/src/AXSharp.Presentation.Blazor/Services/AttributesHandler.cs
index 9409a19f..66489a19 100644
--- a/src/AXSharp.blazor/src/AXSharp.Presentation.Blazor/Services/AttributesHandler.cs
+++ b/src/AXSharp.blazor/src/AXSharp.Presentation.Blazor/Services/AttributesHandler.cs
@@ -79,6 +79,37 @@ public RenderIgnoreAttribute GetIgnoreRenderingAttribute(ITwinElement twinObject
return null;
}
+ public RenderTemplateOverrideAttribute GetRenderTemplateOverrideAttribute(ITwinElement twinObject)
+ {
+ if (twinObject == null) return null;
+
+ try
+ {
+ var propertyInfo = GetPropertyViaSymbol(twinObject);
+ if (propertyInfo != null)
+ {
+ if (propertyInfo
+ .GetCustomAttributes().FirstOrDefault(p => p is RenderTemplateOverrideAttribute) is RenderTemplateOverrideAttribute propertyAttribute)
+ {
+ return propertyAttribute;
+ }
+ }
+
+ var typeAttribute = twinObject
+ .GetType()
+ .GetCustomAttributes(true)
+ .FirstOrDefault(p => p is RenderTemplateOverrideAttribute) as RenderTemplateOverrideAttribute;
+
+ return typeAttribute;
+ }
+ catch (Exception)
+ {
+ //throw;
+ }
+
+ return null;
+ }
+
public PropertyInfo GetPropertyViaSymbol(ITwinElement twinObject)
{
if (twinObject == null) return null;
diff --git a/src/AXSharp.blazor/tests/sandbox/AXSharp.RenderableContent.Tests/HtmlFiles/stTestRenderTemplateOverrideStruct.html b/src/AXSharp.blazor/tests/sandbox/AXSharp.RenderableContent.Tests/HtmlFiles/stTestRenderTemplateOverrideStruct.html
new file mode 100644
index 00000000..6b345bb2
--- /dev/null
+++ b/src/AXSharp.blazor/tests/sandbox/AXSharp.RenderableContent.Tests/HtmlFiles/stTestRenderTemplateOverrideStruct.html
@@ -0,0 +1,13 @@
+
\ No newline at end of file
diff --git a/src/AXSharp.blazor/tests/sandbox/AXSharp.RenderableContent.Tests/HtmlFiles/stTestRenderTemplateOverrideTag.html b/src/AXSharp.blazor/tests/sandbox/AXSharp.RenderableContent.Tests/HtmlFiles/stTestRenderTemplateOverrideTag.html
new file mode 100644
index 00000000..2e9998eb
--- /dev/null
+++ b/src/AXSharp.blazor/tests/sandbox/AXSharp.RenderableContent.Tests/HtmlFiles/stTestRenderTemplateOverrideTag.html
@@ -0,0 +1,8 @@
+
\ No newline at end of file
diff --git a/src/AXSharp.blazor/tests/sandbox/AXSharp.RenderableContent.Tests/RenderableContentTests.cs b/src/AXSharp.blazor/tests/sandbox/AXSharp.RenderableContent.Tests/RenderableContentTests.cs
index 155f2d34..1aecca44 100644
--- a/src/AXSharp.blazor/tests/sandbox/AXSharp.RenderableContent.Tests/RenderableContentTests.cs
+++ b/src/AXSharp.blazor/tests/sandbox/AXSharp.RenderableContent.Tests/RenderableContentTests.cs
@@ -30,6 +30,21 @@ public RenderableContentTests(RenderableContentTestsFixture fixture)
_projectDirectory = Directory.GetParent(Environment.CurrentDirectory).Parent.Parent.FullName;
}
+ private void Compare(string fileName, object twin, string presentation)
+ {
+ // Arrange
+ var path = Path.Combine(_projectDirectory, "HtmlFiles", fileName);
+ var html = File.ReadAllText(path);
+ // Act
+ var cut = RenderComponent(param => param
+ .Add(p => p.Context, twin)
+ .Add(p => p.Presentation, presentation));
+
+ // File.WriteAllText(path, cut.Markup);
+
+ // Assert
+ cut.MarkupMatches(html);
+ }
[Fact]
public void Render_prgWeatherStations_Tabs_Successfull()
@@ -47,22 +62,6 @@ public void Render_prgWeatherStations_Tabs_Successfull()
Compare("prgWeatherStations.html", _fixture.Connector.prgWeatherStations, "Display");
}
- private void Compare(string fileName, object twin, string presentation)
- {
- // Arrange
- var path = Path.Combine(_projectDirectory, "HtmlFiles", fileName);
- var html = File.ReadAllText(path);
- // Act
- var cut = RenderComponent(param => param
- .Add(p => p.Context, twin)
- .Add(p => p.Presentation, presentation));
-
- // File.WriteAllText(path, cut.Markup);
-
- // Assert
- cut.MarkupMatches(html);
- }
-
[Fact]
public void Render_stTestPrimitive_Wrap_Success()
{
@@ -522,7 +521,16 @@ public void Render_stTestLayouts_Border_UniformGrid_Successfull()
//}
+ [Fact]
+ public void Render_stTestRenderTemplateOverrideAttributeStruct_Success()
+ {
+ Compare("stTestRenderTemplateOverrideStruct.html", _fixture.Connector.testingProgram.testRenderTemplateOverrideStruct, "Display");
+ }
-
+ [Fact]
+ public void Render_stTestRenderTemplateOverrideAttributeTag_Success()
+ {
+ Compare("stTestRenderTemplateOverrideTag.html", _fixture.Connector.testingProgram.testRenderTemplateOverrideTag, "Display");
+ }
}
}
diff --git a/src/AXSharp.blazor/tests/sandbox/IxBlazor.App/Custom/OnlinerDateControlView.razor b/src/AXSharp.blazor/tests/sandbox/IxBlazor.App/Custom/MachineWordStatusView.razor
similarity index 100%
rename from src/AXSharp.blazor/tests/sandbox/IxBlazor.App/Custom/OnlinerDateControlView.razor
rename to src/AXSharp.blazor/tests/sandbox/IxBlazor.App/Custom/MachineWordStatusView.razor
diff --git a/src/AXSharp.blazor/tests/sandbox/IxBlazor.App/Custom/MySimplePrimitiveStructDisplayView.razor b/src/AXSharp.blazor/tests/sandbox/IxBlazor.App/Custom/MySimplePrimitiveStructDisplayView.razor
new file mode 100644
index 00000000..985b9f8e
--- /dev/null
+++ b/src/AXSharp.blazor/tests/sandbox/IxBlazor.App/Custom/MySimplePrimitiveStructDisplayView.razor
@@ -0,0 +1,10 @@
+@namespace ixBlazor.App.Custom
+@inherits RenderableComplexComponentBase
+@using AXSharp.Connector.ValueTypes;
+
+
+
diff --git a/src/AXSharp.blazor/tests/sandbox/IxBlazor.App/Custom/MySimplePrimitiveTagDisplayView.razor b/src/AXSharp.blazor/tests/sandbox/IxBlazor.App/Custom/MySimplePrimitiveTagDisplayView.razor
new file mode 100644
index 00000000..e21af4f8
--- /dev/null
+++ b/src/AXSharp.blazor/tests/sandbox/IxBlazor.App/Custom/MySimplePrimitiveTagDisplayView.razor
@@ -0,0 +1,22 @@
+@namespace ixBlazor.App.Custom
+@inherits RenderableComponentBase
+@using AXSharp.Connector.ValueTypes;
+
+
+
+@code{
+
+ [Parameter]
+ public ITwinPrimitive Onliner { get; set; }
+ [Parameter]
+ public bool IsReadOnly { get; set; }
+
+ protected override void OnInitialized()
+ {
+ UpdateValuesOnChange(Onliner);
+ }
+}
\ No newline at end of file
diff --git a/src/AXSharp.blazor/tests/sandbox/IxBlazor.App/Pages/AttributeTests.razor b/src/AXSharp.blazor/tests/sandbox/IxBlazor.App/Pages/AttributeTests.razor
new file mode 100644
index 00000000..c796fb98
--- /dev/null
+++ b/src/AXSharp.blazor/tests/sandbox/IxBlazor.App/Pages/AttributeTests.razor
@@ -0,0 +1,27 @@
+@page "/attributeTests"
+WrapLayout
+
+
+
+
------- "TAG Display"--------------
+
+
+
+
+
+
------- "TAG Control"--------------
+
+
+
+
+
+
------- "STRUCT Display"--------------
+
+
+
+
+
+
------- "STRUCT Control"--------------
+
+
+
\ No newline at end of file
diff --git a/src/AXSharp.blazor/tests/sandbox/IxBlazor.App/Shared/NavMenu.razor b/src/AXSharp.blazor/tests/sandbox/IxBlazor.App/Shared/NavMenu.razor
index 94b6aacf..c09ed66b 100644
--- a/src/AXSharp.blazor/tests/sandbox/IxBlazor.App/Shared/NavMenu.razor
+++ b/src/AXSharp.blazor/tests/sandbox/IxBlazor.App/Shared/NavMenu.razor
@@ -1,17 +1,25 @@