From f4ab1a96364213e6599957594f195a99a25a28df Mon Sep 17 00:00:00 2001 From: "Hiroaki@R-koubou" Date: Sat, 21 Oct 2023 02:37:39 +0900 Subject: [PATCH 01/19] =?UTF-8?q?=E6=9C=AA=E4=BD=BF=E7=94=A8=E3=82=AF?= =?UTF-8?q?=E3=83=A9=E3=82=B9=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UseCases/KeySwitches/Add/AddRequest.cs | 44 ------------------- .../KeySwitches/Add/AddingResponse.cs | 12 ----- .../UseCases/KeySwitches/Add/IAddPresenter.cs | 13 ------ .../UseCases/KeySwitches/Add/IAddUseCase.cs | 7 --- 4 files changed, 76 deletions(-) delete mode 100644 KeySwitchManager/Sources/Runtime/UseCases/KeySwitches/Add/AddRequest.cs delete mode 100644 KeySwitchManager/Sources/Runtime/UseCases/KeySwitches/Add/AddingResponse.cs delete mode 100644 KeySwitchManager/Sources/Runtime/UseCases/KeySwitches/Add/IAddPresenter.cs delete mode 100644 KeySwitchManager/Sources/Runtime/UseCases/KeySwitches/Add/IAddUseCase.cs diff --git a/KeySwitchManager/Sources/Runtime/UseCases/KeySwitches/Add/AddRequest.cs b/KeySwitchManager/Sources/Runtime/UseCases/KeySwitches/Add/AddRequest.cs deleted file mode 100644 index 6541d505..00000000 --- a/KeySwitchManager/Sources/Runtime/UseCases/KeySwitches/Add/AddRequest.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System.Collections.Generic; - -using KeySwitchManager.Domain.MidiMessages.Models.Aggregations; - -namespace KeySwitchManager.UseCase.KeySwitches.Add -{ - public class AddRequest - { - public string Author { get; } - public string Description { get; } - public string DeveloperName { get; } - public string ProductName { get; } - public string InstrumentName { get; } - public string ArticulationName { get; } - public IReadOnlyCollection MidiNoteOns { get; } - public IReadOnlyCollection MidiControlChanges { get; } - public IReadOnlyCollection MidiProgramChanges { get; } - public IReadOnlyDictionary ExtraData { get; } - - public AddRequest( - string author, - string description, - string developerName, - string productName, - string instrumentName, - string articulationName, - IReadOnlyCollection midiNoteOns, - IReadOnlyCollection midiControlChanges, - IReadOnlyCollection midiProgramChanges, - IReadOnlyDictionary extraData ) - { - Author = author; - Description = description; - DeveloperName = developerName; - ProductName = productName; - InstrumentName = instrumentName; - ArticulationName = articulationName; - MidiNoteOns = midiNoteOns; - MidiControlChanges = midiControlChanges; - MidiProgramChanges = midiProgramChanges; - ExtraData = extraData; - } - } -} \ No newline at end of file diff --git a/KeySwitchManager/Sources/Runtime/UseCases/KeySwitches/Add/AddingResponse.cs b/KeySwitchManager/Sources/Runtime/UseCases/KeySwitches/Add/AddingResponse.cs deleted file mode 100644 index 6494e40d..00000000 --- a/KeySwitchManager/Sources/Runtime/UseCases/KeySwitches/Add/AddingResponse.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace KeySwitchManager.UseCase.KeySwitches.Add -{ - public class AddingResponse - { - public bool Result { get; } - - public AddingResponse( bool result ) - { - Result = result; - } - } -} \ No newline at end of file diff --git a/KeySwitchManager/Sources/Runtime/UseCases/KeySwitches/Add/IAddPresenter.cs b/KeySwitchManager/Sources/Runtime/UseCases/KeySwitches/Add/IAddPresenter.cs deleted file mode 100644 index 9741057b..00000000 --- a/KeySwitchManager/Sources/Runtime/UseCases/KeySwitches/Add/IAddPresenter.cs +++ /dev/null @@ -1,13 +0,0 @@ -using KeySwitchManager.UseCase.Commons; - -namespace KeySwitchManager.UseCase.KeySwitches.Add -{ - public interface IAddPresenter : IPresenter - { - public class Null : IAddPresenter - { - public void Complete( AddingResponse response ) - {} - } - } -} \ No newline at end of file diff --git a/KeySwitchManager/Sources/Runtime/UseCases/KeySwitches/Add/IAddUseCase.cs b/KeySwitchManager/Sources/Runtime/UseCases/KeySwitches/Add/IAddUseCase.cs deleted file mode 100644 index 62850bfd..00000000 --- a/KeySwitchManager/Sources/Runtime/UseCases/KeySwitches/Add/IAddUseCase.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace KeySwitchManager.UseCase.KeySwitches.Add -{ - public interface IAddUseCase - { - public AddingResponse Execute( AddRequest request ); - } -} \ No newline at end of file From bf62dc136ec42d05acc921f9b52705c691537903 Mon Sep 17 00:00:00 2001 From: "Hiroaki@R-koubou" Date: Sat, 21 Oct 2023 03:02:20 +0900 Subject: [PATCH 02/19] =?UTF-8?q?SaveAsync=E3=83=A1=E3=82=BD=E3=83=83?= =?UTF-8?q?=E3=83=89=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../KeySwitches/Models/IKeySwitchRepository.cs | 9 +++++++-- .../Models/OnMemoryKeySwitchRepository.cs | 12 +++++++----- .../Database.LiteDB/KeySwitches/LiteDbFileWriter.cs | 2 +- .../Database.LiteDB/KeySwitches/LiteDbRepository.cs | 13 +++++++------ .../Storage.Yaml/KeySwitches/YamlRepository.cs | 7 ++++--- .../Database.LiteDB/KeySwitches/LiteDbInsertTest.cs | 5 +++-- 6 files changed, 29 insertions(+), 19 deletions(-) diff --git a/KeySwitchManager/Sources/Runtime/Domain/KeySwitches/Models/IKeySwitchRepository.cs b/KeySwitchManager/Sources/Runtime/Domain/KeySwitches/Models/IKeySwitchRepository.cs index b89a2b43..fa4370b9 100644 --- a/KeySwitchManager/Sources/Runtime/Domain/KeySwitches/Models/IKeySwitchRepository.cs +++ b/KeySwitchManager/Sources/Runtime/Domain/KeySwitches/Models/IKeySwitchRepository.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Threading.Tasks; using KeySwitchManager.Domain.KeySwitches.Models.Values; @@ -12,7 +13,11 @@ public interface IKeySwitchRepository : IDisposable public IObservable OnLogging { get; } public int Count(); - public SaveResult Save( KeySwitch keySwitch ); + + #region Save + public SaveResult Save( KeySwitch keySwitch ) => SaveAsync( keySwitch ).GetAwaiter().GetResult(); + public Task SaveAsync( KeySwitch keySwitch ); + #endregion public int Flush() => 0; public int Delete( DeveloperName developerName, ProductName productName, InstrumentName instrumentName ); public int Delete( DeveloperName developerName, ProductName productName ); @@ -57,4 +62,4 @@ public bool Equals( SaveResult? other ) } } } -} \ No newline at end of file +} diff --git a/KeySwitchManager/Sources/Runtime/Domain/KeySwitches/Models/OnMemoryKeySwitchRepository.cs b/KeySwitchManager/Sources/Runtime/Domain/KeySwitches/Models/OnMemoryKeySwitchRepository.cs index fe3c9a2c..96aef3b9 100644 --- a/KeySwitchManager/Sources/Runtime/Domain/KeySwitches/Models/OnMemoryKeySwitchRepository.cs +++ b/KeySwitchManager/Sources/Runtime/Domain/KeySwitches/Models/OnMemoryKeySwitchRepository.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Reactive.Subjects; +using System.Threading.Tasks; using KeySwitchManager.Domain.KeySwitches.Helpers; using KeySwitchManager.Domain.KeySwitches.Models.Values; @@ -37,19 +38,20 @@ public int Count() => KeySwitches.Count; #region Save - public IKeySwitchRepository.SaveResult Save( KeySwitch keySwitch ) + public async Task SaveAsync( KeySwitch keySwitch ) { var exist = KeySwitches.Find( x => x.Id.Value.Equals( keySwitch.Id.Value ) ); if( exist != null ) { var index = KeySwitches.IndexOf( exist ); - KeySwitches[ index ] = keySwitch; - return new IKeySwitchRepository.SaveResult( 0, 1 ); + KeySwitches[ index ] = keySwitch; + return await Task.FromResult( new IKeySwitchRepository.SaveResult( 0, 1 ) ); } KeySwitches.Add( keySwitch ); - return new IKeySwitchRepository.SaveResult( 1, 0 ); + + return await Task.FromResult( new IKeySwitchRepository.SaveResult( 1, 0 ) ); } public virtual int Flush() @@ -173,4 +175,4 @@ public IReadOnlyCollection FindAll() => KeySwitchHelper.SortByAlphabetical( new List( KeySwitches ) ); #endregion } -} \ No newline at end of file +} diff --git a/KeySwitchManager/Sources/Runtime/Infrastructures/Database.LiteDB/KeySwitches/LiteDbFileWriter.cs b/KeySwitchManager/Sources/Runtime/Infrastructures/Database.LiteDB/KeySwitches/LiteDbFileWriter.cs index 7c12c84b..4c878aa2 100644 --- a/KeySwitchManager/Sources/Runtime/Infrastructures/Database.LiteDB/KeySwitches/LiteDbFileWriter.cs +++ b/KeySwitchManager/Sources/Runtime/Infrastructures/Database.LiteDB/KeySwitches/LiteDbFileWriter.cs @@ -10,7 +10,7 @@ namespace KeySwitchManager.Infrastructures.Database.LiteDB.KeySwitches { public class LiteDbFileWriter : IKeySwitchWriter { - private LiteDbRepository Repository { get; } + private IKeySwitchRepository Repository { get; } public bool LeaveOpen => false; diff --git a/KeySwitchManager/Sources/Runtime/Infrastructures/Database.LiteDB/KeySwitches/LiteDbRepository.cs b/KeySwitchManager/Sources/Runtime/Infrastructures/Database.LiteDB/KeySwitches/LiteDbRepository.cs index e419f34c..d52859ea 100644 --- a/KeySwitchManager/Sources/Runtime/Infrastructures/Database.LiteDB/KeySwitches/LiteDbRepository.cs +++ b/KeySwitchManager/Sources/Runtime/Infrastructures/Database.LiteDB/KeySwitches/LiteDbRepository.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Reactive.Subjects; +using System.Threading.Tasks; using KeySwitchManager.Commons.Data; using KeySwitchManager.Domain.KeySwitches.Helpers; @@ -62,7 +63,7 @@ public int Count() } #region Save - public IKeySwitchRepository.SaveResult Save( KeySwitch keySwitch ) + public async Task SaveAsync( KeySwitch keySwitch ) { logging.OnNext( keySwitch.ToString() ); @@ -78,19 +79,19 @@ public IKeySwitchRepository.SaveResult Save( KeySwitch keySwitch ) entity.LastUpdated = DateTimeHelper.NowUtc(); var updated = table.Update( entity ) ? 1 : 0; - return new IKeySwitchRepository.SaveResult( + return await Task.FromResult( new IKeySwitchRepository.SaveResult( inserted: 0, updated: updated - ); + )); } entity.Id = keySwitch.Id.Value; var insertedId = table.Insert( entity ).AsGuid; - return new IKeySwitchRepository.SaveResult( + return await Task.FromResult( new IKeySwitchRepository.SaveResult( inserted: insertedId == entity.Id ? 1 : 0, updated: 0 - ); + )); } #endregion @@ -272,4 +273,4 @@ public IReadOnlyCollection FindAll() } #endregion } -} \ No newline at end of file +} diff --git a/KeySwitchManager/Sources/Runtime/Infrastructures/Storage.Yaml/KeySwitches/YamlRepository.cs b/KeySwitchManager/Sources/Runtime/Infrastructures/Storage.Yaml/KeySwitches/YamlRepository.cs index ec8297a8..511363ef 100644 --- a/KeySwitchManager/Sources/Runtime/Infrastructures/Storage.Yaml/KeySwitches/YamlRepository.cs +++ b/KeySwitchManager/Sources/Runtime/Infrastructures/Storage.Yaml/KeySwitches/YamlRepository.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Reactive.Subjects; using System.Text; +using System.Threading.Tasks; using KeySwitchManager.Commons.Data; using KeySwitchManager.Domain.KeySwitches.Helpers; @@ -46,7 +47,7 @@ public int Count() => YamlModel.KeySwitches.Count; #region Save - public IKeySwitchRepository.SaveResult Save( KeySwitch keySwitch ) + public async Task SaveAsync( KeySwitch keySwitch ) { var yamlModels = YamlModel.KeySwitches; var model = TranslateModelHelper.Translate( keySwitch ); @@ -61,11 +62,11 @@ public IKeySwitchRepository.SaveResult Save( KeySwitch keySwitch ) model.Created = exist.Created; model.LastUpdated = UtcDateTime.NowAsDateTime; yamlModels[ index ] = model; - return new IKeySwitchRepository.SaveResult( 0, 1 ); + return await Task.FromResult( new IKeySwitchRepository.SaveResult( 0, 1 ) ); } yamlModels.Add( model ); - return new IKeySwitchRepository.SaveResult( 1, 0 ); + return await Task.FromResult( new IKeySwitchRepository.SaveResult( 1, 0 ) ); } public int Flush() diff --git a/KeySwitchManager/Sources/Tests/Infrastructures/Database.LiteDB/KeySwitches/LiteDbInsertTest.cs b/KeySwitchManager/Sources/Tests/Infrastructures/Database.LiteDB/KeySwitches/LiteDbInsertTest.cs index 6e2b9463..582de424 100644 --- a/KeySwitchManager/Sources/Tests/Infrastructures/Database.LiteDB/KeySwitches/LiteDbInsertTest.cs +++ b/KeySwitchManager/Sources/Tests/Infrastructures/Database.LiteDB/KeySwitches/LiteDbInsertTest.cs @@ -3,6 +3,7 @@ using System.Linq; using KeySwitchManager.Commons.Data; +using KeySwitchManager.Domain.KeySwitches.Models; using KeySwitchManager.Domain.MidiMessages.Models.Aggregations; using KeySwitchManager.Domain.MidiMessages.Models.Values; using KeySwitchManager.Infrastructures.Database.LiteDB.KeySwitches; @@ -18,7 +19,7 @@ public class LiteDbInsertTest [Test] public void InsertTest() { - using var repository = new LiteDbRepository( new FilePath( $"{Path.GetTempFileName()}.db" ) ); + using IKeySwitchRepository repository = new LiteDbRepository( new FilePath( $"{Path.GetTempFileName()}.db" ) ); var articulation = TestDataGenerator.CreateArticulation( new List() { @@ -50,4 +51,4 @@ public void InsertTest() } } -} \ No newline at end of file +} From 6eccfca2bd4dce9b3a421c32c4fba4458b13972e Mon Sep 17 00:00:00 2001 From: "Hiroaki@R-koubou" Date: Sat, 21 Oct 2023 03:03:41 +0900 Subject: [PATCH 03/19] =?UTF-8?q?FlushAsync=E3=83=A1=E3=82=BD=E3=83=83?= =?UTF-8?q?=E3=83=89=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Domain/KeySwitches/Models/IKeySwitchRepository.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/KeySwitchManager/Sources/Runtime/Domain/KeySwitches/Models/IKeySwitchRepository.cs b/KeySwitchManager/Sources/Runtime/Domain/KeySwitches/Models/IKeySwitchRepository.cs index fa4370b9..4f8378ca 100644 --- a/KeySwitchManager/Sources/Runtime/Domain/KeySwitches/Models/IKeySwitchRepository.cs +++ b/KeySwitchManager/Sources/Runtime/Domain/KeySwitches/Models/IKeySwitchRepository.cs @@ -18,7 +18,12 @@ public interface IKeySwitchRepository : IDisposable public SaveResult Save( KeySwitch keySwitch ) => SaveAsync( keySwitch ).GetAwaiter().GetResult(); public Task SaveAsync( KeySwitch keySwitch ); #endregion - public int Flush() => 0; + + #region Flush + public int Flush() => FlushAsync().GetAwaiter().GetResult(); + public Task FlushAsync() => Task.FromResult( 0 ); + #endregion + public int Delete( DeveloperName developerName, ProductName productName, InstrumentName instrumentName ); public int Delete( DeveloperName developerName, ProductName productName ); public int Delete( DeveloperName developerName ); From fbdd4995a3d74fff3f600ecd5b16648a3223ed60 Mon Sep 17 00:00:00 2001 From: "Hiroaki@R-koubou" Date: Sat, 21 Oct 2023 03:46:31 +0900 Subject: [PATCH 04/19] =?UTF-8?q?DeleteAsync=E3=83=A1=E3=82=BD=E3=83=83?= =?UTF-8?q?=E3=83=89=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Models/IKeySwitchRepository.cs | 55 +++++++++++++++---- .../Models/OnMemoryKeySwitchRepository.cs | 32 +++++------ .../KeySwitches/LiteDbRepository.cs | 38 ++++++------- .../KeySwitches/YamlRepository.cs | 38 ++++++------- 4 files changed, 99 insertions(+), 64 deletions(-) diff --git a/KeySwitchManager/Sources/Runtime/Domain/KeySwitches/Models/IKeySwitchRepository.cs b/KeySwitchManager/Sources/Runtime/Domain/KeySwitches/Models/IKeySwitchRepository.cs index 4f8378ca..9cdb3f66 100644 --- a/KeySwitchManager/Sources/Runtime/Domain/KeySwitches/Models/IKeySwitchRepository.cs +++ b/KeySwitchManager/Sources/Runtime/Domain/KeySwitches/Models/IKeySwitchRepository.cs @@ -15,22 +15,57 @@ public interface IKeySwitchRepository : IDisposable public int Count(); #region Save - public SaveResult Save( KeySwitch keySwitch ) => SaveAsync( keySwitch ).GetAwaiter().GetResult(); + public SaveResult Save( KeySwitch keySwitch ) + => SaveAsync( keySwitch ).GetAwaiter().GetResult(); + public Task SaveAsync( KeySwitch keySwitch ); #endregion #region Flush - public int Flush() => FlushAsync().GetAwaiter().GetResult(); - public Task FlushAsync() => Task.FromResult( 0 ); + public int Flush() + => FlushAsync().GetAwaiter().GetResult(); + + public Task FlushAsync() + => Task.FromResult( 0 ); + #endregion + + #region Delete + public int Delete( DeveloperName developerName, ProductName productName, InstrumentName instrumentName ) + => DeleteAsync(developerName, productName, instrumentName).GetAwaiter().GetResult(); + + public Task DeleteAsync( DeveloperName developerName, ProductName productName, InstrumentName instrumentName ); + + public int Delete( DeveloperName developerName, ProductName productName ) + => DeleteAsync( developerName, productName ).GetAwaiter().GetResult(); + + public Task DeleteAsync( DeveloperName developerName, ProductName productName ); + + public int Delete( DeveloperName developerName ) + => DeleteAsync( developerName ).GetAwaiter().GetResult(); + + public Task DeleteAsync( DeveloperName developerName ); + + public int Delete( ProductName productName ) + => DeleteAsync( productName ).GetAwaiter().GetResult(); + + public Task DeleteAsync( ProductName productName ); + + public int Delete( InstrumentName instrumentName ) + => DeleteAsync( instrumentName ).GetAwaiter().GetResult(); + + public Task DeleteAsync( InstrumentName instrumentName ); + + public int Delete( KeySwitchId keySwitchId ) + => DeleteAsync( keySwitchId ).GetAwaiter().GetResult(); + + public Task DeleteAsync( KeySwitchId keySwitchId ); + + public int DeleteAll() + => DeleteAllAsync().GetAwaiter().GetResult(); + + public Task DeleteAllAsync(); #endregion - public int Delete( DeveloperName developerName, ProductName productName, InstrumentName instrumentName ); - public int Delete( DeveloperName developerName, ProductName productName ); - public int Delete( DeveloperName developerName ); - public int Delete( ProductName productName ); - public int Delete( InstrumentName instrumentName ); - public int Delete( KeySwitchId keySwitchId ); - public int DeleteAll(); public IReadOnlyCollection Find( KeySwitchId keySwitchId ); public IReadOnlyCollection Find( DeveloperName developerName, ProductName productName, InstrumentName instrumentName ); public IReadOnlyCollection Find( DeveloperName developerName, ProductName productName ); diff --git a/KeySwitchManager/Sources/Runtime/Domain/KeySwitches/Models/OnMemoryKeySwitchRepository.cs b/KeySwitchManager/Sources/Runtime/Domain/KeySwitches/Models/OnMemoryKeySwitchRepository.cs index 96aef3b9..97ee2d7f 100644 --- a/KeySwitchManager/Sources/Runtime/Domain/KeySwitches/Models/OnMemoryKeySwitchRepository.cs +++ b/KeySwitchManager/Sources/Runtime/Domain/KeySwitches/Models/OnMemoryKeySwitchRepository.cs @@ -54,52 +54,52 @@ public int Count() return await Task.FromResult( new IKeySwitchRepository.SaveResult( 1, 0 ) ); } - public virtual int Flush() - => Count(); + public virtual async Task FlushAsync() + => await Task.FromResult( Count() ); #endregion #region Delete - public int Delete( KeySwitchId keySwitchId ) + public async Task DeleteAsync( KeySwitchId keySwitchId ) { var founds = Find( keySwitchId ); - return founds.Sum( x => KeySwitches.Remove( x ) ? 1 : 0 ); + return await Task.FromResult( founds.Sum( x => KeySwitches.Remove( x ) ? 1 : 0 ) ); } - public int Delete( DeveloperName developerName, ProductName productName, InstrumentName instrumentName ) + public async Task DeleteAsync( DeveloperName developerName, ProductName productName, InstrumentName instrumentName ) { var founds = Find( developerName, productName, instrumentName ); - return founds.Sum( x => KeySwitches.Remove( x ) ? 1 : 0 ); + return await Task.FromResult( founds.Sum( x => KeySwitches.Remove( x ) ? 1 : 0 ) ); } - public int Delete( DeveloperName developerName, ProductName productName ) + public async Task DeleteAsync( DeveloperName developerName, ProductName productName ) { var founds = Find( developerName, productName ); - return founds.Sum( x => KeySwitches.Remove( x ) ? 1 : 0 ); + return await Task.FromResult( founds.Sum( x => KeySwitches.Remove( x ) ? 1 : 0 ) ); } - public int Delete( DeveloperName developerName ) + public async Task DeleteAsync( DeveloperName developerName ) { var founds = Find( developerName ); - return founds.Sum( x => KeySwitches.Remove( x ) ? 1 : 0 ); + return await Task.FromResult( founds.Sum( x => KeySwitches.Remove( x ) ? 1 : 0 ) ); } - public int Delete( ProductName productName ) + public async Task DeleteAsync( ProductName productName ) { var founds = Find( productName ); - return founds.Sum( x => KeySwitches.Remove( x ) ? 1 : 0 ); + return await Task.FromResult( founds.Sum( x => KeySwitches.Remove( x ) ? 1 : 0 ) ); } - public int Delete( InstrumentName instrumentName ) + public async Task DeleteAsync( InstrumentName instrumentName ) { var founds = Find( instrumentName ); - return founds.Sum( x => KeySwitches.Remove( x ) ? 1 : 0 ); + return await Task.FromResult( founds.Sum( x => KeySwitches.Remove( x ) ? 1 : 0 ) ); } - public int DeleteAll() + public async Task DeleteAllAsync() { var count = KeySwitches.Count; KeySwitches.Clear(); - return count; + return await Task.FromResult( count ); } #endregion diff --git a/KeySwitchManager/Sources/Runtime/Infrastructures/Database.LiteDB/KeySwitches/LiteDbRepository.cs b/KeySwitchManager/Sources/Runtime/Infrastructures/Database.LiteDB/KeySwitches/LiteDbRepository.cs index d52859ea..2f662df6 100644 --- a/KeySwitchManager/Sources/Runtime/Infrastructures/Database.LiteDB/KeySwitches/LiteDbRepository.cs +++ b/KeySwitchManager/Sources/Runtime/Infrastructures/Database.LiteDB/KeySwitches/LiteDbRepository.cs @@ -97,13 +97,13 @@ public int Count() #endregion #region Delete - public int Delete( KeySwitchId keySwitchId ) + public async Task DeleteAsync( KeySwitchId keySwitchId ) { var result = KeySwitchTable.Delete( keySwitchId.Value ); - return result ? 1 : 0; + return await Task.FromResult( result ? 1 : 0 ); } - public int Delete( + public async Task DeleteAsync( DeveloperName developerName, ProductName productName, InstrumentName instrumentName ) @@ -112,60 +112,60 @@ public int Delete( var p = productName.Value; var i = instrumentName.Value; - return KeySwitchTable.DeleteMany( + return await Task.FromResult( KeySwitchTable.DeleteMany( x => ( d == DeveloperName.Any.Value || x.DeveloperName.Contains( d ) ) && ( p == ProductName.Any.Value || x.ProductName.Contains( p ) ) && ( i == InstrumentName.Any.Value || x.InstrumentName.Contains( i ) ) - ); + )); } - public int Delete( DeveloperName developerName, ProductName productName ) + public async Task DeleteAsync( DeveloperName developerName, ProductName productName ) { var d = developerName.Value; var p = productName.Value; - return KeySwitchTable.DeleteMany( + return await Task.FromResult( KeySwitchTable.DeleteMany( x => ( d == DeveloperName.Any.Value || x.DeveloperName.Contains( d ) ) && ( p == ProductName.Any.Value || x.ProductName.Contains( p ) ) - ); + )); } - public int Delete( DeveloperName developerName ) + public async Task DeleteAsync( DeveloperName developerName ) { var d = developerName.Value; - return KeySwitchTable.DeleteMany( + return await Task.FromResult( KeySwitchTable.DeleteMany( x => d == DeveloperName.Any.Value || x.DeveloperName.Contains( d ) - ); + )); } - public int Delete( ProductName productName ) + public async Task DeleteAsync( ProductName productName ) { var p = productName.Value; - return KeySwitchTable.DeleteMany( + return await Task.FromResult( KeySwitchTable.DeleteMany( x => p == ProductName.Any.Value || x.ProductName.Contains( p ) - ); + )); } - public int Delete( InstrumentName instrumentName ) + public async Task DeleteAsync( InstrumentName instrumentName ) { var i = instrumentName.Value; - return KeySwitchTable.DeleteMany( + return await Task.FromResult( KeySwitchTable.DeleteMany( x => i == InstrumentName.Any.Value || x.InstrumentName.Contains( i ) - ); + )); } - public int DeleteAll() + public async Task DeleteAllAsync() { var table = Database.GetCollection( KeySwitchesTableName ); - return table.DeleteAll(); + return await Task.FromResult( table.DeleteAll() ); } #endregion diff --git a/KeySwitchManager/Sources/Runtime/Infrastructures/Storage.Yaml/KeySwitches/YamlRepository.cs b/KeySwitchManager/Sources/Runtime/Infrastructures/Storage.Yaml/KeySwitches/YamlRepository.cs index 511363ef..0c7f11bd 100644 --- a/KeySwitchManager/Sources/Runtime/Infrastructures/Storage.Yaml/KeySwitches/YamlRepository.cs +++ b/KeySwitchManager/Sources/Runtime/Infrastructures/Storage.Yaml/KeySwitches/YamlRepository.cs @@ -38,9 +38,9 @@ public YamlRepository(FilePath filePath) YamlModel = deserializer.Deserialize( yaml ); } - public void Dispose() + public async void Dispose() { - Flush(); + await FlushAsync(); } public int Count() @@ -69,10 +69,10 @@ public int Count() return await Task.FromResult( new IKeySwitchRepository.SaveResult( 1, 0 ) ); } - public int Flush() + public async Task FlushAsync() { - using var stream = YamlFilePath.OpenWriteStream(); - using var writer = new StreamWriter( stream, Encoding.UTF8 ); + await using var stream = YamlFilePath.OpenWriteStream(); + await using var writer = new StreamWriter( stream, Encoding.UTF8 ); var serializer = new Serializer(); serializer.Serialize( writer, YamlModel ); @@ -82,60 +82,60 @@ public int Flush() #endregion #region Delete - public int Delete( DeveloperName developerName, ProductName productName, InstrumentName instrumentName ) + public async Task DeleteAsync( DeveloperName developerName, ProductName productName, InstrumentName instrumentName ) { var keySwitches = YamlModel.KeySwitches; var founds = YamlModel.Find( developerName, productName, instrumentName ); - return founds.Sum( x => keySwitches.Remove( x ) ? 1 : 0 ); + return await Task.FromResult( founds.Sum( x => keySwitches.Remove( x ) ? 1 : 0 ) ); } - public int Delete( DeveloperName developerName, ProductName productName ) + public async Task DeleteAsync( DeveloperName developerName, ProductName productName ) { var keySwitches = YamlModel.KeySwitches; var founds = YamlModel.Find( developerName, productName ); - return founds.Sum( x => keySwitches.Remove( x ) ? 1 : 0 ); + return await Task.FromResult( founds.Sum( x => keySwitches.Remove( x ) ? 1 : 0 ) ); } - public int Delete( DeveloperName developerName ) + public async Task DeleteAsync( DeveloperName developerName ) { var keySwitches = YamlModel.KeySwitches; var founds = YamlModel.Find( developerName ); - return founds.Sum( x => keySwitches.Remove( x ) ? 1 : 0 ); + return await Task.FromResult( founds.Sum( x => keySwitches.Remove( x ) ? 1 : 0 ) ); } - public int Delete( ProductName productName ) + public async Task DeleteAsync( ProductName productName ) { var keySwitches = YamlModel.KeySwitches; var founds = YamlModel.Find( productName ); - return founds.Sum( x => keySwitches.Remove( x ) ? 1 : 0 ); + return await Task.FromResult( founds.Sum( x => keySwitches.Remove( x ) ? 1 : 0 ) ); } - public int Delete( InstrumentName instrumentName ) + public async Task DeleteAsync( InstrumentName instrumentName ) { var keySwitches = YamlModel.KeySwitches; var founds = YamlModel.Find( instrumentName ); - return founds.Sum( x => keySwitches.Remove( x ) ? 1 : 0 ); + return await Task.FromResult( founds.Sum( x => keySwitches.Remove( x ) ? 1 : 0 ) ); } - public int Delete( KeySwitchId keySwitchId ) + public async Task DeleteAsync( KeySwitchId keySwitchId ) { var keySwitches = YamlModel.KeySwitches; var founds = YamlModel.Find( keySwitchId ); - return founds.Sum( x => keySwitches.Remove( x ) ? 1 : 0 ); + return await Task.FromResult( founds.Sum( x => keySwitches.Remove( x ) ? 1 : 0 ) ); } - public int DeleteAll() + public async Task DeleteAllAsync() { var count = YamlModel.KeySwitches.Count; YamlModel.KeySwitches.Clear(); - return count; + return await Task.FromResult( count ); } #endregion From d6188520424557a077af895ef77ba386676a6ff7 Mon Sep 17 00:00:00 2001 From: "Hiroaki@R-koubou" Date: Sat, 21 Oct 2023 04:03:50 +0900 Subject: [PATCH 05/19] =?UTF-8?q?FindAsync=E3=83=A1=E3=82=BD=E3=83=83?= =?UTF-8?q?=E3=83=89=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Models/IKeySwitchRepository.cs | 43 +++++++++++-- .../Models/OnMemoryKeySwitchRepository.cs | 64 +++++++++---------- .../KeySwitches/LiteDbRepository.cs | 42 ++++++------ .../KeySwitches/YamlRepository.cs | 32 +++++----- 4 files changed, 105 insertions(+), 76 deletions(-) diff --git a/KeySwitchManager/Sources/Runtime/Domain/KeySwitches/Models/IKeySwitchRepository.cs b/KeySwitchManager/Sources/Runtime/Domain/KeySwitches/Models/IKeySwitchRepository.cs index 9cdb3f66..274fc832 100644 --- a/KeySwitchManager/Sources/Runtime/Domain/KeySwitches/Models/IKeySwitchRepository.cs +++ b/KeySwitchManager/Sources/Runtime/Domain/KeySwitches/Models/IKeySwitchRepository.cs @@ -66,13 +66,42 @@ public int DeleteAll() public Task DeleteAllAsync(); #endregion - public IReadOnlyCollection Find( KeySwitchId keySwitchId ); - public IReadOnlyCollection Find( DeveloperName developerName, ProductName productName, InstrumentName instrumentName ); - public IReadOnlyCollection Find( DeveloperName developerName, ProductName productName ); - public IReadOnlyCollection Find( DeveloperName developerName ); - public IReadOnlyCollection Find( ProductName productName ); - public IReadOnlyCollection Find( InstrumentName instrumentName ); - public IReadOnlyCollection FindAll(); + #region Find + public IReadOnlyCollection Find( KeySwitchId keySwitchId ) + => FindAsync( keySwitchId ).GetAwaiter().GetResult(); + + public Task> FindAsync( KeySwitchId keySwitchId ); + + public IReadOnlyCollection Find( DeveloperName developerName, ProductName productName, InstrumentName instrumentName ) + => FindAsync( developerName, productName, instrumentName ).GetAwaiter().GetResult(); + + public Task> FindAsync( DeveloperName developerName, ProductName productName, InstrumentName instrumentName ); + + public IReadOnlyCollection Find( DeveloperName developerName, ProductName productName ) + => FindAsync( developerName, productName ).GetAwaiter().GetResult(); + + public Task> FindAsync( DeveloperName developerName, ProductName productName ); + + public IReadOnlyCollection Find( DeveloperName developerName ) + => FindAsync( developerName ).GetAwaiter().GetResult(); + + public Task> FindAsync( DeveloperName developerName ); + + public IReadOnlyCollection Find( ProductName productName ) + => FindAsync( productName ).GetAwaiter().GetResult(); + + public Task> FindAsync( ProductName productName ); + + public IReadOnlyCollection Find( InstrumentName instrumentName ) + => FindAsync( instrumentName ).GetAwaiter().GetResult(); + + public Task> FindAsync( InstrumentName instrumentName ); + + public IReadOnlyCollection FindAll() + => FindAllAsync().GetAwaiter().GetResult(); + + public Task> FindAllAsync(); + #endregion public class SaveResult : IEquatable { diff --git a/KeySwitchManager/Sources/Runtime/Domain/KeySwitches/Models/OnMemoryKeySwitchRepository.cs b/KeySwitchManager/Sources/Runtime/Domain/KeySwitches/Models/OnMemoryKeySwitchRepository.cs index 97ee2d7f..d311da0a 100644 --- a/KeySwitchManager/Sources/Runtime/Domain/KeySwitches/Models/OnMemoryKeySwitchRepository.cs +++ b/KeySwitchManager/Sources/Runtime/Domain/KeySwitches/Models/OnMemoryKeySwitchRepository.cs @@ -61,38 +61,38 @@ public virtual async Task FlushAsync() #region Delete public async Task DeleteAsync( KeySwitchId keySwitchId ) { - var founds = Find( keySwitchId ); - return await Task.FromResult( founds.Sum( x => KeySwitches.Remove( x ) ? 1 : 0 ) ); + var founds = await FindAsync( keySwitchId ); + return founds.Sum( x => KeySwitches.Remove( x ) ? 1 : 0 ); } public async Task DeleteAsync( DeveloperName developerName, ProductName productName, InstrumentName instrumentName ) { - var founds = Find( developerName, productName, instrumentName ); - return await Task.FromResult( founds.Sum( x => KeySwitches.Remove( x ) ? 1 : 0 ) ); + var founds = await FindAsync( developerName, productName, instrumentName ); + return founds.Sum( x => KeySwitches.Remove( x ) ? 1 : 0 ); } public async Task DeleteAsync( DeveloperName developerName, ProductName productName ) { - var founds = Find( developerName, productName ); - return await Task.FromResult( founds.Sum( x => KeySwitches.Remove( x ) ? 1 : 0 ) ); + var founds = await FindAsync( developerName, productName ); + return founds.Sum( x => KeySwitches.Remove( x ) ? 1 : 0 ); } public async Task DeleteAsync( DeveloperName developerName ) { - var founds = Find( developerName ); - return await Task.FromResult( founds.Sum( x => KeySwitches.Remove( x ) ? 1 : 0 ) ); + var founds = await FindAsync( developerName ); + return founds.Sum( x => KeySwitches.Remove( x ) ? 1 : 0 ); } public async Task DeleteAsync( ProductName productName ) { - var founds = Find( productName ); - return await Task.FromResult( founds.Sum( x => KeySwitches.Remove( x ) ? 1 : 0 ) ); + var founds = await FindAsync( productName ); + return founds.Sum( x => KeySwitches.Remove( x ) ? 1 : 0 ); } public async Task DeleteAsync( InstrumentName instrumentName ) { - var founds = Find( instrumentName ); - return await Task.FromResult( founds.Sum( x => KeySwitches.Remove( x ) ? 1 : 0 ) ); + var founds = await FindAsync( instrumentName ); + return founds.Sum( x => KeySwitches.Remove( x ) ? 1 : 0 ); } public async Task DeleteAllAsync() @@ -104,75 +104,75 @@ public async Task DeleteAllAsync() #endregion #region Find - public IReadOnlyCollection Find( KeySwitchId keySwitchId ) - => KeySwitchHelper.SortByAlphabetical( + public async Task> FindAsync( KeySwitchId keySwitchId ) + => await Task.FromResult( KeySwitchHelper.SortByAlphabetical( KeySwitches.FindAll( x => x.Id.Value == keySwitchId.Value - )); + ))); - public IReadOnlyCollection Find( DeveloperName developerName, ProductName productName, InstrumentName instrumentName ) + public async Task> FindAsync( DeveloperName developerName, ProductName productName, InstrumentName instrumentName ) { var d = developerName.Value; var p = productName.Value; var i = instrumentName.Value; - return KeySwitchHelper.SortByAlphabetical( + return await Task.FromResult( KeySwitchHelper.SortByAlphabetical( KeySwitches.FindAll( x => ( d == DeveloperName.Any.Value || x.DeveloperName.Value.Contains( d ) ) && ( p == ProductName.Any.Value || x.ProductName.Value.Contains( p ) ) && ( i == InstrumentName.Any.Value || x.InstrumentName.Value.Contains( i ) ) - )); + ))); } - public IReadOnlyCollection Find( DeveloperName developerName, ProductName productName ) + public async Task> FindAsync( DeveloperName developerName, ProductName productName ) { var d = developerName.Value; var p = productName.Value; - return KeySwitchHelper.SortByAlphabetical( + return await Task.FromResult( KeySwitchHelper.SortByAlphabetical( KeySwitches.FindAll( x => ( d == DeveloperName.Any.Value || x.DeveloperName.Value.Contains( d ) ) && ( p == ProductName.Any.Value || x.ProductName.Value.Contains( p ) ) - )); + ))); } - public IReadOnlyCollection Find( DeveloperName developerName ) + public async Task> FindAsync( DeveloperName developerName ) { var d = developerName.Value; - return KeySwitchHelper.SortByAlphabetical( + return await Task.FromResult( KeySwitchHelper.SortByAlphabetical( KeySwitches.FindAll( x => d == DeveloperName.Any.Value || x.DeveloperName.Value.Contains( d ) - )); + ))); } - public IReadOnlyCollection Find( ProductName productName ) + public async Task> FindAsync( ProductName productName ) { var p = productName.Value; - return KeySwitchHelper.SortByAlphabetical( + return await Task.FromResult( KeySwitchHelper.SortByAlphabetical( KeySwitches.FindAll( x => p == ProductName.Any.Value || x.ProductName.Value.Contains( p ) - )); + ))); } - public IReadOnlyCollection Find( InstrumentName instrumentName ) + public async Task> FindAsync( InstrumentName instrumentName ) { var i = instrumentName.Value; - return KeySwitchHelper.SortByAlphabetical( + return await Task.FromResult( KeySwitchHelper.SortByAlphabetical( KeySwitches.FindAll( x => i == InstrumentName.Any.Value || x.InstrumentName.Value.Contains( i ) - )); + ))); } - public IReadOnlyCollection FindAll() - => KeySwitchHelper.SortByAlphabetical( new List( KeySwitches ) ); + public async Task> FindAllAsync() + => await Task.FromResult( KeySwitchHelper.SortByAlphabetical( new List( KeySwitches ) ) ); #endregion } } diff --git a/KeySwitchManager/Sources/Runtime/Infrastructures/Database.LiteDB/KeySwitches/LiteDbRepository.cs b/KeySwitchManager/Sources/Runtime/Infrastructures/Database.LiteDB/KeySwitches/LiteDbRepository.cs index 2f662df6..2e91de52 100644 --- a/KeySwitchManager/Sources/Runtime/Infrastructures/Database.LiteDB/KeySwitches/LiteDbRepository.cs +++ b/KeySwitchManager/Sources/Runtime/Infrastructures/Database.LiteDB/KeySwitches/LiteDbRepository.cs @@ -183,12 +183,12 @@ private IReadOnlyCollection CreateEntities( IEnumerable Find( KeySwitchId keySwitchId ) + public async Task> FindAsync( KeySwitchId keySwitchId ) { - return CreateEntities( KeySwitchTable.Find( x => x.Id == keySwitchId.Value ) ); + return await Task.FromResult( CreateEntities( KeySwitchTable.Find( x => x.Id == keySwitchId.Value ) ) ); } - public IReadOnlyCollection Find( + public async Task> FindAsync( DeveloperName developerName, ProductName productName, InstrumentName instrumentName ) @@ -197,79 +197,79 @@ public IReadOnlyCollection Find( var p = productName.Value; var i = instrumentName.Value; - return CreateEntities( + return await Task.FromResult( CreateEntities( KeySwitchTable.Find( x => ( d == DeveloperName.Any.Value || x.DeveloperName.Contains( d ) ) && ( p == ProductName.Any.Value || x.ProductName.Contains( p ) ) && ( i == InstrumentName.Any.Value || x.InstrumentName.Contains( i ) ) ) - ); + )); } - public IReadOnlyCollection Find( DeveloperName developerName, ProductName productName ) + public async Task> FindAsync( DeveloperName developerName, ProductName productName ) { var d = developerName.Value; var p = productName.Value; - return CreateEntities( + return await Task.FromResult( CreateEntities( KeySwitchTable.Find( x => ( d == DeveloperName.Any.Value || x.DeveloperName.Contains( d ) ) && ( p == ProductName.Any.Value || x.ProductName.Contains( p ) ) ) - ); + )); } - public IReadOnlyCollection Find( DeveloperName developerName ) + public async Task> FindAsync( DeveloperName developerName ) { var d = developerName.Value; if( d == DeveloperName.Any.Value ) { - return FindAll(); + return await FindAllAsync(); } - return CreateEntities( + return await Task.FromResult( CreateEntities( KeySwitchTable.Find( x => x.DeveloperName.Contains( d ) ) - ); + )); } - public IReadOnlyCollection Find( ProductName productName ) + public async Task> FindAsync( ProductName productName ) { var p = productName.Value; if( p == ProductName.Any.Value ) { - return FindAll(); + return await FindAllAsync(); } - return CreateEntities( + return await Task.FromResult( CreateEntities( KeySwitchTable.Find( x => x.ProductName.Contains( p ) ) - ); + )); } - public IReadOnlyCollection Find( InstrumentName instrumentName ) + public async Task> FindAsync( InstrumentName instrumentName ) { var i = instrumentName.Value; - return CreateEntities( + return await Task.FromResult( CreateEntities( KeySwitchTable.Find( x => i == InstrumentName.Any.Value || x.InstrumentName.Contains( i ) ) - ); + )); } - public IReadOnlyCollection FindAll() + public async Task> FindAllAsync() { - return CreateEntities( KeySwitchTable.FindAll() ); + return await Task.FromResult( CreateEntities( KeySwitchTable.FindAll() ) ); } #endregion } diff --git a/KeySwitchManager/Sources/Runtime/Infrastructures/Storage.Yaml/KeySwitches/YamlRepository.cs b/KeySwitchManager/Sources/Runtime/Infrastructures/Storage.Yaml/KeySwitches/YamlRepository.cs index 0c7f11bd..4901de71 100644 --- a/KeySwitchManager/Sources/Runtime/Infrastructures/Storage.Yaml/KeySwitches/YamlRepository.cs +++ b/KeySwitchManager/Sources/Runtime/Infrastructures/Storage.Yaml/KeySwitches/YamlRepository.cs @@ -141,7 +141,7 @@ public async Task DeleteAllAsync() #endregion #region Find - private static IReadOnlyCollection Convert( IReadOnlyCollection source ) + private static async Task> ConvertAsync( IReadOnlyCollection source ) { var result = new List(); @@ -150,43 +150,43 @@ private static IReadOnlyCollection Convert( IReadOnlyCollection Find( KeySwitchId keySwitchId ) + public async Task> FindAsync( KeySwitchId keySwitchId ) { - return Convert( YamlModel.Find( keySwitchId ) ); + return await ConvertAsync( YamlModel.Find( keySwitchId ) ); } - public IReadOnlyCollection Find( DeveloperName developerName, ProductName productName, InstrumentName instrumentName ) + public async Task> FindAsync( DeveloperName developerName, ProductName productName, InstrumentName instrumentName ) { - return Convert( YamlModel.Find( developerName, productName, instrumentName ) ); + return await ConvertAsync( YamlModel.Find( developerName, productName, instrumentName ) ); } - public IReadOnlyCollection Find( DeveloperName developerName, ProductName productName ) + public async Task> FindAsync( DeveloperName developerName, ProductName productName ) { - return Convert( YamlModel.Find( developerName, productName ) ); + return await ConvertAsync( YamlModel.Find( developerName, productName ) ); } - public IReadOnlyCollection Find( DeveloperName developerName ) + public async Task> FindAsync( DeveloperName developerName ) { - return Convert( YamlModel.Find( developerName ) ); + return await ConvertAsync( YamlModel.Find( developerName ) ); } - public IReadOnlyCollection Find( ProductName productName ) + public async Task> FindAsync( ProductName productName ) { - return Convert( YamlModel.Find( productName ) ); + return await ConvertAsync( YamlModel.Find( productName ) ); } - public IReadOnlyCollection Find( InstrumentName instrumentName ) + public async Task> FindAsync( InstrumentName instrumentName ) { - return Convert( YamlModel.Find( instrumentName ) ); + return await ConvertAsync( YamlModel.Find( instrumentName ) ); } - public IReadOnlyCollection FindAll() + public async Task> FindAllAsync() { - return Convert( YamlModel.KeySwitches ); + return await ConvertAsync( YamlModel.KeySwitches ); } #endregion } From 7d4cdcd9609f16a60a22391bf014d4d4935e0e72 Mon Sep 17 00:00:00 2001 From: "Hiroaki@R-koubou" Date: Sat, 21 Oct 2023 22:47:30 +0900 Subject: [PATCH 06/19] =?UTF-8?q?writer=E3=81=AE=E9=9D=9E=E5=90=8C?= =?UTF-8?q?=E6=9C=9F=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Domain/KeySwitches/Models/IKeySwitchWriter.cs | 6 +++++- .../KeySwitches/LiteDbFileWriter.cs | 5 +++-- .../KeySwitches/Cakewalk/CakewalkWriter.cs | 7 ++++--- .../KeySwitches/Cakewalk/DividedCakewalkWriter.cs | 5 +++-- .../KeySwitches/ClosedXmlWriter.cs | 5 ++++- .../KeySwitches/CombinedClosedXmlWriter.cs | 5 +++-- .../KeySwitches/DividedClosedXmlWriter.cs | 5 +++-- .../KeySwitches/Cubase/CubaseWriter.cs | 11 ++++++----- .../KeySwitches/StudioOne/StudioOneWriter.cs | 9 +++++---- .../KeySwitches/DividedYamlFileWriter.cs | 5 +++-- .../KeySwitches/YamlKeySwitchWriter.cs | 7 ++++--- .../KeySwitches/Helper/CombinedWritingHelper.cs | 8 ++++++-- .../KeySwitches/Helper/MultipleWritingHelper.cs | 15 +++++++++++---- 13 files changed, 60 insertions(+), 33 deletions(-) diff --git a/KeySwitchManager/Sources/Runtime/Domain/KeySwitches/Models/IKeySwitchWriter.cs b/KeySwitchManager/Sources/Runtime/Domain/KeySwitches/Models/IKeySwitchWriter.cs index be0777f3..92a68967 100644 --- a/KeySwitchManager/Sources/Runtime/Domain/KeySwitches/Models/IKeySwitchWriter.cs +++ b/KeySwitchManager/Sources/Runtime/Domain/KeySwitches/Models/IKeySwitchWriter.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Threading.Tasks; namespace KeySwitchManager.Domain.KeySwitches.Models { @@ -8,6 +9,9 @@ public interface IKeySwitchWriter : IDisposable public const int DefaultStreamWriterBufferSize = 1024; // System.IO.StreamWriter.DefaultBufferSize is 1024 public bool LeaveOpen { get; } - public void Write( IReadOnlyCollection keySwitches, IObserver? loggingSubject = null ); + public void Write( IReadOnlyCollection keySwitches, IObserver? loggingSubject = null ) + => WriteAsync( keySwitches, loggingSubject ).GetAwaiter().GetResult(); + + public Task WriteAsync( IReadOnlyCollection keySwitches, IObserver? loggingSubject ); } } diff --git a/KeySwitchManager/Sources/Runtime/Infrastructures/Database.LiteDB/KeySwitches/LiteDbFileWriter.cs b/KeySwitchManager/Sources/Runtime/Infrastructures/Database.LiteDB/KeySwitches/LiteDbFileWriter.cs index 4c878aa2..62e44991 100644 --- a/KeySwitchManager/Sources/Runtime/Infrastructures/Database.LiteDB/KeySwitches/LiteDbFileWriter.cs +++ b/KeySwitchManager/Sources/Runtime/Infrastructures/Database.LiteDB/KeySwitches/LiteDbFileWriter.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Threading.Tasks; using KeySwitchManager.Commons.Data; using KeySwitchManager.Domain.KeySwitches.Models; @@ -24,12 +25,12 @@ public void Dispose() Disposer.Dispose( Repository ); } - public void Write( IReadOnlyCollection keySwitches, IObserver? loggingSubject = null ) + async Task IKeySwitchWriter.WriteAsync( IReadOnlyCollection keySwitches, IObserver? loggingSubject ) { foreach( var x in keySwitches ) { loggingSubject?.OnNext( x.ToString() ); - Repository.Save( x ); + await Repository.SaveAsync( x ); } } } diff --git a/KeySwitchManager/Sources/Runtime/Infrastructures/Storage.Json/KeySwitches/Cakewalk/CakewalkWriter.cs b/KeySwitchManager/Sources/Runtime/Infrastructures/Storage.Json/KeySwitches/Cakewalk/CakewalkWriter.cs index e7ed5e28..67ea693c 100644 --- a/KeySwitchManager/Sources/Runtime/Infrastructures/Storage.Json/KeySwitches/Cakewalk/CakewalkWriter.cs +++ b/KeySwitchManager/Sources/Runtime/Infrastructures/Storage.Json/KeySwitches/Cakewalk/CakewalkWriter.cs @@ -3,6 +3,7 @@ using System.IO; using System.Linq; using System.Text; +using System.Threading.Tasks; using KeySwitchManager.Domain.KeySwitches.Models; using KeySwitchManager.Infrastructures.Storage.Json.KeySwitches.Cakewalk.Translators; @@ -38,7 +39,7 @@ public void Dispose() Stream = null; } - public void Write( IReadOnlyCollection keySwitches, IObserver? loggingSubject = null ) + async Task IKeySwitchWriter.WriteAsync( IReadOnlyCollection keySwitches, IObserver? loggingSubject ) { if( Stream == null ) { @@ -59,11 +60,11 @@ public void Write( IReadOnlyCollection keySwitches, IObserver loggingSubject?.OnNext( source.ToString() ); - using var writer = new StreamWriter( Stream, FileEncoding, IKeySwitchWriter.DefaultStreamWriterBufferSize, LeaveOpen ); + await using var writer = new StreamWriter( Stream, FileEncoding, IKeySwitchWriter.DefaultStreamWriterBufferSize, LeaveOpen ); // TODO すべての要素を束ねた 1 JSONファイルにしたい(Cakewalkは保持できる) var jsonText = new CakewalkExportTranslator( true ).Translate( source ); - writer.WriteLine( jsonText ); + await writer.WriteLineAsync( jsonText.Value ); } } } diff --git a/KeySwitchManager/Sources/Runtime/Infrastructures/Storage.Json/KeySwitches/Cakewalk/DividedCakewalkWriter.cs b/KeySwitchManager/Sources/Runtime/Infrastructures/Storage.Json/KeySwitches/Cakewalk/DividedCakewalkWriter.cs index dcfc433e..242871a6 100644 --- a/KeySwitchManager/Sources/Runtime/Infrastructures/Storage.Json/KeySwitches/Cakewalk/DividedCakewalkWriter.cs +++ b/KeySwitchManager/Sources/Runtime/Infrastructures/Storage.Json/KeySwitches/Cakewalk/DividedCakewalkWriter.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Text; +using System.Threading.Tasks; using KeySwitchManager.Commons.Data; using KeySwitchManager.Domain.KeySwitches.Models; @@ -26,9 +27,9 @@ public DividedCakewalkWriter( DirectoryPath outputDirectory, Encoding filEncodin public void Dispose() {} - public void Write( IReadOnlyCollection keySwitches, IObserver? loggingSubject = null ) + async Task IKeySwitchWriter.WriteAsync( IReadOnlyCollection keySwitches, IObserver? loggingSubject ) { - MultipleWritingHelper.Write( + await MultipleWritingHelper.WriteAsync( keySwitches, OutputDirectory, Suffix, diff --git a/KeySwitchManager/Sources/Runtime/Infrastructures/Storage.Spreadsheet.ClosedXml/KeySwitches/ClosedXmlWriter.cs b/KeySwitchManager/Sources/Runtime/Infrastructures/Storage.Spreadsheet.ClosedXml/KeySwitches/ClosedXmlWriter.cs index 4b56744a..c0fc7089 100644 --- a/KeySwitchManager/Sources/Runtime/Infrastructures/Storage.Spreadsheet.ClosedXml/KeySwitches/ClosedXmlWriter.cs +++ b/KeySwitchManager/Sources/Runtime/Infrastructures/Storage.Spreadsheet.ClosedXml/KeySwitches/ClosedXmlWriter.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Threading.Tasks; using ClosedXML.Excel; @@ -36,7 +37,7 @@ public void Dispose() Stream = null; } - public void Write( IReadOnlyCollection keySwitches, IObserver? loggingSubject = null ) + async Task IKeySwitchWriter.WriteAsync( IReadOnlyCollection keySwitches, IObserver? loggingSubject ) { using var template = new XLWorkbook( StreamHelper.GetAssemblyResourceStream( "Template.xlsx" ) @@ -61,6 +62,8 @@ public void Write( IReadOnlyCollection keySwitches, IObserver } workbook.SaveAs( Stream ); + + await Task.CompletedTask; } } } diff --git a/KeySwitchManager/Sources/Runtime/Infrastructures/Storage.Spreadsheet.ClosedXml/KeySwitches/CombinedClosedXmlWriter.cs b/KeySwitchManager/Sources/Runtime/Infrastructures/Storage.Spreadsheet.ClosedXml/KeySwitches/CombinedClosedXmlWriter.cs index 7257bd6e..32714065 100644 --- a/KeySwitchManager/Sources/Runtime/Infrastructures/Storage.Spreadsheet.ClosedXml/KeySwitches/CombinedClosedXmlWriter.cs +++ b/KeySwitchManager/Sources/Runtime/Infrastructures/Storage.Spreadsheet.ClosedXml/KeySwitches/CombinedClosedXmlWriter.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; using KeySwitchManager.Commons.Data; using KeySwitchManager.Domain.KeySwitches.Helpers; @@ -23,7 +24,7 @@ public CombinedClosedXmlWriter( DirectoryPath outputDirectory ) public void Dispose() {} - public void Write( IReadOnlyCollection keySwitches, IObserver? loggingSubject = null ) + async Task IKeySwitchWriter.WriteAsync( IReadOnlyCollection keySwitches, IObserver? loggingSubject ) { var groupByDeveloperAndProduct = KeySwitchHelper.GroupBy( keySwitches ); @@ -33,7 +34,7 @@ public void Write( IReadOnlyCollection keySwitches, IObserver var product = kvp.Key.Item2; var items = kvp.Value; - CombinedWritingHelper.Write( + await CombinedWritingHelper.WriteAsync( items, OutputDirectory, items.First(), diff --git a/KeySwitchManager/Sources/Runtime/Infrastructures/Storage.Spreadsheet.ClosedXml/KeySwitches/DividedClosedXmlWriter.cs b/KeySwitchManager/Sources/Runtime/Infrastructures/Storage.Spreadsheet.ClosedXml/KeySwitches/DividedClosedXmlWriter.cs index e6fd232a..748962fd 100644 --- a/KeySwitchManager/Sources/Runtime/Infrastructures/Storage.Spreadsheet.ClosedXml/KeySwitches/DividedClosedXmlWriter.cs +++ b/KeySwitchManager/Sources/Runtime/Infrastructures/Storage.Spreadsheet.ClosedXml/KeySwitches/DividedClosedXmlWriter.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Threading.Tasks; using KeySwitchManager.Commons.Data; using KeySwitchManager.Domain.KeySwitches.Models; @@ -21,9 +22,9 @@ public DividedClosedXmlWriter( DirectoryPath outputDirectory ) public void Dispose() {} - public void Write( IReadOnlyCollection keySwitches, IObserver? loggingSubject = null ) + async Task IKeySwitchWriter.WriteAsync( IReadOnlyCollection keySwitches, IObserver? loggingSubject ) { - MultipleWritingHelper.Write( + await MultipleWritingHelper.WriteAsync( keySwitches, OutputDirectory, Suffix, diff --git a/KeySwitchManager/Sources/Runtime/Infrastructures/Storage.Xml/KeySwitches/Cubase/CubaseWriter.cs b/KeySwitchManager/Sources/Runtime/Infrastructures/Storage.Xml/KeySwitches/Cubase/CubaseWriter.cs index acedbc97..584be3e6 100644 --- a/KeySwitchManager/Sources/Runtime/Infrastructures/Storage.Xml/KeySwitches/Cubase/CubaseWriter.cs +++ b/KeySwitchManager/Sources/Runtime/Infrastructures/Storage.Xml/KeySwitches/Cubase/CubaseWriter.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using System.Text; +using System.Threading.Tasks; using KeySwitchManager.Commons.Data; using KeySwitchManager.Domain.KeySwitches.Models; @@ -28,15 +29,15 @@ public CubaseWriter( DirectoryPath outputDirectory, Encoding filEncoding ) public void Dispose() {} - public void Write( IReadOnlyCollection keySwitches, IObserver? logging = null ) - => MultipleWritingHelper.Write( keySwitches, OutputDirectory, Suffix, logging, WriteImpl ); + async Task IKeySwitchWriter.WriteAsync( IReadOnlyCollection keySwitches, IObserver? logging ) + => await MultipleWritingHelper.WriteAsync( keySwitches, OutputDirectory, Suffix, logging, WriteImplAsync ); - private void WriteImpl( Stream stream, KeySwitch keySwitch, IObserver? logging ) + private async Task WriteImplAsync( Stream stream, KeySwitch keySwitch, IObserver? logging ) { - using var writer = new StreamWriter( stream, FileEncoding, IKeySwitchWriter.DefaultStreamWriterBufferSize, LeaveOpen ); + await using var writer = new StreamWriter( stream, FileEncoding, IKeySwitchWriter.DefaultStreamWriterBufferSize, LeaveOpen ); var xmlText = new CubaseExportTranslator().Translate( keySwitch ); - writer.WriteLine( xmlText ); + await writer.WriteLineAsync( xmlText.Value ); } } diff --git a/KeySwitchManager/Sources/Runtime/Infrastructures/Storage.Xml/KeySwitches/StudioOne/StudioOneWriter.cs b/KeySwitchManager/Sources/Runtime/Infrastructures/Storage.Xml/KeySwitches/StudioOne/StudioOneWriter.cs index 9ce063da..bfafe80a 100644 --- a/KeySwitchManager/Sources/Runtime/Infrastructures/Storage.Xml/KeySwitches/StudioOne/StudioOneWriter.cs +++ b/KeySwitchManager/Sources/Runtime/Infrastructures/Storage.Xml/KeySwitches/StudioOne/StudioOneWriter.cs @@ -3,6 +3,7 @@ using System.IO; using System.Linq; using System.Text; +using System.Threading.Tasks; using KeySwitchManager.Commons.Data; using KeySwitchManager.Domain.KeySwitches.Helpers; @@ -34,7 +35,7 @@ public StudioOneWriter( DirectoryPath outputDirectory, Encoding filEncoding ) public void Dispose() {} - public void Write( IReadOnlyCollection keySwitches, IObserver? logging = null ) + async Task IKeySwitchWriter.WriteAsync( IReadOnlyCollection keySwitches, IObserver? logging ) { if( !keySwitches.Any() ) { @@ -50,11 +51,11 @@ public void Write( IReadOnlyCollection keySwitches, IObserver Translate( rootElement, developerName, productName, x, logging ); var filePath = CreatePathHelper.CreateFilePath( developerName, productName, Suffix, OutputDirectory ); - using var stream = filePath.OpenStream( FileMode.Create, FileAccess.ReadWrite ); - using var writer = new StreamWriter( stream, FileEncoding, IKeySwitchWriter.DefaultStreamWriterBufferSize, LeaveOpen ); + await using var stream = filePath.OpenStream( FileMode.Create, FileAccess.ReadWrite ); + await using var writer = new StreamWriter( stream, FileEncoding, IKeySwitchWriter.DefaultStreamWriterBufferSize, LeaveOpen ); var xmlText = XmlHelper.ToXmlString( rootElement ); - writer.WriteLine( xmlText ); + await writer.WriteLineAsync( xmlText ); } } diff --git a/KeySwitchManager/Sources/Runtime/Infrastructures/Storage.Yaml/KeySwitches/DividedYamlFileWriter.cs b/KeySwitchManager/Sources/Runtime/Infrastructures/Storage.Yaml/KeySwitches/DividedYamlFileWriter.cs index 9247e881..49e3807b 100644 --- a/KeySwitchManager/Sources/Runtime/Infrastructures/Storage.Yaml/KeySwitches/DividedYamlFileWriter.cs +++ b/KeySwitchManager/Sources/Runtime/Infrastructures/Storage.Yaml/KeySwitches/DividedYamlFileWriter.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Text; +using System.Threading.Tasks; using KeySwitchManager.Commons.Data; using KeySwitchManager.Domain.KeySwitches.Models; @@ -26,9 +27,9 @@ public DividedYamlFileWriter( DirectoryPath outputDirectory, Encoding filEncodin public void Dispose() {} - public void Write( IReadOnlyCollection keySwitches, IObserver? loggingSubject = null ) + async Task IKeySwitchWriter.WriteAsync( IReadOnlyCollection keySwitches, IObserver? loggingSubject ) { - MultipleWritingHelper.Write( + await MultipleWritingHelper.WriteAsync( keySwitches, OutputDirectory, Suffix, diff --git a/KeySwitchManager/Sources/Runtime/Infrastructures/Storage.Yaml/KeySwitches/YamlKeySwitchWriter.cs b/KeySwitchManager/Sources/Runtime/Infrastructures/Storage.Yaml/KeySwitches/YamlKeySwitchWriter.cs index 0024ac9c..801a03b0 100644 --- a/KeySwitchManager/Sources/Runtime/Infrastructures/Storage.Yaml/KeySwitches/YamlKeySwitchWriter.cs +++ b/KeySwitchManager/Sources/Runtime/Infrastructures/Storage.Yaml/KeySwitches/YamlKeySwitchWriter.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using System.Text; +using System.Threading.Tasks; using KeySwitchManager.Domain.KeySwitches.Models; using KeySwitchManager.Infrastructures.Storage.Yaml.KeySwitches.Translators; @@ -45,7 +46,7 @@ public void Dispose() Stream = null; } - public void Write( IReadOnlyCollection keySwitches, IObserver? loggingSubject = null ) + async Task IKeySwitchWriter.WriteAsync( IReadOnlyCollection keySwitches, IObserver? loggingSubject ) { if( Stream == null ) { @@ -60,10 +61,10 @@ public void Write( IReadOnlyCollection keySwitches, IObserver } } - using var writer = new StreamWriter( Stream, FileEncoding, IKeySwitchWriter.DefaultStreamWriterBufferSize, LeaveOpen ); + await using var writer = new StreamWriter( Stream, FileEncoding, IKeySwitchWriter.DefaultStreamWriterBufferSize, LeaveOpen ); var yamlText = new YamlKeySwitchExportTranslator().Translate( keySwitches ); - writer.WriteLine( yamlText ); + await writer.WriteLineAsync( yamlText.Value ); } } } diff --git a/KeySwitchManager/Sources/Runtime/Infrastructures/Storage/KeySwitches/Helper/CombinedWritingHelper.cs b/KeySwitchManager/Sources/Runtime/Infrastructures/Storage/KeySwitches/Helper/CombinedWritingHelper.cs index bfdf2b5d..b8f14cf1 100644 --- a/KeySwitchManager/Sources/Runtime/Infrastructures/Storage/KeySwitches/Helper/CombinedWritingHelper.cs +++ b/KeySwitchManager/Sources/Runtime/Infrastructures/Storage/KeySwitches/Helper/CombinedWritingHelper.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Threading.Tasks; using KeySwitchManager.Commons.Data; using KeySwitchManager.Domain.KeySwitches.Models; @@ -10,14 +11,17 @@ namespace KeySwitchManager.Infrastructures.Storage.KeySwitches.Helper public static class CombinedWritingHelper { public static void Write( IReadOnlyCollection keySwitches, DirectoryPath outputDirectory, KeySwitch prefix, string suffix, IObserver? loggingSubject, Func writerFactory ) + => WriteAsync( keySwitches, outputDirectory, prefix, suffix, loggingSubject, writerFactory ).GetAwaiter().GetResult(); + + public async static Task WriteAsync( IReadOnlyCollection keySwitches, DirectoryPath outputDirectory, KeySwitch prefix, string suffix, IObserver? loggingSubject, Func writerFactory ) { var filePath = CreatePathHelper.CreateFilePath( prefix.DeveloperName, prefix.ProductName, string.Empty, suffix, outputDirectory ); // Some writers require Read/Write access stream - using var stream = filePath.OpenStream( FileMode.Create, FileAccess.ReadWrite ); + await using var stream = filePath.OpenStream( FileMode.Create, FileAccess.ReadWrite ); using var fileWriter = writerFactory.Invoke( stream ); - fileWriter.Write( keySwitches, loggingSubject ); + await fileWriter.WriteAsync( keySwitches, loggingSubject ); loggingSubject?.OnNext( $"{nameof(CombinedWritingHelper)} : {keySwitches.Count} records has been written" ); } } diff --git a/KeySwitchManager/Sources/Runtime/Infrastructures/Storage/KeySwitches/Helper/MultipleWritingHelper.cs b/KeySwitchManager/Sources/Runtime/Infrastructures/Storage/KeySwitches/Helper/MultipleWritingHelper.cs index 6a777f6c..fe125b37 100644 --- a/KeySwitchManager/Sources/Runtime/Infrastructures/Storage/KeySwitches/Helper/MultipleWritingHelper.cs +++ b/KeySwitchManager/Sources/Runtime/Infrastructures/Storage/KeySwitches/Helper/MultipleWritingHelper.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Threading.Tasks; using KeySwitchManager.Commons.Data; using KeySwitchManager.Domain.KeySwitches.Models; @@ -10,22 +11,28 @@ namespace KeySwitchManager.Infrastructures.Storage.KeySwitches.Helper public static class MultipleWritingHelper { public static void Write( IReadOnlyCollection keySwitches, DirectoryPath outputDirectory, string suffix, IObserver? loggingSubject, Func writerFactory ) + => WriteAsync( keySwitches, outputDirectory, suffix, loggingSubject, writerFactory ).GetAwaiter().GetResult(); + + public async static Task WriteAsync( IReadOnlyCollection keySwitches, DirectoryPath outputDirectory, string suffix, IObserver? loggingSubject, Func writerFactory ) { foreach( var x in keySwitches ) { var filePath = CreatePathHelper.CreateFilePath( x, suffix, outputDirectory ); // Some writers require Read/Write access stream - using var stream = filePath.OpenStream( FileMode.Create, FileAccess.ReadWrite ); + await using var stream = filePath.OpenStream( FileMode.Create, FileAccess.ReadWrite ); using var fileWriter = writerFactory.Invoke( stream ); - fileWriter.Write( new[] { x }, loggingSubject ); + await fileWriter.WriteAsync( new[] { x }, loggingSubject ); } loggingSubject?.OnNext( $"{nameof(MultipleWritingHelper)} : {keySwitches.Count} records has been written" ); } - public static void Write( IReadOnlyCollection keySwitches, DirectoryPath outputDirectory, string suffix, IObserver? logging, Action?> write ) + public static void Write( IReadOnlyCollection keySwitches, DirectoryPath outputDirectory, string suffix, IObserver? logging, Func?, Task> write ) + => WriteAsync( keySwitches, outputDirectory, suffix, logging, write ).GetAwaiter().GetResult(); + + public async static Task WriteAsync( IReadOnlyCollection keySwitches, DirectoryPath outputDirectory, string suffix, IObserver? logging, Func?, Task> write ) { foreach( var x in keySwitches ) { @@ -34,7 +41,7 @@ public static void Write( IReadOnlyCollection keySwitches, DirectoryP var filePath = CreatePathHelper.CreateFilePath( x, suffix, outputDirectory ); // Some writers require Read/Write access stream - using var stream = filePath.OpenStream( FileMode.Create, FileAccess.ReadWrite ); + await using var stream = filePath.OpenStream( FileMode.Create, FileAccess.ReadWrite ); write.Invoke( stream, x, logging ); } From ab53cf288decc13e06bc5229af7f9152096c0435 Mon Sep 17 00:00:00 2001 From: "Hiroaki@R-koubou" Date: Sat, 21 Oct 2023 23:20:31 +0900 Subject: [PATCH 07/19] =?UTF-8?q?reader=E3=81=AE=E9=9D=9E=E5=90=8C?= =?UTF-8?q?=E6=9C=9F=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Runtime/Domain/KeySwitches/Models/IKeySwitchReader.cs | 7 ++++++- .../KeySwitches/ClosedXmlReader.cs | 7 ++++--- .../Storage.Yaml/KeySwitches/YamlKeySwitchReader.cs | 5 +++-- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/KeySwitchManager/Sources/Runtime/Domain/KeySwitches/Models/IKeySwitchReader.cs b/KeySwitchManager/Sources/Runtime/Domain/KeySwitches/Models/IKeySwitchReader.cs index f01f1041..58fa3ede 100644 --- a/KeySwitchManager/Sources/Runtime/Domain/KeySwitches/Models/IKeySwitchReader.cs +++ b/KeySwitchManager/Sources/Runtime/Domain/KeySwitches/Models/IKeySwitchReader.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Threading.Tasks; namespace KeySwitchManager.Domain.KeySwitches.Models { @@ -7,6 +8,10 @@ public interface IKeySwitchReader : IDisposable { public const int DefaultStreamReaderBufferSize = 4096; // System.IO.StreamReader.DefaultBufferSize is 4096 public bool LeaveOpen { get; } - public IReadOnlyCollection Read( IObserver? loggingSubject = null ); + + public IReadOnlyCollection Read( IObserver? loggingSubject = null ) + => ReadAsync( loggingSubject ).GetAwaiter().GetResult(); + + public Task> ReadAsync( IObserver? loggingSubject ); } } diff --git a/KeySwitchManager/Sources/Runtime/Infrastructures/Storage.Spreadsheet.ClosedXml/KeySwitches/ClosedXmlReader.cs b/KeySwitchManager/Sources/Runtime/Infrastructures/Storage.Spreadsheet.ClosedXml/KeySwitches/ClosedXmlReader.cs index e4c68917..29c7a4ba 100644 --- a/KeySwitchManager/Sources/Runtime/Infrastructures/Storage.Spreadsheet.ClosedXml/KeySwitches/ClosedXmlReader.cs +++ b/KeySwitchManager/Sources/Runtime/Infrastructures/Storage.Spreadsheet.ClosedXml/KeySwitches/ClosedXmlReader.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Threading.Tasks; using KeySwitchManager.Domain.KeySwitches.Models; using KeySwitchManager.Infrastructures.Storage.Spreadsheet.ClosedXml.KeySwitches.Helper; @@ -37,7 +38,7 @@ public void Dispose() Stream = null; } - public IReadOnlyCollection Read( IObserver? loggingSubject = null ) + async Task> IKeySwitchReader.ReadAsync( IObserver? loggingSubject ) { if( Stream == null ) { @@ -46,8 +47,8 @@ public IReadOnlyCollection Read( IObserver? loggingSubject = using var memory = new MemoryStream( InitialBufferSize ); - StreamHelper.ReadAllAndWrite( Stream, memory ); - byte[] xlsxBytes = memory.ToArray(); + await StreamHelper.ReadAllAndWriteAsync( Stream, memory ); + var xlsxBytes = memory.ToArray(); var workBook = XlsxWorkBookParsingHelper.Parse( xlsxBytes ); var translator = new SpreadsheetImportTranslator(); diff --git a/KeySwitchManager/Sources/Runtime/Infrastructures/Storage.Yaml/KeySwitches/YamlKeySwitchReader.cs b/KeySwitchManager/Sources/Runtime/Infrastructures/Storage.Yaml/KeySwitches/YamlKeySwitchReader.cs index 4619d7f8..2545881a 100644 --- a/KeySwitchManager/Sources/Runtime/Infrastructures/Storage.Yaml/KeySwitches/YamlKeySwitchReader.cs +++ b/KeySwitchManager/Sources/Runtime/Infrastructures/Storage.Yaml/KeySwitches/YamlKeySwitchReader.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using System.Text; +using System.Threading.Tasks; using KeySwitchManager.Commons.Data; using KeySwitchManager.Domain.KeySwitches.Models; @@ -37,7 +38,7 @@ public void Dispose() Stream = null; } - public IReadOnlyCollection Read( IObserver? loggingSubject = null ) + async Task> IKeySwitchReader.ReadAsync( IObserver? loggingSubject ) { if( Stream == null ) { @@ -45,7 +46,7 @@ public IReadOnlyCollection Read( IObserver? loggingSubject = } using var reader = new StreamReader( Stream, FileEncoding, true, IKeySwitchReader.DefaultStreamReaderBufferSize, LeaveOpen ); - var jsonText = reader.ReadToEnd(); + var jsonText = await reader.ReadToEndAsync(); var keySwitches = new YamlKeySwitchImportTranslator().Translate( new PlainText( jsonText ) ); From 68696b01b64bf3eb4a3a4085d05180e3c8c8fc3a Mon Sep 17 00:00:00 2001 From: "Hiroaki@R-koubou" Date: Sat, 21 Oct 2023 23:25:41 +0900 Subject: [PATCH 08/19] =?UTF-8?q?=E8=87=AA=E4=BD=9C=E3=83=A9=E3=82=A4?= =?UTF-8?q?=E3=83=96=E3=83=A9=E3=83=AA=E3=81=AE=E9=9D=9E=E5=90=8C=E6=9C=9F?= =?UTF-8?q?=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89=E5=AF=BE=E5=BF=9C=E3=82=92?= =?UTF-8?q?=E5=8F=8D=E6=98=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- KeySwitchManager/Sources/Runtime/Commons/Commons.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/KeySwitchManager/Sources/Runtime/Commons/Commons.csproj b/KeySwitchManager/Sources/Runtime/Commons/Commons.csproj index 077bffd4..d17251c1 100644 --- a/KeySwitchManager/Sources/Runtime/Commons/Commons.csproj +++ b/KeySwitchManager/Sources/Runtime/Commons/Commons.csproj @@ -14,7 +14,7 @@ - + From fae249647e755ba124ee7f88e9be6611ad2631d3 Mon Sep 17 00:00:00 2001 From: "Hiroaki@R-koubou" Date: Sat, 21 Oct 2023 23:41:10 +0900 Subject: [PATCH 09/19] =?UTF-8?q?usecase=E3=81=AE=E9=9D=9E=E5=90=8C?= =?UTF-8?q?=E6=9C=9F=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../KeySwitches/Helpers/SearchHelper.cs | 38 +++++++++++++++---- .../KeySwitches/CreateFileInteractor.cs | 6 ++- .../KeySwitches/DeleteInteractor.cs | 10 +++-- .../KeySwitches/DumpFileInteractor.cs | 9 +++-- .../KeySwitches/ExportFileInteractor.cs | 9 +++-- .../Interactors/KeySwitches/FindInteractor.cs | 11 +++--- .../KeySwitches/ImportFileInteractor.cs | 8 ++-- .../KeySwitches/Create/ICreateFileUseCase.cs | 9 ++++- .../KeySwitches/Delete/IDeleteUseCase.cs | 9 ++++- .../KeySwitches/Dump/IDumpFileUseCase.cs | 9 ++++- .../KeySwitches/Export/IExportFileUseCase.cs | 8 +++- .../UseCases/KeySwitches/Find/IFindUseCase.cs | 9 ++++- .../KeySwitches/Import/IImportFileUseCase.cs | 9 ++++- 13 files changed, 102 insertions(+), 42 deletions(-) diff --git a/KeySwitchManager/Sources/Runtime/Domain/KeySwitches/Helpers/SearchHelper.cs b/KeySwitchManager/Sources/Runtime/Domain/KeySwitches/Helpers/SearchHelper.cs index 6e0562ba..fa4b1f60 100644 --- a/KeySwitchManager/Sources/Runtime/Domain/KeySwitches/Helpers/SearchHelper.cs +++ b/KeySwitchManager/Sources/Runtime/Domain/KeySwitches/Helpers/SearchHelper.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Threading.Tasks; using KeySwitchManager.Domain.KeySwitches.Models; using KeySwitchManager.Domain.KeySwitches.Models.Values; @@ -11,13 +12,21 @@ namespace KeySwitchManager.Domain.KeySwitches.Helpers public static class SearchHelper { #region Search + public static IReadOnlyCollection Search( IKeySwitchRepository repository, string developerName = "", string productName = "", string instrumentName = "" ) + => SearchAsync( repository, developerName, productName, instrumentName ).GetAwaiter().GetResult(); + + public static async Task> SearchAsync( + IKeySwitchRepository repository, + string developerName = "", + string productName = "", + string instrumentName = "" ) { - return Search( repository, default, developerName, productName, instrumentName ); + return await SearchAsync( repository, default, developerName, productName, instrumentName ); } public static IReadOnlyCollection Search( @@ -26,11 +35,19 @@ public static IReadOnlyCollection Search( string developerName = "", string productName = "", string instrumentName = "" ) + => SearchAsync( repository, guid, developerName, productName, instrumentName ).GetAwaiter().GetResult(); + + public static async Task> SearchAsync( + IKeySwitchRepository repository, + Guid guid = default, + string developerName = "", + string productName = "", + string instrumentName = "" ) { #region By Guid if( guid != default ) { - return new List( repository.Find( new KeySwitchId( guid ) ) ); + return new List( await repository.FindAsync( new KeySwitchId( guid ) ) ); } #endregion @@ -38,7 +55,7 @@ public static IReadOnlyCollection Search( if( !StringHelper.IsEmpty( developerName, productName, instrumentName ) ) { return new List( - repository.Find( + await repository.FindAsync( new DeveloperName( developerName ), new ProductName( productName ), new InstrumentName( instrumentName ) ) @@ -50,7 +67,7 @@ public static IReadOnlyCollection Search( if( !StringHelper.IsEmpty( developerName, productName ) ) { return new List( - repository.Find( + await repository.FindAsync( new DeveloperName( developerName ), new ProductName( productName ) ) @@ -62,7 +79,7 @@ public static IReadOnlyCollection Search( if( !StringHelper.IsEmpty( developerName ) ) { return new List( - repository.Find( + await repository.FindAsync( new DeveloperName( developerName ) ) ); @@ -70,14 +87,19 @@ public static IReadOnlyCollection Search( #endregion // All - return new List( repository.FindAll() ); + return new List( await repository.FindAllAsync() ); } public static IReadOnlyCollection Search( IKeySwitchRepository repository, KeySwitchInfo info ) + => SearchAsync( repository, info ).GetAwaiter().GetResult(); + + public static async Task> SearchAsync( + IKeySwitchRepository repository, + KeySwitchInfo info ) { - return Search( + return await SearchAsync( repository, info.DeveloperName, info.ProductName @@ -86,4 +108,4 @@ public static IReadOnlyCollection Search( #endregion } -} \ No newline at end of file +} diff --git a/KeySwitchManager/Sources/Runtime/Interactors/KeySwitches/CreateFileInteractor.cs b/KeySwitchManager/Sources/Runtime/Interactors/KeySwitches/CreateFileInteractor.cs index 2f55e039..1000e33d 100644 --- a/KeySwitchManager/Sources/Runtime/Interactors/KeySwitches/CreateFileInteractor.cs +++ b/KeySwitchManager/Sources/Runtime/Interactors/KeySwitches/CreateFileInteractor.cs @@ -1,3 +1,5 @@ +using System.Threading.Tasks; + using KeySwitchManager.Domain.KeySwitches.Helpers; using KeySwitchManager.UseCase.KeySwitches.Create; @@ -15,10 +17,10 @@ public CreateFileInteractor( ICreateFilePresenter presenter ) Presenter = presenter; } - public CreateFileResponse Execute( CreateFileRequest request ) + async Task ICreateFileUseCase.ExecuteAsync( CreateFileRequest request ) { var keyswitch = KeySwitchFactoryHelper.CreateTemplate(); - request.Writer.Write( new[] { keyswitch } ); + await request.Writer.WriteAsync( new[] { keyswitch }, null ); return new CreateFileResponse(); } diff --git a/KeySwitchManager/Sources/Runtime/Interactors/KeySwitches/DeleteInteractor.cs b/KeySwitchManager/Sources/Runtime/Interactors/KeySwitches/DeleteInteractor.cs index 26ec09be..ce1153a7 100644 --- a/KeySwitchManager/Sources/Runtime/Interactors/KeySwitches/DeleteInteractor.cs +++ b/KeySwitchManager/Sources/Runtime/Interactors/KeySwitches/DeleteInteractor.cs @@ -1,3 +1,5 @@ +using System.Threading.Tasks; + using KeySwitchManager.Domain.KeySwitches.Models; using KeySwitchManager.Domain.KeySwitches.Models.Values; using KeySwitchManager.UseCase.KeySwitches.Delete; @@ -23,7 +25,7 @@ public DeleteInteractor( Presenter = presenter; } - public DeleteResponse Execute( DeleteRequest request ) + async Task IDeleteUseCase.ExecuteAsync( DeleteRequest request ) { var developerName = request.DeveloperName; var productName = request.ProductName; @@ -35,7 +37,7 @@ public DeleteResponse Execute( DeleteRequest request ) if( !StringHelper.IsEmpty( developerName, productName, instrumentName ) ) { - removedCount = Repository.Delete( + removedCount = await Repository.DeleteAsync( new DeveloperName( developerName ), new ProductName( productName ), new InstrumentName( instrumentName ) @@ -43,7 +45,7 @@ public DeleteResponse Execute( DeleteRequest request ) } else if( !StringHelper.IsEmpty( developerName, productName ) ) { - removedCount = Repository.Delete( + removedCount = await Repository.DeleteAsync( new DeveloperName( developerName ), new ProductName( productName ) ); @@ -61,4 +63,4 @@ public DeleteResponse Execute( DeleteRequest request ) return new DeleteResponse( removedCount ); } } -} \ No newline at end of file +} diff --git a/KeySwitchManager/Sources/Runtime/Interactors/KeySwitches/DumpFileInteractor.cs b/KeySwitchManager/Sources/Runtime/Interactors/KeySwitches/DumpFileInteractor.cs index 1ebb863e..fa534060 100644 --- a/KeySwitchManager/Sources/Runtime/Interactors/KeySwitches/DumpFileInteractor.cs +++ b/KeySwitchManager/Sources/Runtime/Interactors/KeySwitches/DumpFileInteractor.cs @@ -1,4 +1,5 @@ using System.Linq; +using System.Threading.Tasks; using KeySwitchManager.Domain.KeySwitches.Models; using KeySwitchManager.UseCase.KeySwitches.Dump; @@ -26,9 +27,9 @@ public DumpFileInteractor( Presenter = presenter; } - public DumpFileResponse Execute( DumpFileRequest request ) + async Task IDumpFileUseCase.ExecuteAsync( DumpFileRequest request ) { - var all = Repository.FindAll(); + var all = await Repository.FindAllAsync(); var sorted = all.OrderBy( x => x.DeveloperName.Value ) .ThenBy( x => x.ProductName.Value ) @@ -36,7 +37,7 @@ public DumpFileResponse Execute( DumpFileRequest request ) if( sorted.Count > 0 ) { - Writer.Write( sorted ); + await Writer.WriteAsync( sorted, null ); return new DumpFileResponse( sorted.Count ); } @@ -44,4 +45,4 @@ public DumpFileResponse Execute( DumpFileRequest request ) return new DumpFileResponse( 0 ); } } -} \ No newline at end of file +} diff --git a/KeySwitchManager/Sources/Runtime/Interactors/KeySwitches/ExportFileInteractor.cs b/KeySwitchManager/Sources/Runtime/Interactors/KeySwitches/ExportFileInteractor.cs index 4f63cc2b..228aee9a 100644 --- a/KeySwitchManager/Sources/Runtime/Interactors/KeySwitches/ExportFileInteractor.cs +++ b/KeySwitchManager/Sources/Runtime/Interactors/KeySwitches/ExportFileInteractor.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; using KeySwitchManager.Domain.KeySwitches.Helpers; using KeySwitchManager.Domain.KeySwitches.Models; @@ -30,13 +31,13 @@ public ExportFileInteractor( Presenter = presenter; } - public ExportFileResponse Execute( ExportFileRequest request, IObserver? loggingSubject = null ) + async Task IExportFileUseCase.ExecuteAsync( ExportFileRequest request, IObserver? loggingSubject ) { var developerName = request.DeveloperName; var productName = request.ProductName; var instrumentName = request.InstrumentName; - var queryResult = SearchHelper.Search( + var queryResult = await SearchHelper.SearchAsync( Repository, developerName, productName, @@ -45,7 +46,7 @@ public ExportFileResponse Execute( ExportFileRequest request, IObserver? if( queryResult.Any() ) { - Writer.Write( queryResult, loggingSubject ); + await Writer.WriteAsync( queryResult, loggingSubject ); return new ExportFileResponse( queryResult ); } @@ -53,4 +54,4 @@ public ExportFileResponse Execute( ExportFileRequest request, IObserver? return new ExportFileResponse( new List() ); } } -} \ No newline at end of file +} diff --git a/KeySwitchManager/Sources/Runtime/Interactors/KeySwitches/FindInteractor.cs b/KeySwitchManager/Sources/Runtime/Interactors/KeySwitches/FindInteractor.cs index 1a961f45..90517638 100644 --- a/KeySwitchManager/Sources/Runtime/Interactors/KeySwitches/FindInteractor.cs +++ b/KeySwitchManager/Sources/Runtime/Interactors/KeySwitches/FindInteractor.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Threading.Tasks; using KeySwitchManager.Domain.KeySwitches.Models; using KeySwitchManager.Domain.KeySwitches.Models.Values; @@ -26,7 +27,7 @@ public FindInteractor( Presenter = presenter; } - public FindResponse Execute( FindRequest request ) + async Task IFindUseCase.ExecuteAsync( FindRequest request ) { var developerName = request.DeveloperName; var productName = request.ProductName; @@ -35,7 +36,7 @@ public FindResponse Execute( FindRequest request ) #region By Developer, Product, Instrument if( !StringHelper.IsEmpty( developerName, productName, instrumentName ) ) { - var keySwitches = Repository.Find( + var keySwitches = await Repository.FindAsync( new DeveloperName( request.DeveloperName ), new ProductName( request.ProductName ), new InstrumentName( request.InstrumentName ) @@ -48,7 +49,7 @@ public FindResponse Execute( FindRequest request ) #region By Developer, Product if( !StringHelper.IsEmpty( developerName, productName ) ) { - var keySwitches = Repository.Find( + var keySwitches = await Repository.FindAsync( new DeveloperName( request.DeveloperName ), new ProductName( request.ProductName ) ); @@ -60,7 +61,7 @@ public FindResponse Execute( FindRequest request ) #region By Developer if( !StringHelper.IsEmpty( developerName ) ) { - var keySwitches = Repository.Find( + var keySwitches = await Repository.FindAsync( new DeveloperName( request.DeveloperName ) ); @@ -71,4 +72,4 @@ public FindResponse Execute( FindRequest request ) return new FindResponse( new List() ); } } -} \ No newline at end of file +} diff --git a/KeySwitchManager/Sources/Runtime/Interactors/KeySwitches/ImportFileInteractor.cs b/KeySwitchManager/Sources/Runtime/Interactors/KeySwitches/ImportFileInteractor.cs index 652f3866..2f045289 100644 --- a/KeySwitchManager/Sources/Runtime/Interactors/KeySwitches/ImportFileInteractor.cs +++ b/KeySwitchManager/Sources/Runtime/Interactors/KeySwitches/ImportFileInteractor.cs @@ -1,3 +1,5 @@ +using System.Threading.Tasks; + using KeySwitchManager.Domain.KeySwitches.Models; using KeySwitchManager.UseCase.KeySwitches.Import; @@ -21,14 +23,14 @@ public ImportFileInteractor( Presenter = presenter; } - public ImportFileResponse Execute( ImportFileRequest request ) + async Task IImportFileUseCase.ExecuteAsync( ImportFileRequest request ) { var insertedCount = 0; var updatedCount = 0; foreach( var i in request.KeySwitches ) { - var r = Repository.Save( i ); + var r = await Repository.SaveAsync( i ); updatedCount += r.Updated; insertedCount += r.Inserted; } @@ -39,4 +41,4 @@ public ImportFileResponse Execute( ImportFileRequest request ) } } -} \ No newline at end of file +} diff --git a/KeySwitchManager/Sources/Runtime/UseCases/KeySwitches/Create/ICreateFileUseCase.cs b/KeySwitchManager/Sources/Runtime/UseCases/KeySwitches/Create/ICreateFileUseCase.cs index 7a09e2eb..dc15acdd 100644 --- a/KeySwitchManager/Sources/Runtime/UseCases/KeySwitches/Create/ICreateFileUseCase.cs +++ b/KeySwitchManager/Sources/Runtime/UseCases/KeySwitches/Create/ICreateFileUseCase.cs @@ -1,7 +1,12 @@ +using System.Threading.Tasks; + namespace KeySwitchManager.UseCase.KeySwitches.Create { public interface ICreateFileUseCase { - public CreateFileResponse Execute( CreateFileRequest request ); + public CreateFileResponse Execute( CreateFileRequest request ) + => ExecuteAsync( request ).GetAwaiter().GetResult(); + + public Task ExecuteAsync( CreateFileRequest request ); } -} \ No newline at end of file +} diff --git a/KeySwitchManager/Sources/Runtime/UseCases/KeySwitches/Delete/IDeleteUseCase.cs b/KeySwitchManager/Sources/Runtime/UseCases/KeySwitches/Delete/IDeleteUseCase.cs index 6525e336..234b29c0 100644 --- a/KeySwitchManager/Sources/Runtime/UseCases/KeySwitches/Delete/IDeleteUseCase.cs +++ b/KeySwitchManager/Sources/Runtime/UseCases/KeySwitches/Delete/IDeleteUseCase.cs @@ -1,7 +1,12 @@ +using System.Threading.Tasks; + namespace KeySwitchManager.UseCase.KeySwitches.Delete { public interface IDeleteUseCase { - public DeleteResponse Execute( DeleteRequest request ); + public DeleteResponse Execute( DeleteRequest request ) + => ExecuteAsync( request ).GetAwaiter().GetResult(); + + public Task ExecuteAsync( DeleteRequest request ); } -} \ No newline at end of file +} diff --git a/KeySwitchManager/Sources/Runtime/UseCases/KeySwitches/Dump/IDumpFileUseCase.cs b/KeySwitchManager/Sources/Runtime/UseCases/KeySwitches/Dump/IDumpFileUseCase.cs index ba871d4c..80740017 100644 --- a/KeySwitchManager/Sources/Runtime/UseCases/KeySwitches/Dump/IDumpFileUseCase.cs +++ b/KeySwitchManager/Sources/Runtime/UseCases/KeySwitches/Dump/IDumpFileUseCase.cs @@ -1,7 +1,12 @@ +using System.Threading.Tasks; + namespace KeySwitchManager.UseCase.KeySwitches.Dump { public interface IDumpFileUseCase { - public DumpFileResponse Execute( DumpFileRequest request ); + public DumpFileResponse Execute( DumpFileRequest request ) + => ExecuteAsync( request ).GetAwaiter().GetResult(); + + public Task ExecuteAsync( DumpFileRequest request ); } -} \ No newline at end of file +} diff --git a/KeySwitchManager/Sources/Runtime/UseCases/KeySwitches/Export/IExportFileUseCase.cs b/KeySwitchManager/Sources/Runtime/UseCases/KeySwitches/Export/IExportFileUseCase.cs index af857303..cdf8bdd8 100644 --- a/KeySwitchManager/Sources/Runtime/UseCases/KeySwitches/Export/IExportFileUseCase.cs +++ b/KeySwitchManager/Sources/Runtime/UseCases/KeySwitches/Export/IExportFileUseCase.cs @@ -1,9 +1,13 @@ using System; +using System.Threading.Tasks; namespace KeySwitchManager.UseCase.KeySwitches.Export { public interface IExportFileUseCase { - public ExportFileResponse Execute( ExportFileRequest request, IObserver? loggingSubject = null ); + public ExportFileResponse Execute( ExportFileRequest request, IObserver? loggingSubject = null ) + => ExecuteAsync( request, loggingSubject ).GetAwaiter().GetResult(); + + public Task ExecuteAsync( ExportFileRequest request, IObserver? loggingSubject ); } -} \ No newline at end of file +} diff --git a/KeySwitchManager/Sources/Runtime/UseCases/KeySwitches/Find/IFindUseCase.cs b/KeySwitchManager/Sources/Runtime/UseCases/KeySwitches/Find/IFindUseCase.cs index 9c873509..2d69d8ff 100644 --- a/KeySwitchManager/Sources/Runtime/UseCases/KeySwitches/Find/IFindUseCase.cs +++ b/KeySwitchManager/Sources/Runtime/UseCases/KeySwitches/Find/IFindUseCase.cs @@ -1,7 +1,12 @@ +using System.Threading.Tasks; + namespace KeySwitchManager.UseCase.KeySwitches.Find { public interface IFindUseCase { - public FindResponse Execute( FindRequest request ); + public FindResponse Execute( FindRequest request ) + => ExecuteAsync( request ).GetAwaiter().GetResult(); + + public Task ExecuteAsync( FindRequest request ); } -} \ No newline at end of file +} diff --git a/KeySwitchManager/Sources/Runtime/UseCases/KeySwitches/Import/IImportFileUseCase.cs b/KeySwitchManager/Sources/Runtime/UseCases/KeySwitches/Import/IImportFileUseCase.cs index afef1b02..782a8ddd 100644 --- a/KeySwitchManager/Sources/Runtime/UseCases/KeySwitches/Import/IImportFileUseCase.cs +++ b/KeySwitchManager/Sources/Runtime/UseCases/KeySwitches/Import/IImportFileUseCase.cs @@ -1,7 +1,12 @@ +using System.Threading.Tasks; + namespace KeySwitchManager.UseCase.KeySwitches.Import { public interface IImportFileUseCase { - public ImportFileResponse Execute( ImportFileRequest request ); + public ImportFileResponse Execute( ImportFileRequest request ) + => ExecuteAsync( request ).GetAwaiter().GetResult(); + + public Task ExecuteAsync( ImportFileRequest request ); } -} \ No newline at end of file +} From c5eb59b26d658edc1291722273209b55f36a1a3a Mon Sep 17 00:00:00 2001 From: "Hiroaki@R-koubou" Date: Sat, 21 Oct 2023 23:52:18 +0900 Subject: [PATCH 10/19] =?UTF-8?q?controller=E3=81=AE=E9=9D=9E=E5=90=8C?= =?UTF-8?q?=E6=9C=9F=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Core/Controllers/ControlExecutor.cs | 16 ++++++---------- .../Controllers/Create/CreateFileController.cs | 10 ++++++---- .../Core/Controllers/Delete/DeleteController.cs | 10 ++++++---- .../Core/Controllers/Dump/DumpFileController.cs | 10 ++++++---- .../Controllers/Export/ExportFileController.cs | 7 ++++--- .../Core/Controllers/Find/FindController.cs | 10 ++++++---- .../Applications/Core/Controllers/IController.cs | 6 +++++- .../Controllers/Import/ImportFileController.cs | 9 +++++---- 8 files changed, 44 insertions(+), 34 deletions(-) diff --git a/KeySwitchManager/Sources/Runtime/Applications/Core/Controllers/ControlExecutor.cs b/KeySwitchManager/Sources/Runtime/Applications/Core/Controllers/ControlExecutor.cs index 3a9a44b1..d694155b 100644 --- a/KeySwitchManager/Sources/Runtime/Applications/Core/Controllers/ControlExecutor.cs +++ b/KeySwitchManager/Sources/Runtime/Applications/Core/Controllers/ControlExecutor.cs @@ -8,11 +8,14 @@ namespace KeySwitchManager.Applications.Core.Controllers public static class ControlExecutor { public static void Execute( Func controllerFactory, ILogTextView logTextView ) + => ExecuteAsync( controllerFactory, logTextView ).GetAwaiter().GetResult(); + + public static async Task ExecuteAsync( Func controllerFactory, ILogTextView logTextView ) { try { using var controller = controllerFactory.Invoke(); - ExecuteImpl( controller, logTextView ); + await ExecuteImplAsync( controller, logTextView ); } catch( Exception exception ) { @@ -20,23 +23,16 @@ public static void Execute( Func controllerFactory, ILogTextView lo } } - private static void ExecuteImpl( IController controller, ILogTextView logTextView ) + private static async Task ExecuteImplAsync( IController controller, ILogTextView logTextView ) { try { - controller.Execute(); + await controller.ExecuteAsync(); } catch( Exception e ) { logTextView.Append( e.ToString() ); } } - - public static async Task ExecuteAsync( Func controllerFactory, ILogTextView logTextView ) - { - await Task.Run( () => { - Execute( controllerFactory, logTextView ); - } ); - } } } diff --git a/KeySwitchManager/Sources/Runtime/Applications/Core/Controllers/Create/CreateFileController.cs b/KeySwitchManager/Sources/Runtime/Applications/Core/Controllers/Create/CreateFileController.cs index 633c6477..a2985748 100644 --- a/KeySwitchManager/Sources/Runtime/Applications/Core/Controllers/Create/CreateFileController.cs +++ b/KeySwitchManager/Sources/Runtime/Applications/Core/Controllers/Create/CreateFileController.cs @@ -1,4 +1,6 @@ -using KeySwitchManager.Domain.KeySwitches.Models; +using System.Threading.Tasks; + +using KeySwitchManager.Domain.KeySwitches.Models; using KeySwitchManager.Interactors.KeySwitches; using KeySwitchManager.UseCase.KeySwitches.Create; @@ -27,10 +29,10 @@ public void Dispose() } } - public void Execute() + async Task IController.ExecuteAsync() { - var interactor = new CreateFileInteractor( Presenter ); - var response = interactor.Execute( new CreateFileRequest( Writer ) ); + ICreateFileUseCase interactor = new CreateFileInteractor( Presenter ); + var response = await interactor.ExecuteAsync( new CreateFileRequest( Writer ) ); Presenter.Complete( response ); } } diff --git a/KeySwitchManager/Sources/Runtime/Applications/Core/Controllers/Delete/DeleteController.cs b/KeySwitchManager/Sources/Runtime/Applications/Core/Controllers/Delete/DeleteController.cs index a184d406..5f7d2173 100644 --- a/KeySwitchManager/Sources/Runtime/Applications/Core/Controllers/Delete/DeleteController.cs +++ b/KeySwitchManager/Sources/Runtime/Applications/Core/Controllers/Delete/DeleteController.cs @@ -1,4 +1,6 @@ -using KeySwitchManager.Domain.KeySwitches.Models; +using System.Threading.Tasks; + +using KeySwitchManager.Domain.KeySwitches.Models; using KeySwitchManager.Interactors.KeySwitches; using KeySwitchManager.UseCase.KeySwitches.Delete; @@ -41,11 +43,11 @@ public void Dispose() } } - public void Execute() + async Task IController.ExecuteAsync() { - var interactor = new DeleteInteractor( DatabaseRepository, Presenter ); + IDeleteUseCase interactor = new DeleteInteractor( DatabaseRepository, Presenter ); var request = new DeleteRequest( DeveloperName, ProductName, InstrumentName ); - var response = interactor.Execute( request ); + var response = await interactor.ExecuteAsync( request ); if( response.RemovedCount > 0 ) { diff --git a/KeySwitchManager/Sources/Runtime/Applications/Core/Controllers/Dump/DumpFileController.cs b/KeySwitchManager/Sources/Runtime/Applications/Core/Controllers/Dump/DumpFileController.cs index 1f777f0c..4e5c5a5e 100644 --- a/KeySwitchManager/Sources/Runtime/Applications/Core/Controllers/Dump/DumpFileController.cs +++ b/KeySwitchManager/Sources/Runtime/Applications/Core/Controllers/Dump/DumpFileController.cs @@ -1,4 +1,6 @@ -using KeySwitchManager.Domain.KeySwitches.Models; +using System.Threading.Tasks; + +using KeySwitchManager.Domain.KeySwitches.Models; using KeySwitchManager.Interactors.KeySwitches; using KeySwitchManager.UseCase.KeySwitches.Dump; @@ -32,15 +34,15 @@ public void Dispose() } } - public void Execute() + async Task IController.ExecuteAsync() { - var interactor = new DumpFileInteractor( + IDumpFileUseCase interactor = new DumpFileInteractor( SourceRepository, Writer, Presenter ); - var response = interactor.Execute( new DumpFileRequest() ); + var response = await interactor.ExecuteAsync( new DumpFileRequest() ); Presenter.Complete( response ); } } diff --git a/KeySwitchManager/Sources/Runtime/Applications/Core/Controllers/Export/ExportFileController.cs b/KeySwitchManager/Sources/Runtime/Applications/Core/Controllers/Export/ExportFileController.cs index 78225178..aeb19d16 100644 --- a/KeySwitchManager/Sources/Runtime/Applications/Core/Controllers/Export/ExportFileController.cs +++ b/KeySwitchManager/Sources/Runtime/Applications/Core/Controllers/Export/ExportFileController.cs @@ -1,5 +1,6 @@ using System; using System.Reactive.Subjects; +using System.Threading.Tasks; using KeySwitchManager.Domain.KeySwitches.Models; using KeySwitchManager.Domain.KeySwitches.Models.Values; @@ -53,15 +54,15 @@ public void Dispose() } } - public void Execute() + async Task IController.ExecuteAsync() { - var interactor = new ExportFileInteractor( + IExportFileUseCase interactor = new ExportFileInteractor( SourceRepository, Writer, Presenter ); - var response = interactor.Execute( + var response = await interactor.ExecuteAsync( new ExportFileRequest( DeveloperName.Value, ProductName.Value, diff --git a/KeySwitchManager/Sources/Runtime/Applications/Core/Controllers/Find/FindController.cs b/KeySwitchManager/Sources/Runtime/Applications/Core/Controllers/Find/FindController.cs index fa83350a..80d7abba 100644 --- a/KeySwitchManager/Sources/Runtime/Applications/Core/Controllers/Find/FindController.cs +++ b/KeySwitchManager/Sources/Runtime/Applications/Core/Controllers/Find/FindController.cs @@ -1,4 +1,6 @@ -using KeySwitchManager.Domain.KeySwitches.Models; +using System.Threading.Tasks; + +using KeySwitchManager.Domain.KeySwitches.Models; using KeySwitchManager.Interactors.KeySwitches; using KeySwitchManager.UseCase.KeySwitches.Find; @@ -41,11 +43,11 @@ public void Dispose() } } - public void Execute() + async Task IController.ExecuteAsync() { - var interactor = new FindInteractor( DatabaseRepository, Presenter ); + IFindUseCase interactor = new FindInteractor( DatabaseRepository, Presenter ); var request = new FindRequest( DeveloperName, ProductName, InstrumentName ); - var response = interactor.Execute( request ); + var response = await interactor.ExecuteAsync( request ); Presenter.Complete( response ); } diff --git a/KeySwitchManager/Sources/Runtime/Applications/Core/Controllers/IController.cs b/KeySwitchManager/Sources/Runtime/Applications/Core/Controllers/IController.cs index 5f7543d3..ae7cb84a 100644 --- a/KeySwitchManager/Sources/Runtime/Applications/Core/Controllers/IController.cs +++ b/KeySwitchManager/Sources/Runtime/Applications/Core/Controllers/IController.cs @@ -1,9 +1,13 @@ using System; +using System.Threading.Tasks; namespace KeySwitchManager.Applications.Core.Controllers { public interface IController : IDisposable { - void Execute(); + void Execute() + => ExecuteAsync().GetAwaiter().GetResult(); + + Task ExecuteAsync(); } } diff --git a/KeySwitchManager/Sources/Runtime/Applications/Core/Controllers/Import/ImportFileController.cs b/KeySwitchManager/Sources/Runtime/Applications/Core/Controllers/Import/ImportFileController.cs index 5b6df1a5..488970b1 100644 --- a/KeySwitchManager/Sources/Runtime/Applications/Core/Controllers/Import/ImportFileController.cs +++ b/KeySwitchManager/Sources/Runtime/Applications/Core/Controllers/Import/ImportFileController.cs @@ -1,4 +1,5 @@ using System; +using System.Threading.Tasks; using KeySwitchManager.Domain.KeySwitches.Models; using KeySwitchManager.Interactors.KeySwitches; @@ -49,13 +50,13 @@ public void Dispose() } } - public void Execute() + async Task IController.ExecuteAsync() { var keySwitches = KeySwitchReader.Read(); - var interactor = new ImportFileInteractor( DatabaseRepository, Presenter ); + IImportFileUseCase interactor = new ImportFileInteractor( DatabaseRepository, Presenter ); var request = new ImportFileRequest( keySwitches ); - var response = interactor.Execute( request ); - DatabaseRepository.Flush(); + var response = await interactor.ExecuteAsync( request ); + await DatabaseRepository.FlushAsync(); Presenter.Complete( response ); } From 6803a57d17e4294007122287c3351aaadcf06fa4 Mon Sep 17 00:00:00 2001 From: "Hiroaki@R-koubou" Date: Sat, 21 Oct 2023 23:55:22 +0900 Subject: [PATCH 11/19] =?UTF-8?q?=E4=BF=AE=E9=A3=BE=E5=AD=90=E3=81=AE?= =?UTF-8?q?=E8=A8=98=E8=BF=B0=E9=A0=86=E3=81=AE=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Storage/KeySwitches/Helper/CombinedWritingHelper.cs | 2 +- .../Storage/KeySwitches/Helper/MultipleWritingHelper.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/KeySwitchManager/Sources/Runtime/Infrastructures/Storage/KeySwitches/Helper/CombinedWritingHelper.cs b/KeySwitchManager/Sources/Runtime/Infrastructures/Storage/KeySwitches/Helper/CombinedWritingHelper.cs index b8f14cf1..496d88fd 100644 --- a/KeySwitchManager/Sources/Runtime/Infrastructures/Storage/KeySwitches/Helper/CombinedWritingHelper.cs +++ b/KeySwitchManager/Sources/Runtime/Infrastructures/Storage/KeySwitches/Helper/CombinedWritingHelper.cs @@ -13,7 +13,7 @@ public static class CombinedWritingHelper public static void Write( IReadOnlyCollection keySwitches, DirectoryPath outputDirectory, KeySwitch prefix, string suffix, IObserver? loggingSubject, Func writerFactory ) => WriteAsync( keySwitches, outputDirectory, prefix, suffix, loggingSubject, writerFactory ).GetAwaiter().GetResult(); - public async static Task WriteAsync( IReadOnlyCollection keySwitches, DirectoryPath outputDirectory, KeySwitch prefix, string suffix, IObserver? loggingSubject, Func writerFactory ) + public static async Task WriteAsync( IReadOnlyCollection keySwitches, DirectoryPath outputDirectory, KeySwitch prefix, string suffix, IObserver? loggingSubject, Func writerFactory ) { var filePath = CreatePathHelper.CreateFilePath( prefix.DeveloperName, prefix.ProductName, string.Empty, suffix, outputDirectory ); diff --git a/KeySwitchManager/Sources/Runtime/Infrastructures/Storage/KeySwitches/Helper/MultipleWritingHelper.cs b/KeySwitchManager/Sources/Runtime/Infrastructures/Storage/KeySwitches/Helper/MultipleWritingHelper.cs index fe125b37..95659e1e 100644 --- a/KeySwitchManager/Sources/Runtime/Infrastructures/Storage/KeySwitches/Helper/MultipleWritingHelper.cs +++ b/KeySwitchManager/Sources/Runtime/Infrastructures/Storage/KeySwitches/Helper/MultipleWritingHelper.cs @@ -13,7 +13,7 @@ public static class MultipleWritingHelper public static void Write( IReadOnlyCollection keySwitches, DirectoryPath outputDirectory, string suffix, IObserver? loggingSubject, Func writerFactory ) => WriteAsync( keySwitches, outputDirectory, suffix, loggingSubject, writerFactory ).GetAwaiter().GetResult(); - public async static Task WriteAsync( IReadOnlyCollection keySwitches, DirectoryPath outputDirectory, string suffix, IObserver? loggingSubject, Func writerFactory ) + public static async Task WriteAsync( IReadOnlyCollection keySwitches, DirectoryPath outputDirectory, string suffix, IObserver? loggingSubject, Func writerFactory ) { foreach( var x in keySwitches ) { @@ -32,7 +32,7 @@ public async static Task WriteAsync( IReadOnlyCollection keySwitches, public static void Write( IReadOnlyCollection keySwitches, DirectoryPath outputDirectory, string suffix, IObserver? logging, Func?, Task> write ) => WriteAsync( keySwitches, outputDirectory, suffix, logging, write ).GetAwaiter().GetResult(); - public async static Task WriteAsync( IReadOnlyCollection keySwitches, DirectoryPath outputDirectory, string suffix, IObserver? logging, Func?, Task> write ) + public static async Task WriteAsync( IReadOnlyCollection keySwitches, DirectoryPath outputDirectory, string suffix, IObserver? logging, Func?, Task> write ) { foreach( var x in keySwitches ) { From 0ac5c11aa456c89f58336b18255ca329d7c92016 Mon Sep 17 00:00:00 2001 From: "Hiroaki@R-Koubou" Date: Sun, 22 Oct 2023 18:16:32 +0900 Subject: [PATCH 12/19] =?UTF-8?q?=E9=87=8D=E8=A4=87=E3=81=99=E3=82=8B?= =?UTF-8?q?=E5=8F=82=E7=85=A7=E3=81=AE=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 上位の Applications.Core.csproj で参照済み --- .../Sources/Runtime/Applications/WPF/Applications.WPF.csproj | 1 - 1 file changed, 1 deletion(-) diff --git a/KeySwitchManager/Sources/Runtime/Applications/WPF/Applications.WPF.csproj b/KeySwitchManager/Sources/Runtime/Applications/WPF/Applications.WPF.csproj index 8b874445..4ca19971 100644 --- a/KeySwitchManager/Sources/Runtime/Applications/WPF/Applications.WPF.csproj +++ b/KeySwitchManager/Sources/Runtime/Applications/WPF/Applications.WPF.csproj @@ -21,7 +21,6 @@ - From b5f91d34a3d111206f941efe53c99c5c2e463fe0 Mon Sep 17 00:00:00 2001 From: "Hiroaki@R-Koubou" Date: Sun, 22 Oct 2023 18:17:29 +0900 Subject: [PATCH 13/19] =?UTF-8?q?WPF=E3=82=A2=E3=83=97=E3=83=AA=E3=82=B1?= =?UTF-8?q?=E3=83=BC=E3=82=B7=E3=83=A7=E3=83=B3=20-=20=E3=83=90=E3=83=83?= =?UTF-8?q?=E3=82=AF=E3=82=B0=E3=83=A9=E3=82=A6=E3=83=B3=E3=83=89=E3=82=B9?= =?UTF-8?q?=E3=83=AC=E3=83=83=E3=83=89=E3=82=92=E4=BD=9C=E6=88=90=E3=81=9B?= =?UTF-8?q?=E3=81=9A=E3=81=AB=E5=AE=9F=E8=A1=8C=E3=81=97=E3=81=A6=E3=81=84?= =?UTF-8?q?=E3=81=9F=E3=81=AE=E3=81=A7=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 処理中にUIスレッドが固まっていた原因 --- .../Sources/Runtime/Applications/WPF/Applications.WPF.csproj | 2 +- .../Runtime/Applications/WPF/Sources/MainWindow.xaml.cs | 2 +- KeySwitchManager/Sources/Runtime/Applications/WPF/VERSION.md | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/KeySwitchManager/Sources/Runtime/Applications/WPF/Applications.WPF.csproj b/KeySwitchManager/Sources/Runtime/Applications/WPF/Applications.WPF.csproj index 4ca19971..3d609c94 100644 --- a/KeySwitchManager/Sources/Runtime/Applications/WPF/Applications.WPF.csproj +++ b/KeySwitchManager/Sources/Runtime/Applications/WPF/Applications.WPF.csproj @@ -7,7 +7,7 @@ KeySwitchManager KeySwitchManager WPF Application KeySwitchManager WPF Application - 0.5.2 + 0.5.3 enable diff --git a/KeySwitchManager/Sources/Runtime/Applications/WPF/Sources/MainWindow.xaml.cs b/KeySwitchManager/Sources/Runtime/Applications/WPF/Sources/MainWindow.xaml.cs index a27df337..cc7179fd 100644 --- a/KeySwitchManager/Sources/Runtime/Applications/WPF/Sources/MainWindow.xaml.cs +++ b/KeySwitchManager/Sources/Runtime/Applications/WPF/Sources/MainWindow.xaml.cs @@ -79,7 +79,7 @@ private void PostExecuteController() private async Task ExecuteControllerAsync( Func controllerFactory ) { PreExecuteController(); - await ControlExecutor.ExecuteAsync( controllerFactory, LogTextView ); + await Task.Run( async () => await ControlExecutor.ExecuteAsync( controllerFactory, LogTextView ) ); PostExecuteController(); } #endregion diff --git a/KeySwitchManager/Sources/Runtime/Applications/WPF/VERSION.md b/KeySwitchManager/Sources/Runtime/Applications/WPF/VERSION.md index 080b450f..e80e7f0b 100644 --- a/KeySwitchManager/Sources/Runtime/Applications/WPF/VERSION.md +++ b/KeySwitchManager/Sources/Runtime/Applications/WPF/VERSION.md @@ -3,8 +3,8 @@ KeySwitchManager WPF Application ## Assembly Version -0.5.2.0 +0.5.3.0 ## Build At -2023-06-24 01:18:53 +09:00 +2023-10-22 18:18:14 +09:00 From b463be2ff57f5803ad7612fd6cd1061ac43ff3ee Mon Sep 17 00:00:00 2001 From: "Hiroaki@R-Koubou" Date: Sun, 22 Oct 2023 18:32:30 +0900 Subject: [PATCH 14/19] =?UTF-8?q?WPF=E3=82=A2=E3=83=97=E3=83=AA=E3=82=B1?= =?UTF-8?q?=E3=83=BC=E3=82=B7=E3=83=A7=E3=83=B3=20-=20=E5=90=8D=E5=89=8D?= =?UTF-8?q?=E7=A9=BA=E9=96=93=E3=81=AE=E4=BF=AE=E6=AD=A3=E6=BC=8F=E3=82=8C?= =?UTF-8?q?=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Runtime/Applications/WPF/Applications.WPF.csproj | 1 + .../Sources/Runtime/Applications/WPF/Sources/App.xaml | 2 +- .../Sources/Runtime/Applications/WPF/Sources/App.xaml.cs | 2 +- .../Runtime/Applications/WPF/Sources/ApplicationConfig.cs | 2 +- .../Runtime/Applications/WPF/Sources/MainWindow.xaml | 2 +- .../Runtime/Applications/WPF/Sources/MainWindow.xaml.cs | 6 ++---- .../Runtime/Applications/WPF/Sources/WpfView/LogTextView.cs | 2 +- .../Sources/Runtime/Applications/WPF/VERSION.md | 2 +- 8 files changed, 9 insertions(+), 10 deletions(-) diff --git a/KeySwitchManager/Sources/Runtime/Applications/WPF/Applications.WPF.csproj b/KeySwitchManager/Sources/Runtime/Applications/WPF/Applications.WPF.csproj index 3d609c94..4829654d 100644 --- a/KeySwitchManager/Sources/Runtime/Applications/WPF/Applications.WPF.csproj +++ b/KeySwitchManager/Sources/Runtime/Applications/WPF/Applications.WPF.csproj @@ -5,6 +5,7 @@ net7.0-windows true KeySwitchManager + KeySwitchManager.Applications.WPF KeySwitchManager WPF Application KeySwitchManager WPF Application 0.5.3 diff --git a/KeySwitchManager/Sources/Runtime/Applications/WPF/Sources/App.xaml b/KeySwitchManager/Sources/Runtime/Applications/WPF/Sources/App.xaml index 1da800c6..ccbbdd33 100644 --- a/KeySwitchManager/Sources/Runtime/Applications/WPF/Sources/App.xaml +++ b/KeySwitchManager/Sources/Runtime/Applications/WPF/Sources/App.xaml @@ -1,4 +1,4 @@ - diff --git a/KeySwitchManager/Sources/Runtime/Applications/WPF/Sources/App.xaml.cs b/KeySwitchManager/Sources/Runtime/Applications/WPF/Sources/App.xaml.cs index 3d62ccd1..1d4aa681 100644 --- a/KeySwitchManager/Sources/Runtime/Applications/WPF/Sources/App.xaml.cs +++ b/KeySwitchManager/Sources/Runtime/Applications/WPF/Sources/App.xaml.cs @@ -1,4 +1,4 @@ -namespace KeySwitchManager.WPF +namespace KeySwitchManager.Applications.WPF { /// /// Interaction logic for App.xaml diff --git a/KeySwitchManager/Sources/Runtime/Applications/WPF/Sources/ApplicationConfig.cs b/KeySwitchManager/Sources/Runtime/Applications/WPF/Sources/ApplicationConfig.cs index ccf6532d..a39ad8f1 100644 --- a/KeySwitchManager/Sources/Runtime/Applications/WPF/Sources/ApplicationConfig.cs +++ b/KeySwitchManager/Sources/Runtime/Applications/WPF/Sources/ApplicationConfig.cs @@ -6,7 +6,7 @@ using YamlDotNet.Serialization; -namespace KeySwitchManager.WPF +namespace KeySwitchManager.Applications.WPF { public class ApplicationConfigModel { diff --git a/KeySwitchManager/Sources/Runtime/Applications/WPF/Sources/MainWindow.xaml b/KeySwitchManager/Sources/Runtime/Applications/WPF/Sources/MainWindow.xaml index 8d260563..5f1e8b56 100644 --- a/KeySwitchManager/Sources/Runtime/Applications/WPF/Sources/MainWindow.xaml +++ b/KeySwitchManager/Sources/Runtime/Applications/WPF/Sources/MainWindow.xaml @@ -1,4 +1,4 @@ - /// Interaction logic for MainWindow.xaml diff --git a/KeySwitchManager/Sources/Runtime/Applications/WPF/Sources/WpfView/LogTextView.cs b/KeySwitchManager/Sources/Runtime/Applications/WPF/Sources/WpfView/LogTextView.cs index 3b7d4a99..8972c0e0 100644 --- a/KeySwitchManager/Sources/Runtime/Applications/WPF/Sources/WpfView/LogTextView.cs +++ b/KeySwitchManager/Sources/Runtime/Applications/WPF/Sources/WpfView/LogTextView.cs @@ -4,7 +4,7 @@ using KeySwitchManager.Applications.Core.Views.LogView; -namespace KeySwitchManager.WPF.WpfView +namespace KeySwitchManager.Applications.WPF.WpfView { public class LogTextView : ILogTextView { diff --git a/KeySwitchManager/Sources/Runtime/Applications/WPF/VERSION.md b/KeySwitchManager/Sources/Runtime/Applications/WPF/VERSION.md index e80e7f0b..655f1885 100644 --- a/KeySwitchManager/Sources/Runtime/Applications/WPF/VERSION.md +++ b/KeySwitchManager/Sources/Runtime/Applications/WPF/VERSION.md @@ -7,4 +7,4 @@ KeySwitchManager WPF Application ## Build At -2023-10-22 18:18:14 +09:00 +2023-10-22 18:31:13 +09:00 From f0fb78b69b974a3c7b754645a7b6e12d1d0cf1dd Mon Sep 17 00:00:00 2001 From: "Hiroaki@R-Koubou" Date: Sun, 22 Oct 2023 18:33:23 +0900 Subject: [PATCH 15/19] =?UTF-8?q?WPF=E3=82=A2=E3=83=97=E3=83=AA=E3=82=B1?= =?UTF-8?q?=E3=83=BC=E3=82=B7=E3=83=A7=E3=83=B3=20-=20=E3=82=BF=E3=82=A4?= =?UTF-8?q?=E3=83=88=E3=83=AB=E3=83=90=E3=83=BC=E3=81=AB=E3=83=90=E3=83=BC?= =?UTF-8?q?=E3=82=B8=E3=83=A7=E3=83=B3=E6=83=85=E5=A0=B1=E3=82=92=E8=A1=A8?= =?UTF-8?q?=E7=A4=BA=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E5=AF=BE?= =?UTF-8?q?=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Applications/WPF/Sources/MainWindow.xaml.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/KeySwitchManager/Sources/Runtime/Applications/WPF/Sources/MainWindow.xaml.cs b/KeySwitchManager/Sources/Runtime/Applications/WPF/Sources/MainWindow.xaml.cs index b2f6a5e7..caa63305 100644 --- a/KeySwitchManager/Sources/Runtime/Applications/WPF/Sources/MainWindow.xaml.cs +++ b/KeySwitchManager/Sources/Runtime/Applications/WPF/Sources/MainWindow.xaml.cs @@ -49,9 +49,21 @@ public MainWindow() private void InitializeCustomComponent() { ExportFormatCombobox.ItemsSource = ExportSupportedFormatList; + InitializeWindowTitle(); LoadApplicationConfig(); } + private void InitializeWindowTitle() + { + var version = typeof( MainWindow ).Assembly.GetName().Version; + + if( version != null ) + { + Title = $"{Title} (Version {version.ToString( 3 )})"; + } + + } + #region Executions private void PreExecuteController() { From 798252f8dab0cf12b7d5e12852ff98570ae38f76 Mon Sep 17 00:00:00 2001 From: "Hiroaki@R-Koubou" Date: Sun, 22 Oct 2023 18:52:56 +0900 Subject: [PATCH 16/19] =?UTF-8?q?WPF=E3=82=A2=E3=83=97=E3=83=AA=E3=82=B1?= =?UTF-8?q?=E3=83=BC=E3=82=B7=E3=83=A7=E3=83=B3=20-=20=E3=82=B3=E3=83=BC?= =?UTF-8?q?=E3=83=89=E3=82=B9=E3=82=BF=E3=82=A4=E3=83=AB=E8=AA=BF=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Runtime/Applications/WPF/Sources/MainWindow.xaml.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/KeySwitchManager/Sources/Runtime/Applications/WPF/Sources/MainWindow.xaml.cs b/KeySwitchManager/Sources/Runtime/Applications/WPF/Sources/MainWindow.xaml.cs index caa63305..3dc8fc9f 100644 --- a/KeySwitchManager/Sources/Runtime/Applications/WPF/Sources/MainWindow.xaml.cs +++ b/KeySwitchManager/Sources/Runtime/Applications/WPF/Sources/MainWindow.xaml.cs @@ -89,7 +89,12 @@ private void PostExecuteController() private async Task ExecuteControllerAsync( Func controllerFactory ) { PreExecuteController(); - await Task.Run( async () => await ControlExecutor.ExecuteAsync( controllerFactory, LogTextView ) ); + + await Task.Run( async () => { + await ControlExecutor.ExecuteAsync( controllerFactory, LogTextView ); + } + ); + PostExecuteController(); } #endregion From 442d31c4130eecf75d2e93d540d059336a20b46c Mon Sep 17 00:00:00 2001 From: "Hiroaki@R-Koubou" Date: Sun, 22 Oct 2023 22:46:50 +0900 Subject: [PATCH 17/19] =?UTF-8?q?Obsolete=E3=82=92=E3=81=A4=E3=81=91?= =?UTF-8?q?=E3=81=A6=E5=89=8A=E9=99=A4=E4=BA=88=E5=AE=9A=E3=81=A0=E3=81=A3?= =?UTF-8?q?=E3=81=9F=E3=82=AF=E3=83=A9=E3=82=B9=EF=BC=88LiteDB=EF=BC=89?= =?UTF-8?q?=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- KeySwitchManager/KeySwitchManager.sln | 14 - .../Applications/CLI/Sources/Commands/New.cs | 2 +- .../Core/Applications.Core.csproj | 1 - .../Create/CreateControllerFactory.cs | 6 - .../Helpers/KeySwitchRepositoryFactory.cs | 6 - .../WPF/Sources/MainWindow.xaml.cs | 4 +- .../Xamarin.Mac/Sources/ViewController.cs | 15 +- .../Database.LiteDB/Database.LiteDB.csproj | 24 -- .../KeySwitches/LiteDbFileWriter.cs | 37 --- .../KeySwitches/LiteDbRepository.cs | 276 ------------------ .../KeySwitches/Models/ArticulationModel.cs | 30 -- .../KeySwitches/Models/KeySwitchModel.cs | 52 ---- .../KeySwitches/Models/MidiMessageModel.cs | 23 -- .../Translators/KeySwitchExportTranslator.cs | 82 ------ .../Translators/KeySwitchImportTranslator.cs | 86 ------ .../Database.LiteDB/Database.LiteDB.csproj | 22 -- .../KeySwitches/LiteDbDeleteTest.cs | 86 ------ .../KeySwitches/LiteDbInsertTest.cs | 54 ---- NOTICE.md | 30 -- 19 files changed, 13 insertions(+), 837 deletions(-) delete mode 100644 KeySwitchManager/Sources/Runtime/Infrastructures/Database.LiteDB/Database.LiteDB.csproj delete mode 100644 KeySwitchManager/Sources/Runtime/Infrastructures/Database.LiteDB/KeySwitches/LiteDbFileWriter.cs delete mode 100644 KeySwitchManager/Sources/Runtime/Infrastructures/Database.LiteDB/KeySwitches/LiteDbRepository.cs delete mode 100644 KeySwitchManager/Sources/Runtime/Infrastructures/Database.LiteDB/KeySwitches/Models/ArticulationModel.cs delete mode 100644 KeySwitchManager/Sources/Runtime/Infrastructures/Database.LiteDB/KeySwitches/Models/KeySwitchModel.cs delete mode 100644 KeySwitchManager/Sources/Runtime/Infrastructures/Database.LiteDB/KeySwitches/Models/MidiMessageModel.cs delete mode 100644 KeySwitchManager/Sources/Runtime/Infrastructures/Database.LiteDB/KeySwitches/Translators/KeySwitchExportTranslator.cs delete mode 100644 KeySwitchManager/Sources/Runtime/Infrastructures/Database.LiteDB/KeySwitches/Translators/KeySwitchImportTranslator.cs delete mode 100644 KeySwitchManager/Sources/Tests/Infrastructures/Database.LiteDB/Database.LiteDB.csproj delete mode 100644 KeySwitchManager/Sources/Tests/Infrastructures/Database.LiteDB/KeySwitches/LiteDbDeleteTest.cs delete mode 100644 KeySwitchManager/Sources/Tests/Infrastructures/Database.LiteDB/KeySwitches/LiteDbInsertTest.cs diff --git a/KeySwitchManager/KeySwitchManager.sln b/KeySwitchManager/KeySwitchManager.sln index b535c524..cd292b61 100644 --- a/KeySwitchManager/KeySwitchManager.sln +++ b/KeySwitchManager/KeySwitchManager.sln @@ -14,8 +14,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Interactors", "Sources\Runt EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Infrastructures", "Infrastructures", "{505E86DD-3A59-4038-B109-22B3678D035E}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Database.LiteDB", "Sources\Runtime\Infrastructures\Database.LiteDB\Database.LiteDB.csproj", "{20749A6A-AD52-4545-B6B2-A921EC8CF850}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Storage.Json", "Sources\Runtime\Infrastructures\Storage.Json\Storage.Json.csproj", "{EAE5D07E-8455-4C33-BCD1-07EFF958E21B}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Storage.Xml", "Sources\Runtime\Infrastructures\Storage.Xml\Storage.Xml.csproj", "{499CCE1B-A7D9-4EFA-B890-8785C137EF72}" @@ -32,8 +30,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Domain", "Sources\Tests\Dom EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Infrastructures", "Infrastructures", "{B1FC3859-B078-471F-81F2-FBB0A25C974B}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Database.LiteDB", "Sources\Tests\Infrastructures\Database.LiteDB\Database.LiteDB.csproj", "{87930720-147C-4DD4-89C8-F022A65BE461}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Storage.Xml", "Sources\Tests\Infrastructures\Storage.Xml\Storage.Xml.csproj", "{20F51031-CED4-48E2-BBC2-99239D4C3A68}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Storage.Yaml", "Sources\Runtime\Infrastructures\Storage.Yaml\Storage.Yaml.csproj", "{17FB1646-6A55-422B-AB7C-9AEB25126D03}" @@ -74,10 +70,6 @@ Global {8CAA9A5D-B054-42F7-8589-300866F8223A}.Debug|Any CPU.Build.0 = Debug|Any CPU {8CAA9A5D-B054-42F7-8589-300866F8223A}.Release|Any CPU.ActiveCfg = Release|Any CPU {8CAA9A5D-B054-42F7-8589-300866F8223A}.Release|Any CPU.Build.0 = Release|Any CPU - {20749A6A-AD52-4545-B6B2-A921EC8CF850}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {20749A6A-AD52-4545-B6B2-A921EC8CF850}.Debug|Any CPU.Build.0 = Debug|Any CPU - {20749A6A-AD52-4545-B6B2-A921EC8CF850}.Release|Any CPU.ActiveCfg = Release|Any CPU - {20749A6A-AD52-4545-B6B2-A921EC8CF850}.Release|Any CPU.Build.0 = Release|Any CPU {EAE5D07E-8455-4C33-BCD1-07EFF958E21B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {EAE5D07E-8455-4C33-BCD1-07EFF958E21B}.Debug|Any CPU.Build.0 = Debug|Any CPU {EAE5D07E-8455-4C33-BCD1-07EFF958E21B}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -106,10 +98,6 @@ Global {D023CB3F-71C6-4925-9651-5FBA3BEF4404}.Debug|Any CPU.Build.0 = Debug|Any CPU {D023CB3F-71C6-4925-9651-5FBA3BEF4404}.Release|Any CPU.ActiveCfg = Release|Any CPU {D023CB3F-71C6-4925-9651-5FBA3BEF4404}.Release|Any CPU.Build.0 = Release|Any CPU - {87930720-147C-4DD4-89C8-F022A65BE461}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {87930720-147C-4DD4-89C8-F022A65BE461}.Debug|Any CPU.Build.0 = Debug|Any CPU - {87930720-147C-4DD4-89C8-F022A65BE461}.Release|Any CPU.ActiveCfg = Release|Any CPU - {87930720-147C-4DD4-89C8-F022A65BE461}.Release|Any CPU.Build.0 = Release|Any CPU {20F51031-CED4-48E2-BBC2-99239D4C3A68}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {20F51031-CED4-48E2-BBC2-99239D4C3A68}.Debug|Any CPU.Build.0 = Debug|Any CPU {20F51031-CED4-48E2-BBC2-99239D4C3A68}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -136,14 +124,12 @@ Global {D35DCF05-CE3B-4258-AF17-5D73C2A9EE86}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(NestedProjects) = preSolution - {20749A6A-AD52-4545-B6B2-A921EC8CF850} = {505E86DD-3A59-4038-B109-22B3678D035E} {EAE5D07E-8455-4C33-BCD1-07EFF958E21B} = {505E86DD-3A59-4038-B109-22B3678D035E} {499CCE1B-A7D9-4EFA-B890-8785C137EF72} = {505E86DD-3A59-4038-B109-22B3678D035E} {1747E137-ABC6-4DE6-BE33-9C6B6335266F} = {505E86DD-3A59-4038-B109-22B3678D035E} {62BED324-A809-4740-BB44-7D0ADC88B8E3} = {505E86DD-3A59-4038-B109-22B3678D035E} {BA5C1A39-004B-45EC-8FB6-59DB7F80A305} = {505E86DD-3A59-4038-B109-22B3678D035E} {01822D19-80DD-4979-BA62-FE10E4ACE5CA} = {DF635B48-6000-45EF-AA41-01E06BA4A254} - {87930720-147C-4DD4-89C8-F022A65BE461} = {B1FC3859-B078-471F-81F2-FBB0A25C974B} {20F51031-CED4-48E2-BBC2-99239D4C3A68} = {B1FC3859-B078-471F-81F2-FBB0A25C974B} {17FB1646-6A55-422B-AB7C-9AEB25126D03} = {505E86DD-3A59-4038-B109-22B3678D035E} {A2D9D05E-00A1-456D-93DF-40CB784BB74A} = {B1FC3859-B078-471F-81F2-FBB0A25C974B} diff --git a/KeySwitchManager/Sources/Runtime/Applications/CLI/Sources/Commands/New.cs b/KeySwitchManager/Sources/Runtime/Applications/CLI/Sources/Commands/New.cs index 583d7ad9..ebbacf55 100644 --- a/KeySwitchManager/Sources/Runtime/Applications/CLI/Sources/Commands/New.cs +++ b/KeySwitchManager/Sources/Runtime/Applications/CLI/Sources/Commands/New.cs @@ -9,7 +9,7 @@ public class New : ICommand [Verb( "new", HelpText = "export a template file" )] public class CommandOption : ICommandOption { - [Value( index: 0, MetaName = "output", HelpText = "Output path for template file (*.yaml or *.xlsx or *.db)", Default = "(ProductName).yaml" )] + [Value( index: 0, MetaName = "output", HelpText = "Output path for template file (*.yaml or *.xlsx)", Default = "(ProductName).yaml" )] public string OutputPath { get; set; } = string.Empty; } diff --git a/KeySwitchManager/Sources/Runtime/Applications/Core/Applications.Core.csproj b/KeySwitchManager/Sources/Runtime/Applications/Core/Applications.Core.csproj index baf97ff1..9c453f29 100644 --- a/KeySwitchManager/Sources/Runtime/Applications/Core/Applications.Core.csproj +++ b/KeySwitchManager/Sources/Runtime/Applications/Core/Applications.Core.csproj @@ -14,7 +14,6 @@ - diff --git a/KeySwitchManager/Sources/Runtime/Applications/Core/Controllers/Create/CreateControllerFactory.cs b/KeySwitchManager/Sources/Runtime/Applications/Core/Controllers/Create/CreateControllerFactory.cs index f853328f..c5be9074 100644 --- a/KeySwitchManager/Sources/Runtime/Applications/Core/Controllers/Create/CreateControllerFactory.cs +++ b/KeySwitchManager/Sources/Runtime/Applications/Core/Controllers/Create/CreateControllerFactory.cs @@ -4,7 +4,6 @@ using KeySwitchManager.Applications.Core.Views.LogView; using KeySwitchManager.Commons.Data; using KeySwitchManager.Domain.KeySwitches.Models; -using KeySwitchManager.Infrastructures.Database.LiteDB.KeySwitches; using KeySwitchManager.Infrastructures.Storage.Spreadsheet.ClosedXml.KeySwitches; using KeySwitchManager.Infrastructures.Storage.Yaml.KeySwitches; @@ -26,11 +25,6 @@ public static IController Create( string outputFilePath, ILogTextView logTextVie return CreateImpl( outputFilePath, logTextView, ( stream ) => new YamlKeySwitchWriter( stream ) ); } - if( path.EndsWith( ".db" ) ) - { - return CreateImpl( logTextView, new LiteDbFileWriter( new FilePath( outputFilePath ) ) ); - } - throw new ArgumentException( $"{outputFilePath} is unknown file format" ); } diff --git a/KeySwitchManager/Sources/Runtime/Applications/Core/Helpers/KeySwitchRepositoryFactory.cs b/KeySwitchManager/Sources/Runtime/Applications/Core/Helpers/KeySwitchRepositoryFactory.cs index 0324fa34..6414b5a3 100644 --- a/KeySwitchManager/Sources/Runtime/Applications/Core/Helpers/KeySwitchRepositoryFactory.cs +++ b/KeySwitchManager/Sources/Runtime/Applications/Core/Helpers/KeySwitchRepositoryFactory.cs @@ -2,7 +2,6 @@ using KeySwitchManager.Commons.Data; using KeySwitchManager.Domain.KeySwitches.Models; -using KeySwitchManager.Infrastructures.Database.LiteDB.KeySwitches; using KeySwitchManager.Infrastructures.Storage.Yaml.KeySwitches; namespace KeySwitchManager.Applications.Core.Helpers @@ -13,11 +12,6 @@ public static IKeySwitchRepository CreateFileRepository(string filePath) { var path = filePath.ToLower(); - if( path.EndsWith( ".db" ) ) - { - return new LiteDbRepository( new FilePath( filePath ) ); - } - if( path.EndsWith( ".yaml" ) || path.EndsWith( ".yml" ) ) { return new YamlRepository( new FilePath( filePath ) ); diff --git a/KeySwitchManager/Sources/Runtime/Applications/WPF/Sources/MainWindow.xaml.cs b/KeySwitchManager/Sources/Runtime/Applications/WPF/Sources/MainWindow.xaml.cs index 3dc8fc9f..cae5dab7 100644 --- a/KeySwitchManager/Sources/Runtime/Applications/WPF/Sources/MainWindow.xaml.cs +++ b/KeySwitchManager/Sources/Runtime/Applications/WPF/Sources/MainWindow.xaml.cs @@ -27,8 +27,8 @@ namespace KeySwitchManager.Applications.WPF public partial class MainWindow { private const string KeySwitchDefinitionFileFilter = "KeySwitch definition File|*.xlsx;*.yaml;*.yml"; - private const string KeySwitchDatabaseFileFilter = "KeySwitch Database File|*.yaml;*.yml;*.db"; - private const string KeySwitchAllFileFilter = "Supported File|*.xlsx;*.yaml;*.yml;*.db"; + private const string KeySwitchDatabaseFileFilter = "KeySwitch Database File|*.yaml;*.yml"; + private const string KeySwitchAllFileFilter = "Supported File|*.xlsx;*.yaml;*.yml"; #region UI Binding #endregion diff --git a/KeySwitchManager/Sources/Runtime/Applications/Xamarin.Mac/Sources/ViewController.cs b/KeySwitchManager/Sources/Runtime/Applications/Xamarin.Mac/Sources/ViewController.cs index 7dc5365c..fd473a1e 100644 --- a/KeySwitchManager/Sources/Runtime/Applications/Xamarin.Mac/Sources/ViewController.cs +++ b/KeySwitchManager/Sources/Runtime/Applications/Xamarin.Mac/Sources/ViewController.cs @@ -92,7 +92,12 @@ private void PostExecuteController() private async Task ExecuteControllerAsync( Func controllerFactory ) { PreExecuteController(); - await ControlExecutor.ExecuteAsync( controllerFactory, LogView ); + + await Task.Run( async () => { + await ControlExecutor.ExecuteAsync( controllerFactory, LogView ); + } + ); + PostExecuteController(); } #endregion @@ -108,7 +113,7 @@ partial void OnCreateDefinitionFileChooserButtonClicked( NSObject sender ) { ChooseSaveFilePath( ( path ) => { NewFileText.StringValue = path; - }, "db", "yaml", "xlsx" ); + }, "yaml", "yml", "xlsx" ); } async partial void OnOpenNewFileButtonClicked( NSObject sender ) @@ -130,14 +135,14 @@ partial void OnOpenDatabaseFileChooserButtonClicked( NSObject sender ) { ChooseOpenFilePath( ( path ) => { ImportDatabaseFileText.StringValue = path; - }, "db" ); + }, "yaml", "yml" ); } partial void OnOpenFileChooserButtonClicked( NSObject sender ) { ChooseOpenFilePath( ( path ) => { ImportFileText.StringValue = path; - }, "yaml", "xlsx" ); + }, "yaml", "yml", "xlsx" ); } async partial void OnDoImportButtonClicked( NSObject sender ) @@ -159,7 +164,7 @@ partial void OpenFindDatabaseFileChooserButtonClicked( NSObject sender ) { ChooseOpenFilePath( ( path ) => { FindDatabaseFileText.StringValue = path; - }, "db" ); + }, "yaml", "yml" ); } async partial void OnFindButtonClicked( NSObject sender ) diff --git a/KeySwitchManager/Sources/Runtime/Infrastructures/Database.LiteDB/Database.LiteDB.csproj b/KeySwitchManager/Sources/Runtime/Infrastructures/Database.LiteDB/Database.LiteDB.csproj deleted file mode 100644 index e86d2b8c..00000000 --- a/KeySwitchManager/Sources/Runtime/Infrastructures/Database.LiteDB/Database.LiteDB.csproj +++ /dev/null @@ -1,24 +0,0 @@ - - - - 9 - netstandard2.1 - - R-Koubou - R-Koubou - KeySwitchManager.Database.LiteDB - KeySwitchManager.Infrastructures.Database.LiteDB - KeySwitchManager.Infrastructures.Database.LiteDB - enable - - - - - - - - - - - - diff --git a/KeySwitchManager/Sources/Runtime/Infrastructures/Database.LiteDB/KeySwitches/LiteDbFileWriter.cs b/KeySwitchManager/Sources/Runtime/Infrastructures/Database.LiteDB/KeySwitches/LiteDbFileWriter.cs deleted file mode 100644 index 62e44991..00000000 --- a/KeySwitchManager/Sources/Runtime/Infrastructures/Database.LiteDB/KeySwitches/LiteDbFileWriter.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Threading.Tasks; - -using KeySwitchManager.Commons.Data; -using KeySwitchManager.Domain.KeySwitches.Models; - -using RkHelper.System; - -namespace KeySwitchManager.Infrastructures.Database.LiteDB.KeySwitches -{ - public class LiteDbFileWriter : IKeySwitchWriter - { - private IKeySwitchRepository Repository { get; } - - public bool LeaveOpen => false; - - public LiteDbFileWriter( FilePath dbFilePath ) - { - Repository = new LiteDbRepository( dbFilePath ); - } - - public void Dispose() - { - Disposer.Dispose( Repository ); - } - - async Task IKeySwitchWriter.WriteAsync( IReadOnlyCollection keySwitches, IObserver? loggingSubject ) - { - foreach( var x in keySwitches ) - { - loggingSubject?.OnNext( x.ToString() ); - await Repository.SaveAsync( x ); - } - } - } -} diff --git a/KeySwitchManager/Sources/Runtime/Infrastructures/Database.LiteDB/KeySwitches/LiteDbRepository.cs b/KeySwitchManager/Sources/Runtime/Infrastructures/Database.LiteDB/KeySwitches/LiteDbRepository.cs deleted file mode 100644 index 2e91de52..00000000 --- a/KeySwitchManager/Sources/Runtime/Infrastructures/Database.LiteDB/KeySwitches/LiteDbRepository.cs +++ /dev/null @@ -1,276 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reactive.Subjects; -using System.Threading.Tasks; - -using KeySwitchManager.Commons.Data; -using KeySwitchManager.Domain.KeySwitches.Helpers; -using KeySwitchManager.Domain.KeySwitches.Models; -using KeySwitchManager.Domain.KeySwitches.Models.Values; -using KeySwitchManager.Infrastructures.Database.LiteDB.KeySwitches.Models; -using KeySwitchManager.Infrastructures.Database.LiteDB.KeySwitches.Translators; - -using LiteDB; - -using RkHelper.System; -using RkHelper.Time; - -namespace KeySwitchManager.Infrastructures.Database.LiteDB.KeySwitches -{ - [Obsolete( "Use YamlhRepository instead" )] - public class LiteDbRepository : IKeySwitchRepository - { - public const string KeySwitchesTableName = @"keyswitches"; - - private readonly Subject logging = new(); - public IObservable OnLogging => logging; - - private LiteDatabase Database { get; set; } - - private ILiteCollection KeySwitchTable - => Database.GetCollection( KeySwitchesTableName ); - - public LiteDbRepository( FilePath dbFilePath ) - { - Database = new LiteDatabase( dbFilePath.Path ); - } - - public void Dispose() - { - Disposer.Dispose( logging ); - Close(); - } - - private void Close() - { - lock( this ) - { - if( Database == default! ) - { - return; - } - - Database.Dispose(); - Database = default!; - } - } - - public int Count() - { - var table = Database.GetCollection( KeySwitchesTableName ); - return table.Count(); - } - - #region Save - public async Task SaveAsync( KeySwitch keySwitch ) - { - logging.OnNext( keySwitch.ToString() ); - - var table = Database.GetCollection( KeySwitchesTableName ); - - var translator = new KeySwitchExportTranslator(); - var entity = translator.Translate( keySwitch ); - var exist = table.Find( x => x.Id.Equals( keySwitch.Id.Value ), 0, 1 ).ToList(); - - if( exist.Any() ) - { - entity.Created = DateTimeHelper.ToUtc( exist[ 0 ].Created ); - entity.LastUpdated = DateTimeHelper.NowUtc(); - var updated = table.Update( entity ) ? 1 : 0; - - return await Task.FromResult( new IKeySwitchRepository.SaveResult( - inserted: 0, - updated: updated - )); - } - - entity.Id = keySwitch.Id.Value; - - var insertedId = table.Insert( entity ).AsGuid; - return await Task.FromResult( new IKeySwitchRepository.SaveResult( - inserted: insertedId == entity.Id ? 1 : 0, - updated: 0 - )); - } - - #endregion - - #region Delete - public async Task DeleteAsync( KeySwitchId keySwitchId ) - { - var result = KeySwitchTable.Delete( keySwitchId.Value ); - return await Task.FromResult( result ? 1 : 0 ); - } - - public async Task DeleteAsync( - DeveloperName developerName, - ProductName productName, - InstrumentName instrumentName ) - { - var d = developerName.Value; - var p = productName.Value; - var i = instrumentName.Value; - - return await Task.FromResult( KeySwitchTable.DeleteMany( - x => - ( d == DeveloperName.Any.Value || x.DeveloperName.Contains( d ) ) && - ( p == ProductName.Any.Value || x.ProductName.Contains( p ) ) && - ( i == InstrumentName.Any.Value || x.InstrumentName.Contains( i ) ) - )); - } - - public async Task DeleteAsync( DeveloperName developerName, ProductName productName ) - { - var d = developerName.Value; - var p = productName.Value; - - return await Task.FromResult( KeySwitchTable.DeleteMany( - x => - ( d == DeveloperName.Any.Value || x.DeveloperName.Contains( d ) ) && - ( p == ProductName.Any.Value || x.ProductName.Contains( p ) ) - )); - } - - public async Task DeleteAsync( DeveloperName developerName ) - { - var d = developerName.Value; - - return await Task.FromResult( KeySwitchTable.DeleteMany( - x => - d == DeveloperName.Any.Value || x.DeveloperName.Contains( d ) - )); - } - - public async Task DeleteAsync( ProductName productName ) - { - var p = productName.Value; - - return await Task.FromResult( KeySwitchTable.DeleteMany( - x => - p == ProductName.Any.Value || x.ProductName.Contains( p ) - )); - } - - public async Task DeleteAsync( InstrumentName instrumentName ) - { - var i = instrumentName.Value; - - return await Task.FromResult( KeySwitchTable.DeleteMany( - x => - i == InstrumentName.Any.Value || x.InstrumentName.Contains( i ) - )); - } - - public async Task DeleteAllAsync() - { - var table = Database.GetCollection( KeySwitchesTableName ); - return await Task.FromResult( table.DeleteAll() ); - } - #endregion - - #region Find - private IReadOnlyCollection CreateEntities( IEnumerable query ) - { - var result = new List(); - var translator = new KeySwitchImportTranslator(); - - foreach( var item in query ) - { - result.Add( translator.Translate( item ) ); - } - - return KeySwitchHelper.SortByAlphabetical( result ); - } - - public async Task> FindAsync( KeySwitchId keySwitchId ) - { - return await Task.FromResult( CreateEntities( KeySwitchTable.Find( x => x.Id == keySwitchId.Value ) ) ); - } - - public async Task> FindAsync( - DeveloperName developerName, - ProductName productName, - InstrumentName instrumentName ) - { - var d = developerName.Value; - var p = productName.Value; - var i = instrumentName.Value; - - return await Task.FromResult( CreateEntities( - KeySwitchTable.Find( - x => - ( d == DeveloperName.Any.Value || x.DeveloperName.Contains( d ) ) && - ( p == ProductName.Any.Value || x.ProductName.Contains( p ) ) && - ( i == InstrumentName.Any.Value || x.InstrumentName.Contains( i ) ) - ) - )); - } - - public async Task> FindAsync( DeveloperName developerName, ProductName productName ) - { - var d = developerName.Value; - var p = productName.Value; - - return await Task.FromResult( CreateEntities( - KeySwitchTable.Find( - x => - ( d == DeveloperName.Any.Value || x.DeveloperName.Contains( d ) ) && - ( p == ProductName.Any.Value || x.ProductName.Contains( p ) ) - ) - )); - } - - public async Task> FindAsync( DeveloperName developerName ) - { - var d = developerName.Value; - - if( d == DeveloperName.Any.Value ) - { - return await FindAllAsync(); - } - - return await Task.FromResult( CreateEntities( - KeySwitchTable.Find( - x => - x.DeveloperName.Contains( d ) - ) - )); - } - - public async Task> FindAsync( ProductName productName ) - { - var p = productName.Value; - - if( p == ProductName.Any.Value ) - { - return await FindAllAsync(); - } - - return await Task.FromResult( CreateEntities( - KeySwitchTable.Find( - x => - x.ProductName.Contains( p ) - ) - )); - } - - public async Task> FindAsync( InstrumentName instrumentName ) - { - var i = instrumentName.Value; - - return await Task.FromResult( CreateEntities( - KeySwitchTable.Find( - x => - i == InstrumentName.Any.Value || x.InstrumentName.Contains( i ) - ) - )); - } - - public async Task> FindAllAsync() - { - return await Task.FromResult( CreateEntities( KeySwitchTable.FindAll() ) ); - } - #endregion - } -} diff --git a/KeySwitchManager/Sources/Runtime/Infrastructures/Database.LiteDB/KeySwitches/Models/ArticulationModel.cs b/KeySwitchManager/Sources/Runtime/Infrastructures/Database.LiteDB/KeySwitches/Models/ArticulationModel.cs deleted file mode 100644 index b25514ba..00000000 --- a/KeySwitchManager/Sources/Runtime/Infrastructures/Database.LiteDB/KeySwitches/Models/ArticulationModel.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System.Collections.Generic; - -namespace KeySwitchManager.Infrastructures.Database.LiteDB.KeySwitches.Models -{ - internal class ArticulationModel - { - public string ArticulationName { get; set; } = "Unknown"; - public ICollection NoteOn { get; set; } = new List(); - public ICollection ControlChange { get; set; } = new List(); - public ICollection ProgramChange { get; set; } = new List(); - public IDictionary ExtraData { get; set; } = new Dictionary(); - - public ArticulationModel() - {} - - public ArticulationModel( - string articulationName, - ICollection midiNoteOns, - ICollection midiControlChanges, - ICollection midiProgramChanges, - IDictionary extraData ) - { - ArticulationName = articulationName; - NoteOn = midiNoteOns; - ControlChange = midiControlChanges; - ProgramChange = midiProgramChanges; - ExtraData = extraData; - } - } -} \ No newline at end of file diff --git a/KeySwitchManager/Sources/Runtime/Infrastructures/Database.LiteDB/KeySwitches/Models/KeySwitchModel.cs b/KeySwitchManager/Sources/Runtime/Infrastructures/Database.LiteDB/KeySwitches/Models/KeySwitchModel.cs deleted file mode 100644 index e8d5db27..00000000 --- a/KeySwitchManager/Sources/Runtime/Infrastructures/Database.LiteDB/KeySwitches/Models/KeySwitchModel.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System; -using System.Collections.Generic; - -using LiteDB; - -using RkHelper.Time; - -namespace KeySwitchManager.Infrastructures.Database.LiteDB.KeySwitches.Models -{ - internal class KeySwitchModel - { - [BsonId] - public Guid Id { get; set; } = Guid.NewGuid(); - - public string Author { get; set; } = "Unknwon"; - public string Description { get; set; } = string.Empty; - public DateTime Created { get; set; } = DateTimeHelper.NowUtc(); - public DateTime LastUpdated { get; set; } = DateTimeHelper.NowUtc(); - public string DeveloperName { get; set; } = "Unknown"; - public string ProductName { get; set; } = "Unknown"; - public string InstrumentName { get; set; } = "Unknown"; - public ICollection Articulations { get; set; } = new List(); - public IDictionary ExtraData { get; set; } = new Dictionary(); - - public KeySwitchModel() - {} - - public KeySwitchModel( - Guid id, - string author, - string description, - DateTime created, - DateTime lastUpdated, - string developerName, - string productName, - string instrumentName, - ICollection articulations, - IDictionary extraData ) - { - Id = id; - Author = author; - Description = description; - Created = created; - LastUpdated = lastUpdated; - DeveloperName = developerName; - ProductName = productName; - InstrumentName = instrumentName; - Articulations = articulations; - ExtraData = extraData; - } - } -} \ No newline at end of file diff --git a/KeySwitchManager/Sources/Runtime/Infrastructures/Database.LiteDB/KeySwitches/Models/MidiMessageModel.cs b/KeySwitchManager/Sources/Runtime/Infrastructures/Database.LiteDB/KeySwitches/Models/MidiMessageModel.cs deleted file mode 100644 index a5c936e4..00000000 --- a/KeySwitchManager/Sources/Runtime/Infrastructures/Database.LiteDB/KeySwitches/Models/MidiMessageModel.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace KeySwitchManager.Infrastructures.Database.LiteDB.KeySwitches.Models -{ - internal class MidiMessageModel - { - public int Status { get; set; } - public int DataByte1 { get; set; } - public int DataByte2 { get; set; } - - public MidiMessageModel() - {} - - public MidiMessageModel( - int status, - int dataByte1, - int dataByte2 ) - { - Status = status; - DataByte1 = dataByte1; - DataByte2 = dataByte2; - } - - } -} \ No newline at end of file diff --git a/KeySwitchManager/Sources/Runtime/Infrastructures/Database.LiteDB/KeySwitches/Translators/KeySwitchExportTranslator.cs b/KeySwitchManager/Sources/Runtime/Infrastructures/Database.LiteDB/KeySwitches/Translators/KeySwitchExportTranslator.cs deleted file mode 100644 index 1f6a40b7..00000000 --- a/KeySwitchManager/Sources/Runtime/Infrastructures/Database.LiteDB/KeySwitches/Translators/KeySwitchExportTranslator.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System.Collections.Generic; - -using KeySwitchManager.Commons.Data; -using KeySwitchManager.Commons.Helpers; -using KeySwitchManager.Domain.KeySwitches.Models; -using KeySwitchManager.Domain.KeySwitches.Models.Values; -using KeySwitchManager.Domain.MidiMessages.Models.Aggregations; -using KeySwitchManager.Infrastructures.Database.LiteDB.KeySwitches.Models; - -namespace KeySwitchManager.Infrastructures.Database.LiteDB.KeySwitches.Translators -{ - internal class KeySwitchExportTranslator : IDataTranslator - { - public KeySwitchModel Translate( KeySwitch source ) - { - var articulationModels = new List(); - - foreach( var i in source.Articulations ) - { - var noteOn = new List(); - var controlChange = new List(); - var programChange = new List(); - - ConvertMessageList( i.MidiNoteOns, noteOn ); - ConvertMessageList( i.MidiControlChanges, controlChange ); - ConvertMessageList( i.MidiProgramChanges, programChange ); - - var articulation = new ArticulationModel( - i.ArticulationName.Value, - noteOn, - controlChange, - programChange, - ConvertExtraData( i.ExtraData ) - ); - - articulationModels.Add( articulation ); - } - - return new KeySwitchModel( - source.Id.Value, - source.Author.Value, - source.Description.Value, - UtcDateTimeHelper.ToDateTime( source.Created ), - UtcDateTimeHelper.ToDateTime( source.LastUpdated ), - source.DeveloperName.Value, - source.ProductName.Value, - source.InstrumentName.Value, - articulationModels, - ConvertExtraData( source.ExtraData ) - ); - } - - private static void ConvertMessageList( IReadOnlyCollection src, ICollection dest ) - { - foreach( var i in src ) - { - dest.Add( - new MidiMessageModel( - i.Status.Value, - i.DataByte1.Value, - i.DataByte2.Value - ) - ); - } - } - - private static Dictionary ConvertExtraData( ExtraData source ) - { - var extra = new Dictionary(); - - foreach( var keyValuePair in source ) - { - var k = keyValuePair.Key.Value; - var v = keyValuePair.Value.Value; - extra[ k ] = v; - } - - return extra; - } - - } -} \ No newline at end of file diff --git a/KeySwitchManager/Sources/Runtime/Infrastructures/Database.LiteDB/KeySwitches/Translators/KeySwitchImportTranslator.cs b/KeySwitchManager/Sources/Runtime/Infrastructures/Database.LiteDB/KeySwitches/Translators/KeySwitchImportTranslator.cs deleted file mode 100644 index c0bf6db8..00000000 --- a/KeySwitchManager/Sources/Runtime/Infrastructures/Database.LiteDB/KeySwitches/Translators/KeySwitchImportTranslator.cs +++ /dev/null @@ -1,86 +0,0 @@ -using System.Collections.Generic; - -using KeySwitchManager.Commons.Data; -using KeySwitchManager.Domain.KeySwitches.Models; -using KeySwitchManager.Domain.KeySwitches.Models.Aggregations; -using KeySwitchManager.Domain.KeySwitches.Models.Factory; -using KeySwitchManager.Domain.MidiMessages.Models.Aggregations; -using KeySwitchManager.Domain.MidiMessages.Models.Factory; -using KeySwitchManager.Infrastructures.Database.LiteDB.KeySwitches.Models; - -namespace KeySwitchManager.Infrastructures.Database.LiteDB.KeySwitches.Translators -{ - internal class KeySwitchImportTranslator : IDataTranslator - { - public KeySwitch Translate( KeySwitchModel source ) - { - var articulations = new List(); - - foreach( var i in source.Articulations ) - { - var noteOn = new List(); - var controlChange = new List(); - var programChange = new List(); - - ConvertMessageList( i.NoteOn, noteOn, IMidiNoteOnFactory.Default ); - ConvertMessageList( i.ControlChange, controlChange, IMidiControlChangeFactory.Default ); - ConvertMessageList( i.ProgramChange, programChange, IMidiProgramChangeFactory.Default ); - - var articulation = IArticulationFactory.Default.Create( - i.ArticulationName, - noteOn, - controlChange, - programChange, - ConvertExtraData( i.ExtraData ) - ); - - articulations.Add( articulation ); - } - - return IKeySwitchFactory.Default.Create( - source.Id, - source.Author, - source.Description, - source.Created, - source.LastUpdated, - source.DeveloperName, - source.ProductName, - source.InstrumentName, - articulations, - ConvertExtraData( source.ExtraData ) - ); - - } - - private static IReadOnlyDictionary ConvertExtraData( IDictionary source ) - { - var extra = new Dictionary(); - - foreach( var keyValuePair in source ) - { - var k = keyValuePair.Key; - var v = keyValuePair.Value; - extra.Add( k, v.ToString()! ); - } - - return extra; - } - - private static void ConvertMessageList( - IEnumerable src, - ICollection dest, - IMidiChannelVoiceMessageFactory messageFactory ) - { - foreach( var i in src ) - { - dest.Add( - messageFactory.Create( - i.Status & 0x0F, - i.DataByte1, - i.DataByte2 - ) - ); - } - } - } -} \ No newline at end of file diff --git a/KeySwitchManager/Sources/Tests/Infrastructures/Database.LiteDB/Database.LiteDB.csproj b/KeySwitchManager/Sources/Tests/Infrastructures/Database.LiteDB/Database.LiteDB.csproj deleted file mode 100644 index 1b7d1de7..00000000 --- a/KeySwitchManager/Sources/Tests/Infrastructures/Database.LiteDB/Database.LiteDB.csproj +++ /dev/null @@ -1,22 +0,0 @@ - - - - 9 - net5.0 - KeySwitchManager.Testing.Database.LiteDB - enable - false - - - - - - - - - - - - - - diff --git a/KeySwitchManager/Sources/Tests/Infrastructures/Database.LiteDB/KeySwitches/LiteDbDeleteTest.cs b/KeySwitchManager/Sources/Tests/Infrastructures/Database.LiteDB/KeySwitches/LiteDbDeleteTest.cs deleted file mode 100644 index dcac46e5..00000000 --- a/KeySwitchManager/Sources/Tests/Infrastructures/Database.LiteDB/KeySwitches/LiteDbDeleteTest.cs +++ /dev/null @@ -1,86 +0,0 @@ -using System.Collections.Generic; -using System.IO; - -using KeySwitchManager.Commons.Data; -using KeySwitchManager.Domain.KeySwitches.Models; -using KeySwitchManager.Domain.KeySwitches.Models.Values; -using KeySwitchManager.Infrastructures.Database.LiteDB.KeySwitches; -using KeySwitchManager.Testing.Commons.KeySwitches; - -using NUnit.Framework; - -namespace KeySwitchManager.Testing.Database.LiteDB.KeySwitches -{ - [TestFixture] - public class LiteDbDeleteTest - { - private static IKeySwitchRepository CreateRepository() - => new LiteDbRepository( new FilePath( $"{Path.GetTempFileName()}.db" ) ); - - [Test] - public void DeleteByIdTest() - { - using var repository = CreateRepository(); - var record = TestDataGenerator.CreateKeySwitch(); - - repository.Save( record ); - Assert.AreEqual( 1, repository.Count() ); - - repository.Delete( record.Id ); - Assert.AreEqual( 0, repository.Count() ); - - } - - [Test] - public void DeleteByDeveloperAndProduct() - { - using var repository = CreateRepository(); - var record = TestDataGenerator.CreateKeySwitch(); - - repository.Save( record ); - Assert.AreEqual( 1, repository.Count() ); - - repository.Delete( record.DeveloperName, record.ProductName ); - Assert.AreEqual( 0, repository.Count() ); - } - - [Test] - public void DeleteByWildcardTest() - { - using var repository = CreateRepository(); - - var saveRecord = TestDataGenerator.CreateKeySwitch(); - var deleteRecord = TestDataGenerator.CreateKeySwitch( - DeveloperName.Any.Value, - ProductName.Any.Value, - InstrumentName.Any.Value - ); - - repository.Save( saveRecord ); - Assert.AreEqual( 1, repository.Count() ); - - var deleted = repository.Delete( deleteRecord.DeveloperName, deleteRecord.ProductName ); - Assert.AreEqual( 1, deleted ); - Assert.AreEqual( 0, repository.Count() ); - - } - - [Test] - public void DeleteAllTest() - { - using var repository = CreateRepository(); - var record = new List - { - TestDataGenerator.CreateKeySwitch(), - TestDataGenerator.CreateKeySwitch() - }; - - repository.Save( record[ 0 ] ); - repository.Save( record[ 1 ] ); - Assert.AreEqual( record.Count, repository.Count() ); - - repository.DeleteAll(); - Assert.AreEqual( 0, repository.Count() ); - } - } -} \ No newline at end of file diff --git a/KeySwitchManager/Sources/Tests/Infrastructures/Database.LiteDB/KeySwitches/LiteDbInsertTest.cs b/KeySwitchManager/Sources/Tests/Infrastructures/Database.LiteDB/KeySwitches/LiteDbInsertTest.cs deleted file mode 100644 index 582de424..00000000 --- a/KeySwitchManager/Sources/Tests/Infrastructures/Database.LiteDB/KeySwitches/LiteDbInsertTest.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System.Collections.Generic; -using System.IO; -using System.Linq; - -using KeySwitchManager.Commons.Data; -using KeySwitchManager.Domain.KeySwitches.Models; -using KeySwitchManager.Domain.MidiMessages.Models.Aggregations; -using KeySwitchManager.Domain.MidiMessages.Models.Values; -using KeySwitchManager.Infrastructures.Database.LiteDB.KeySwitches; -using KeySwitchManager.Testing.Commons.KeySwitches; - -using NUnit.Framework; - -namespace KeySwitchManager.Testing.Database.LiteDB.KeySwitches -{ - [TestFixture] - public class LiteDbInsertTest - { - [Test] - public void InsertTest() - { - using IKeySwitchRepository repository = new LiteDbRepository( new FilePath( $"{Path.GetTempFileName()}.db" ) ); - var articulation = TestDataGenerator.CreateArticulation( - new List() - { - new MidiNoteOn( new MidiChannel( 0 ), new MidiNoteNumber( 1 ), new MidiVelocity( 100 ) ) - }, - new List(), - new List() - ); - var record = TestDataGenerator.CreateKeySwitch( articulation ); - - var result = repository.Save( record ); - Assert.AreEqual( 1, result.Inserted ); - - var seq = repository.Find( record.ProductName ); - var cmp = seq.First(); - Assert.AreEqual( record, cmp ); - - seq = repository.Find( record.DeveloperName ); - cmp = seq.First(); - Assert.AreEqual( record, cmp ); - - seq = repository.Find( record.ProductName ); - cmp = seq.First(); - Assert.AreEqual( record, cmp ); - - seq = repository.Find( record.DeveloperName, record.ProductName, record.InstrumentName ); - cmp = seq.First(); - Assert.AreEqual( record, cmp ); - - } - } -} diff --git a/NOTICE.md b/NOTICE.md index 85201399..32d60b0c 100644 --- a/NOTICE.md +++ b/NOTICE.md @@ -73,36 +73,6 @@ SOFTWARE. ---- -### LiteDB - -https://github.com/mbdavid/LiteDB - -``` -The MIT License (MIT) - -Copyright (c) 2014-2020 Mauricio David - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -``` - ----- - ### YamlDotNet https://github.com/aaubry/YamlDotNet From df7ec0946f87263fa815304269b0b3b1d227c630 Mon Sep 17 00:00:00 2001 From: "Hiroaki@R-Koubou" Date: Mon, 23 Oct 2023 23:36:16 +0900 Subject: [PATCH 18/19] =?UTF-8?q?=E3=83=90=E3=83=BC=E3=82=B8=E3=83=A7?= =?UTF-8?q?=E3=83=B3=E5=80=A4=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit WPF以前別途対応済み --- .../Sources/Runtime/Applications/CLI/Applications.CLI.csproj | 2 +- .../Applications/Xamarin.Mac/Applications.Xamarin.Mac.csproj | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/KeySwitchManager/Sources/Runtime/Applications/CLI/Applications.CLI.csproj b/KeySwitchManager/Sources/Runtime/Applications/CLI/Applications.CLI.csproj index b9a9f504..da7a58be 100644 --- a/KeySwitchManager/Sources/Runtime/Applications/CLI/Applications.CLI.csproj +++ b/KeySwitchManager/Sources/Runtime/Applications/CLI/Applications.CLI.csproj @@ -8,7 +8,7 @@ KeySwitchManager.Applications.CLI R-Koubou KeySwitchManager CLI Application - 0.5.2 + 0.5.3 KeySwitchManager CLI Application enable diff --git a/KeySwitchManager/Sources/Runtime/Applications/Xamarin.Mac/Applications.Xamarin.Mac.csproj b/KeySwitchManager/Sources/Runtime/Applications/Xamarin.Mac/Applications.Xamarin.Mac.csproj index b91a658a..c67558db 100644 --- a/KeySwitchManager/Sources/Runtime/Applications/Xamarin.Mac/Applications.Xamarin.Mac.csproj +++ b/KeySwitchManager/Sources/Runtime/Applications/Xamarin.Mac/Applications.Xamarin.Mac.csproj @@ -6,7 +6,7 @@ {6343EE02-E18E-4492-B3B3-B0544ACE01E5} {A3F8F2AB-B479-4A4A-A458-A89E7DC349F1};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} Exe - 0.5.0 + 0.5.3 KeySwitchManager Xamarin.Mac Application KeySwitchManager.Xamarin.Mac KeySwitchManager @@ -88,9 +88,6 @@ - - Always - Always From 542c5b5b96ed809a08d53a783aca9f4201f1f779 Mon Sep 17 00:00:00 2001 From: "Hiroaki@R-Koubou" Date: Mon, 23 Oct 2023 23:37:17 +0900 Subject: [PATCH 19/19] =?UTF-8?q?=E3=83=91=E3=83=96=E3=83=AA=E3=83=83?= =?UTF-8?q?=E3=82=B7=E3=83=A5=E6=99=82=E3=81=AB=E8=87=AA=E5=8B=95=E7=94=9F?= =?UTF-8?q?=E6=88=90=E3=81=97=E3=81=A6=E9=85=8D=E5=B8=83=E7=89=A9=E3=81=AB?= =?UTF-8?q?=E5=90=AB=E3=82=81=E3=82=8B=E3=83=90=E3=83=BC=E3=82=B8=E3=83=A7?= =?UTF-8?q?=E3=83=B3=E6=83=85=E5=A0=B1=E3=82=92=E9=99=A4=E5=A4=96=E5=AF=BE?= =?UTF-8?q?=E8=B1=A1=E3=81=AB=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/Runtime/Applications/CLI/.gitignore | 2 ++ .../Sources/Runtime/Applications/CLI/VERSION.md | 10 ---------- .../Sources/Runtime/Applications/WPF/.gitignore | 2 ++ .../Sources/Runtime/Applications/WPF/VERSION.md | 2 +- .../Runtime/Applications/Xamarin.Mac/.gitignore | 2 ++ .../Runtime/Applications/Xamarin.Mac/VERSION.md | 10 ---------- 6 files changed, 7 insertions(+), 21 deletions(-) create mode 100644 KeySwitchManager/Sources/Runtime/Applications/CLI/.gitignore delete mode 100644 KeySwitchManager/Sources/Runtime/Applications/CLI/VERSION.md create mode 100644 KeySwitchManager/Sources/Runtime/Applications/WPF/.gitignore create mode 100644 KeySwitchManager/Sources/Runtime/Applications/Xamarin.Mac/.gitignore delete mode 100644 KeySwitchManager/Sources/Runtime/Applications/Xamarin.Mac/VERSION.md diff --git a/KeySwitchManager/Sources/Runtime/Applications/CLI/.gitignore b/KeySwitchManager/Sources/Runtime/Applications/CLI/.gitignore new file mode 100644 index 00000000..0174d1d7 --- /dev/null +++ b/KeySwitchManager/Sources/Runtime/Applications/CLI/.gitignore @@ -0,0 +1,2 @@ +# Automatically generated during the build and publish process +./VERSION.md diff --git a/KeySwitchManager/Sources/Runtime/Applications/CLI/VERSION.md b/KeySwitchManager/Sources/Runtime/Applications/CLI/VERSION.md deleted file mode 100644 index 774d77ac..00000000 --- a/KeySwitchManager/Sources/Runtime/Applications/CLI/VERSION.md +++ /dev/null @@ -1,10 +0,0 @@ -KeySwitchManager CLI Application -============================== - -## Assembly Version - -0.5.2.0 - -## Build At - -2023-06-24 01:17:09 +09:00 diff --git a/KeySwitchManager/Sources/Runtime/Applications/WPF/.gitignore b/KeySwitchManager/Sources/Runtime/Applications/WPF/.gitignore new file mode 100644 index 00000000..0174d1d7 --- /dev/null +++ b/KeySwitchManager/Sources/Runtime/Applications/WPF/.gitignore @@ -0,0 +1,2 @@ +# Automatically generated during the build and publish process +./VERSION.md diff --git a/KeySwitchManager/Sources/Runtime/Applications/WPF/VERSION.md b/KeySwitchManager/Sources/Runtime/Applications/WPF/VERSION.md index 655f1885..9fe7c3a8 100644 --- a/KeySwitchManager/Sources/Runtime/Applications/WPF/VERSION.md +++ b/KeySwitchManager/Sources/Runtime/Applications/WPF/VERSION.md @@ -7,4 +7,4 @@ KeySwitchManager WPF Application ## Build At -2023-10-22 18:31:13 +09:00 +2023-10-23 23:32:45 +09:00 diff --git a/KeySwitchManager/Sources/Runtime/Applications/Xamarin.Mac/.gitignore b/KeySwitchManager/Sources/Runtime/Applications/Xamarin.Mac/.gitignore new file mode 100644 index 00000000..0174d1d7 --- /dev/null +++ b/KeySwitchManager/Sources/Runtime/Applications/Xamarin.Mac/.gitignore @@ -0,0 +1,2 @@ +# Automatically generated during the build and publish process +./VERSION.md diff --git a/KeySwitchManager/Sources/Runtime/Applications/Xamarin.Mac/VERSION.md b/KeySwitchManager/Sources/Runtime/Applications/Xamarin.Mac/VERSION.md deleted file mode 100644 index a4480ba5..00000000 --- a/KeySwitchManager/Sources/Runtime/Applications/Xamarin.Mac/VERSION.md +++ /dev/null @@ -1,10 +0,0 @@ -KeySwitchManager Xamarin.Mac Application -============================== - -## Version - -0.3.1 - -## Build At - -2022-10-04 04:14:37 +09:00