From 7d251b20ccfa78aa619b8aa5bcd6522775abf0cf Mon Sep 17 00:00:00 2001 From: ijungleboy Date: Thu, 28 May 2020 21:07:30 +0200 Subject: [PATCH 1/3] Fix collection of theme information because of improper namespace checks https://github.com/oqtane/oqtane.framework/issues/554 --- Oqtane.Server/Repository/ThemeRepository.cs | 28 +++++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/Oqtane.Server/Repository/ThemeRepository.cs b/Oqtane.Server/Repository/ThemeRepository.cs index 1ea0c697..33012004 100644 --- a/Oqtane.Server/Repository/ThemeRepository.cs +++ b/Oqtane.Server/Repository/ThemeRepository.cs @@ -54,16 +54,26 @@ namespace Oqtane.Repository ) continue; string themeNamespace = themeControlType.Namespace; - string qualifiedModuleType = themeNamespace + ", " + themeControlType.Assembly.GetName().Name; + // 2dm disabled - not used anywhere in code + //string qualifiedModuleType = themeNamespace + ", " + themeControlType.Assembly.GetName().Name; int index = themes.FindIndex(item => item.ThemeName == themeNamespace); + + // Find all types in the assembly which have the same namespace-root as the theme file + // Check with "." in the end to + List typesInTheme = assembly.GetTypes() + .Where(item => item.Namespace != null) + // Namespace must be the same or start with "xxx." to ensure that + // similar namespaces like "MyTheme" and "MyTheme2" don't match in StartsWith(...) + .Where(item => item.Namespace == themeNamespace + || item.Namespace.StartsWith(themeNamespace + ".")) + .ToList(); + if (index == -1) { // determine if this theme implements ITheme - Type themetype = assembly.GetTypes() - .Where(item => item.Namespace != null) - .Where(item => item.Namespace.StartsWith(themeNamespace)) - .Where(item => item.GetInterfaces().Contains(typeof(ITheme))).FirstOrDefault(); + Type themetype = typesInTheme + .FirstOrDefault(item => item.GetInterfaces().Contains(typeof(ITheme))); if (themetype != null) { var themeobject = Activator.CreateInstance(themetype) as ITheme; @@ -90,9 +100,7 @@ namespace Oqtane.Repository theme.ThemeControls += (themeControlType.FullName + ", " + themeControlType.Assembly.GetName().Name + ";"); // layouts - Type[] layouttypes = assembly.GetTypes() - .Where(item => item.Namespace != null) - .Where(item => item.Namespace.StartsWith(themeNamespace)) + Type[] layouttypes = typesInTheme .Where(item => item.GetInterfaces().Contains(typeof(ILayoutControl))).ToArray(); foreach (Type layouttype in layouttypes) { @@ -104,9 +112,7 @@ namespace Oqtane.Repository } // containers - Type[] containertypes = assembly.GetTypes() - .Where(item => item.Namespace != null) - .Where(item => item.Namespace.StartsWith(themeNamespace)) + Type[] containertypes = typesInTheme .Where(item => item.GetInterfaces().Contains(typeof(IContainerControl))).ToArray(); foreach (Type containertype in containertypes) { From f9035f8fdfe3e1c0d49ccdec012973fb3d26a0e0 Mon Sep 17 00:00:00 2001 From: Shaun Walker Date: Thu, 28 May 2020 17:32:06 -0400 Subject: [PATCH 2/3] Update README.md --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 29bbbb1f..d80d120a 100644 --- a/README.md +++ b/README.md @@ -51,9 +51,11 @@ V1.0.0 (MVP) # Background Oqtane was created by [Shaun Walker](https://www.linkedin.com/in/shaunbrucewalker/) and is inspired by the DotNetNuke web application framework. Initially created as a proof of concept, Oqtane is a native Blazor application written from the ground up using modern .NET Core technology. It is a modular application framework offering a fully dynamic page compositing model, multi-site support, designer friendly templates (skins), and extensibility via third party modules. -# Release Announcement +# Release Announcements -[Announcing Oqtane... a Modular Application Framework for Blazor!](https://www.oqtane.org/Resources/Blog/PostId/520/announcing-oqtane-a-modular-application-framework-for-blazor) +[Oqtane 1.0](https://www.oqtane.org/Resources/Blog/PostId/540/announcing-oqtane-10-a-modular-application-framework-for-blazor) + +[Oqtane POC](https://www.oqtane.org/Resources/Blog/PostId/520/announcing-oqtane-a-modular-application-framework-for-blazor) # Example Screenshots From 58d97dd73194061f985ec5e1ace6dea4135f519d Mon Sep 17 00:00:00 2001 From: Pavel Vesely Date: Fri, 29 May 2020 16:09:27 +0200 Subject: [PATCH 3/3] OqtaneIgnore implementation to theme elements --- Oqtane.Server/Repository/ModuleDefinitionRepository.cs | 2 +- Oqtane.Server/Repository/ThemeRepository.cs | 3 ++- Oqtane.Shared/Extensions/AssemblyExtensions.cs | 5 +++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Oqtane.Server/Repository/ModuleDefinitionRepository.cs b/Oqtane.Server/Repository/ModuleDefinitionRepository.cs index 9cf698a5..4a600a62 100644 --- a/Oqtane.Server/Repository/ModuleDefinitionRepository.cs +++ b/Oqtane.Server/Repository/ModuleDefinitionRepository.cs @@ -195,7 +195,7 @@ namespace Oqtane.Repository if (modulecontroltype.Name == "ModuleBase" || modulecontroltype.IsGenericType || modulecontroltype.IsAbstract - || Attribute.IsDefined(modulecontroltype, typeof(OqtaneIgnoreAttribute)) + || modulecontroltype.IsOqtaneIgnore() ) continue; string moduleNamespace = modulecontroltype.Namespace; diff --git a/Oqtane.Server/Repository/ThemeRepository.cs b/Oqtane.Server/Repository/ThemeRepository.cs index 33012004..13fe85dc 100644 --- a/Oqtane.Server/Repository/ThemeRepository.cs +++ b/Oqtane.Server/Repository/ThemeRepository.cs @@ -50,7 +50,7 @@ namespace Oqtane.Repository // Check if type should be ignored if (themeControlType.Name == "ThemeBase" || themeControlType.IsGenericType - || Attribute.IsDefined(themeControlType, typeof(OqtaneIgnoreAttribute)) + || themeControlType.IsOqtaneIgnore() ) continue; string themeNamespace = themeControlType.Namespace; @@ -62,6 +62,7 @@ namespace Oqtane.Repository // Find all types in the assembly which have the same namespace-root as the theme file // Check with "." in the end to List typesInTheme = assembly.GetTypes() + .Where(item=>!item.IsOqtaneIgnore()) .Where(item => item.Namespace != null) // Namespace must be the same or start with "xxx." to ensure that // similar namespaces like "MyTheme" and "MyTheme2" don't match in StartsWith(...) diff --git a/Oqtane.Shared/Extensions/AssemblyExtensions.cs b/Oqtane.Shared/Extensions/AssemblyExtensions.cs index fc873fe2..d02053f4 100644 --- a/Oqtane.Shared/Extensions/AssemblyExtensions.cs +++ b/Oqtane.Shared/Extensions/AssemblyExtensions.cs @@ -79,5 +79,10 @@ namespace System.Reflection .Where(a => a.GetTypes().Any() || a.GetTypes().Any() || a.GetTypes().Any()) .Where(a => Utilities.GetFullTypeName(a.GetName().Name) != "Oqtane.Client"); } + + public static bool IsOqtaneIgnore(this Type type) + { + return Attribute.IsDefined(type, typeof(OqtaneIgnoreAttribute)); + } } }