diff --git a/ZuneHost.Wpf/MainWindow.xaml.cs b/ZuneHost.Wpf/MainWindow.xaml.cs index 4c9b7ef..147e3a1 100644 --- a/ZuneHost.Wpf/MainWindow.xaml.cs +++ b/ZuneHost.Wpf/MainWindow.xaml.cs @@ -60,12 +60,32 @@ namespace ZuneHost.Wpf } } + Microsoft.Iris.Application.DebugSettings.GenerateDataMappingModels = true; + Microsoft.Iris.Application.DebugSettings.DataMappingModels.CollectionChanged += DataMappingModels_CollectionChanged; + IntPtr hWnd = new System.Windows.Interop.WindowInteropHelper(this).Handle; Thread zuneThread = new Thread(new ThreadStart(() => Microsoft.Zune.Shell.ZuneApplication.Launch(strArgs, hWnd))); zuneThread.Start(); } + private void DataMappingModels_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) + { + string destDir = Path.Combine(Environment.CurrentDirectory, "DataMappings"); + Directory.CreateDirectory(destDir); + + foreach (var item in e.NewItems.Cast()) + { + FileInfo file = new(Path.Combine(destDir, $"{item.Provider}_{item.Type}.cs")); + if (file.Exists) file.Delete(); + + using var stream = file.Open(FileMode.Create); + using var writer = new StreamWriter(stream); + writer.Write(item.GeneratedCode); + writer.Flush(); + } + } + public static void CopyAll(DirectoryInfo source, DirectoryInfo target) { // Check if the target directory exists diff --git a/libs/MicrosoftIris b/libs/MicrosoftIris index 5741116..21fbce6 160000 --- a/libs/MicrosoftIris +++ b/libs/MicrosoftIris @@ -1 +1 @@ -Subproject commit 5741116340fd79f69379e6df0e9e17901d0a8eaa +Subproject commit 21fbce65dfadb9fe4592138d8258117dacefd005