Moved the core parsing utility out into a core lib, kept a console application for easier debugging of parsing, and added a startpoint of a gui application
This commit is contained in:
parent
f2c7ec0d9a
commit
66f6347f4a
12
XSDVisualiser.Core/XSDVisualiser.Core.csproj
Normal file
12
XSDVisualiser.Core/XSDVisualiser.Core.csproj
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net9.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="..\XSDVisualiser\Models\**\*.cs" Link="Models\%(RecursiveDir)%(Filename)%(Extension)" />
|
||||||
|
<Compile Include="..\XSDVisualiser\Parsing\**\*.cs" Link="Parsing\%(RecursiveDir)%(Filename)%(Extension)" />
|
||||||
|
<Compile Include="..\XSDVisualiser\Utils\**\*.cs" Link="Utils\%(RecursiveDir)%(Filename)%(Extension)" />
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
8
XSDVisualiser.Desktop/App.axaml
Normal file
8
XSDVisualiser.Desktop/App.axaml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<Application xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:fluent="using:Avalonia.Themes.Fluent"
|
||||||
|
x:Class="XSDVisualiser.Desktop.App">
|
||||||
|
<Application.Styles>
|
||||||
|
<fluent:FluentTheme />
|
||||||
|
</Application.Styles>
|
||||||
|
</Application>
|
||||||
23
XSDVisualiser.Desktop/App.axaml.cs
Normal file
23
XSDVisualiser.Desktop/App.axaml.cs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
using Avalonia;
|
||||||
|
using Avalonia.Controls.ApplicationLifetimes;
|
||||||
|
using Avalonia.Markup.Xaml;
|
||||||
|
|
||||||
|
namespace XSDVisualiser.Desktop
|
||||||
|
{
|
||||||
|
public partial class App : Application
|
||||||
|
{
|
||||||
|
public override void Initialize()
|
||||||
|
{
|
||||||
|
AvaloniaXamlLoader.Load(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnFrameworkInitializationCompleted()
|
||||||
|
{
|
||||||
|
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||||
|
{
|
||||||
|
desktop.MainWindow = new MainWindow();
|
||||||
|
}
|
||||||
|
base.OnFrameworkInitializationCompleted();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
10
XSDVisualiser.Desktop/MainWindow.axaml
Normal file
10
XSDVisualiser.Desktop/MainWindow.axaml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<Window xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
x:Class="XSDVisualiser.Desktop.MainWindow"
|
||||||
|
Title="XSD Visualiser" Width="1000" Height="700">
|
||||||
|
<StackPanel Margin="12" Spacing="8">
|
||||||
|
<TextBlock Text="XSD Visualiser (Avalonia)" FontSize="18"/>
|
||||||
|
<Button Content="Open XSD and parse" x:Name="OpenBtn" Width="200"/>
|
||||||
|
<TextBox x:Name="Output" AcceptsReturn="True" Height="600" TextWrapping="Wrap" FontFamily="Consolas"/>
|
||||||
|
</StackPanel>
|
||||||
|
</Window>
|
||||||
58
XSDVisualiser.Desktop/MainWindow.axaml.cs
Normal file
58
XSDVisualiser.Desktop/MainWindow.axaml.cs
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Interactivity;
|
||||||
|
using Avalonia.Threading;
|
||||||
|
using XSDVisualiser.Parsing;
|
||||||
|
using XSDVisualiser.Utils;
|
||||||
|
|
||||||
|
namespace XSDVisualiser.Desktop
|
||||||
|
{
|
||||||
|
public partial class MainWindow : Window
|
||||||
|
{
|
||||||
|
private Button _openBtn = null!;
|
||||||
|
private TextBox _output = null!;
|
||||||
|
|
||||||
|
public MainWindow()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_openBtn = this.FindControl<Button>("OpenBtn");
|
||||||
|
_output = this.FindControl<TextBox>("Output");
|
||||||
|
_openBtn.Click += OpenBtn_Click;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void OpenBtn_Click(object? sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
var ofd = new OpenFileDialog
|
||||||
|
{
|
||||||
|
AllowMultiple = false,
|
||||||
|
Title = "Open XSD file"
|
||||||
|
};
|
||||||
|
ofd.Filters!.Add(new FileDialogFilter { Name = "XSD schema", Extensions = { "xsd" } });
|
||||||
|
var files = await ofd.ShowAsync(this);
|
||||||
|
if (files != null && files.Length > 0)
|
||||||
|
{
|
||||||
|
await ParseAndShowAsync(files[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Task ParseAndShowAsync(string path)
|
||||||
|
{
|
||||||
|
return Task.Run(() =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var parser = new XsdSchemaParser();
|
||||||
|
var model = parser.Parse(path);
|
||||||
|
var text = Serialization.ToJson(model);
|
||||||
|
Dispatcher.UIThread.Post(() => _output.Text = text);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Dispatcher.UIThread.Post(() => _output.Text = ex.ToString());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
21
XSDVisualiser.Desktop/Program.cs
Normal file
21
XSDVisualiser.Desktop/Program.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
using System;
|
||||||
|
using Avalonia;
|
||||||
|
using Avalonia.ReactiveUI;
|
||||||
|
|
||||||
|
namespace XSDVisualiser.Desktop
|
||||||
|
{
|
||||||
|
internal static class Program
|
||||||
|
{
|
||||||
|
[STAThread]
|
||||||
|
public static void Main(string[] args)
|
||||||
|
{
|
||||||
|
BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AppBuilder BuildAvaloniaApp() =>
|
||||||
|
AppBuilder.Configure<App>()
|
||||||
|
.UsePlatformDetect()
|
||||||
|
.LogToTrace()
|
||||||
|
.UseReactiveUI();
|
||||||
|
}
|
||||||
|
}
|
||||||
19
XSDVisualiser.Desktop/XSDVisualiser.Desktop.csproj
Normal file
19
XSDVisualiser.Desktop/XSDVisualiser.Desktop.csproj
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>WinExe</OutputType>
|
||||||
|
<TargetFramework>net9.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Avalonia" Version="11.1.3" />
|
||||||
|
<PackageReference Include="Avalonia.Desktop" Version="11.1.3" />
|
||||||
|
<PackageReference Include="Avalonia.Controls.DataGrid" Version="11.1.3" />
|
||||||
|
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.1.3" />
|
||||||
|
<PackageReference Include="Avalonia.ReactiveUI" Version="11.1.3" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\XSDVisualiser.Core\XSDVisualiser.Core.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
@ -2,6 +2,10 @@
|
|||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XSDVisualiser", "XSDVisualiser\XSDVisualiser.csproj", "{A42F0483-69BE-44FC-8147-DA3466375051}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XSDVisualiser", "XSDVisualiser\XSDVisualiser.csproj", "{A42F0483-69BE-44FC-8147-DA3466375051}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XSDVisualiser.Core", "XSDVisualiser.Core\XSDVisualiser.Core.csproj", "{0B7B9C8D-8215-4E64-9B3A-2B8F9C7B3E11}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XSDVisualiser.Desktop", "XSDVisualiser.Desktop\XSDVisualiser.Desktop.csproj", "{1C2D3E4F-5061-7283-94A5-B6C7D8E9F0A1}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@ -12,5 +16,13 @@ Global
|
|||||||
{A42F0483-69BE-44FC-8147-DA3466375051}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{A42F0483-69BE-44FC-8147-DA3466375051}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{A42F0483-69BE-44FC-8147-DA3466375051}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{A42F0483-69BE-44FC-8147-DA3466375051}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{A42F0483-69BE-44FC-8147-DA3466375051}.Release|Any CPU.Build.0 = Release|Any CPU
|
{A42F0483-69BE-44FC-8147-DA3466375051}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{0B7B9C8D-8215-4E64-9B3A-2B8F9C7B3E11}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{0B7B9C8D-8215-4E64-9B3A-2B8F9C7B3E11}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{0B7B9C8D-8215-4E64-9B3A-2B8F9C7B3E11}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{0B7B9C8D-8215-4E64-9B3A-2B8F9C7B3E11}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{1C2D3E4F-5061-7283-94A5-B6C7D8E9F0A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{1C2D3E4F-5061-7283-94A5-B6C7D8E9F0A1}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{1C2D3E4F-5061-7283-94A5-B6C7D8E9F0A1}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{1C2D3E4F-5061-7283-94A5-B6C7D8E9F0A1}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|||||||
@ -1,10 +1,16 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
<PropertyGroup>
|
||||||
<PropertyGroup>
|
<OutputType>Exe</OutputType>
|
||||||
<OutputType>Exe</OutputType>
|
<TargetFramework>net9.0</TargetFramework>
|
||||||
<TargetFramework>net9.0</TargetFramework>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<Nullable>enable</Nullable>
|
||||||
<Nullable>enable</Nullable>
|
</PropertyGroup>
|
||||||
</PropertyGroup>
|
<ItemGroup>
|
||||||
|
<Compile Remove="Models\**\*.cs" />
|
||||||
|
<Compile Remove="Parsing\**\*.cs" />
|
||||||
|
<Compile Remove="Utils\**\*.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\XSDVisualiser.Core\XSDVisualiser.Core.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user