update version number

This commit is contained in:
bluepilledgreat 2025-03-11 11:44:41 +00:00
parent 1b7c8b2b3a
commit 71667c6c11
3 changed files with 23 additions and 5 deletions

View File

@ -1,4 +1,4 @@
<BloxstrapCustomBootstrapper Version="0" Height="320" Width="500">
<BloxstrapCustomBootstrapper Version="1" Height="320" Width="500">
<!-- Put UI elements here -->
<!-- Examples of custom bootstrappers can be found at https://github.com/bloxstraplabs/custom-bootstrapper-examples -->
</BloxstrapCustomBootstrapper>

View File

@ -1,4 +1,4 @@
<BloxstrapCustomBootstrapper Version="0" Height="320" Width="520" IgnoreTitleBarInset="True" Theme="Default" Margin="30">
<BloxstrapCustomBootstrapper Version="1" Height="320" Width="520" IgnoreTitleBarInset="True" Theme="Default" Margin="30">
<!-- Find more custom bootstrapper examples at https://github.com/bloxstraplabs/custom-bootstrapper-examples -->
<TitleBar Title="" ShowMinimize="False" ShowClose="False" />

View File

@ -5,7 +5,7 @@ namespace Bloxstrap.UI.Elements.Bootstrapper
{
public partial class CustomDialog
{
const int Version = 0;
const int Version = 1;
private class DummyFrameworkElement : FrameworkElement { }
@ -78,6 +78,25 @@ namespace Bloxstrap.UI.Elements.Bootstrapper
dialog.ElementGrid.Children.Add(uiElement);
}
private static void AssertThemeVersion(string? versionStr)
{
if (string.IsNullOrEmpty(versionStr))
throw new Exception("BloxstrapCustomBootstrapper version is not set");
if (!uint.TryParse(versionStr, out uint version))
throw new Exception("BloxstrapCustomBootstrapper version is not a number");
switch (version)
{
case Version:
break;
case 0: // Themes made between Oct 19, 2024 to Mar 11, 2025 (on the feature/custom-bootstrappers branch)
throw new Exception($"BloxstrapCustomBootstrapper version {version} is no longer supported");
default:
throw new Exception($"BloxstrapCustomBootstrapper version {version} is not recognised");
}
}
private void HandleXmlBase(XElement xml)
{
if (_initialised)
@ -86,8 +105,7 @@ namespace Bloxstrap.UI.Elements.Bootstrapper
if (xml.Name != "BloxstrapCustomBootstrapper")
throw new Exception("XML root is not a BloxstrapCustomBootstrapper");
if (xml.Attribute("Version")?.Value != Version.ToString())
throw new Exception("Unknown BloxstrapCustomBootstrapper version");
AssertThemeVersion(xml.Attribute("Version")?.Value);
if (xml.Descendants().Count() > MaxElements)
throw new Exception($"Custom bootstrappers can have a maximum of {MaxElements} elements");