diff --git a/tools/Ntreev.Crema.Commands/DataSplitSetting.cs b/tools/Ntreev.Crema.Commands/DataSplitSetting.cs index 1c95bffed..b4868a52c 100644 --- a/tools/Ntreev.Crema.Commands/DataSplitSetting.cs +++ b/tools/Ntreev.Crema.Commands/DataSplitSetting.cs @@ -1,4 +1,21 @@ -using System; +//Released under the MIT License. +// +//Copyright (c) 2018 Ntreev Soft co., Ltd. +// +//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. + +using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; diff --git a/tools/Ntreev.Crema.Commands/GetCodeCommand.cs b/tools/Ntreev.Crema.Commands/GetCodeCommand.cs index 78a6d8422..9ff1360b5 100644 --- a/tools/Ntreev.Crema.Commands/GetCodeCommand.cs +++ b/tools/Ntreev.Crema.Commands/GetCodeCommand.cs @@ -27,6 +27,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +using Ntreev.Crema.Commands.OptionProcessor; namespace Ntreev.Crema.Commands { @@ -34,6 +35,7 @@ namespace Ntreev.Crema.Commands [CommandStaticProperty(typeof(CodeSettings))] [CommandStaticProperty(typeof(FilterSettings))] [CommandStaticProperty(typeof(DataBaseSettings))] + [CommandStaticProperty(typeof(ReplaceSettings))] class GetCodeCommand : CommandBase { [Import] @@ -106,6 +108,7 @@ private void GenerateCode() this.Out.WriteLine("receiving info"); var metaData = this.service.GetMetaData(this.Address, DataBaseSettings.DataBaseName, DataBaseSettings.Tags, FilterSettings.FilterExpression, CodeSettings.Devmode, this.Revision); + metaData = ReplaceOptionProcessor.Process(metaData); var generationSettings = new CodeGenerationSettings() { diff --git a/tools/Ntreev.Crema.Commands/GetCommand.cs b/tools/Ntreev.Crema.Commands/GetCommand.cs index 0dd3763a1..68bcb1407 100644 --- a/tools/Ntreev.Crema.Commands/GetCommand.cs +++ b/tools/Ntreev.Crema.Commands/GetCommand.cs @@ -29,6 +29,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +using Ntreev.Crema.Commands.OptionProcessor; namespace Ntreev.Crema.Commands { @@ -36,6 +37,7 @@ namespace Ntreev.Crema.Commands [CommandStaticProperty(typeof(CodeSettings))] [CommandStaticProperty(typeof(FilterSettings))] [CommandStaticProperty(typeof(DataBaseSettings))] + [CommandStaticProperty(typeof(ReplaceSettings))] class GetCommand : CommandBase { [Import] @@ -114,6 +116,7 @@ protected override void OnExecute() this.Out.WriteLine("receiving info"); var metaData = this.service.GetMetaData(this.Address, DataBaseSettings.DataBaseName, DataBaseSettings.Tags, FilterSettings.FilterExpression, CodeSettings.Devmode, this.Revision); + metaData = ReplaceOptionProcessor.Process(metaData); var generationSettings = new CodeGenerationSettings() { diff --git a/tools/Ntreev.Crema.Commands/GetDataCommand.cs b/tools/Ntreev.Crema.Commands/GetDataCommand.cs index 0e5b60e4c..3495f8977 100644 --- a/tools/Ntreev.Crema.Commands/GetDataCommand.cs +++ b/tools/Ntreev.Crema.Commands/GetDataCommand.cs @@ -28,6 +28,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +using Ntreev.Crema.Commands.OptionProcessor; namespace Ntreev.Crema.Commands { @@ -35,6 +36,7 @@ namespace Ntreev.Crema.Commands [CommandStaticProperty(typeof(FilterSettings))] [CommandStaticProperty(typeof(DataBaseSettings))] [CommandStaticProperty(typeof(DataSplitSetting))] + [CommandStaticProperty(typeof(ReplaceSettings))] class GetDataCommand : CommandBase { [Import] @@ -104,6 +106,7 @@ protected override void OnExecute() this.Out.WriteLine("receiving info"); var metaData = service.GetDataGenerationData(this.Address, DataBaseSettings.DataBaseName, DataBaseSettings.Tags, FilterSettings.FilterExpression, this.Devmode, this.Revision); + metaData = ReplaceOptionProcessor.Process(metaData); this.Out.WriteLine("data serializing."); var serializer = this.serializers.FirstOrDefault(item => item.Name == this.OutputType); @@ -135,6 +138,8 @@ private void SerializePerTable(IDataSerializer serializer, SerializationSet meta foreach (var table in metaData.Tables) { var filteredMetaData = metaData.Filter(table.Name); + filteredMetaData = ReplaceOptionProcessor.Process(filteredMetaData); + if (filteredMetaData.Tables.Any()) { metaDataList.Add(filteredMetaData); diff --git a/tools/Ntreev.Crema.Commands/Ntreev.Crema.Commands.csproj b/tools/Ntreev.Crema.Commands/Ntreev.Crema.Commands.csproj index a433156b2..d024ffa69 100644 --- a/tools/Ntreev.Crema.Commands/Ntreev.Crema.Commands.csproj +++ b/tools/Ntreev.Crema.Commands/Ntreev.Crema.Commands.csproj @@ -45,6 +45,8 @@ + + diff --git a/tools/Ntreev.Crema.Commands/OptionProcessor/ReplaceOptionProcessor.cs b/tools/Ntreev.Crema.Commands/OptionProcessor/ReplaceOptionProcessor.cs new file mode 100644 index 000000000..0e0d6e102 --- /dev/null +++ b/tools/Ntreev.Crema.Commands/OptionProcessor/ReplaceOptionProcessor.cs @@ -0,0 +1,65 @@ +//Released under the MIT License. +// +//Copyright (c) 2018 Ntreev Soft co., Ltd. +// +//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. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Ntreev.Crema.Runtime.Generation; +using Ntreev.Crema.Runtime.Serialization; + +namespace Ntreev.Crema.Commands.OptionProcessor +{ + static class ReplaceOptionProcessor + { + public static Tuple Process(Tuple metaData) + { + var generationSet = metaData.Item1; + var serializationSet = metaData.Item2; + + generationSet = Process(generationSet); + serializationSet = Process(serializationSet); + + return new Tuple(generationSet, serializationSet); + } + + public static GenerationSet Process(GenerationSet generationSet) + { + if (ReplaceSettings.ReplaceHashValue != null) + { + generationSet.Revision = ReplaceSettings.ReplaceRevision; + generationSet.TablesHashValue = ReplaceSettings.ReplaceHashValue; + generationSet.TypesHashValue = ReplaceSettings.ReplaceHashValue; + } + + return generationSet; + } + + public static SerializationSet Process(SerializationSet serializationSet) + { + if (ReplaceSettings.ReplaceRevision != long.MinValue) + { + serializationSet.Revision = ReplaceSettings.ReplaceRevision; + serializationSet.TablesHashValue = ReplaceSettings.ReplaceHashValue; + serializationSet.TypesHashValue = ReplaceSettings.ReplaceHashValue; + } + + return serializationSet; + } + } +} diff --git a/tools/Ntreev.Crema.Commands/ReplaceSettings.cs b/tools/Ntreev.Crema.Commands/ReplaceSettings.cs new file mode 100644 index 000000000..dbc1669c6 --- /dev/null +++ b/tools/Ntreev.Crema.Commands/ReplaceSettings.cs @@ -0,0 +1,46 @@ +//Released under the MIT License. +// +//Copyright (c) 2018 Ntreev Soft co., Ltd. +// +//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. + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Ntreev.Library.Commands; + +namespace Ntreev.Crema.Commands +{ + static class ReplaceSettings + { + [CommandProperty] + [DefaultValue((long)long.MinValue)] + [Description("바이너리 파일 헤더의 Revision 값을 변경합니다.")] + public static long ReplaceRevision + { + get; set; + } + + [CommandProperty("replace-hashvalue")] + [DefaultValue(null)] + [Description("바이너리 파일 헤더의 TablesHashValue, TypesHashValue 값을 변경합니다.")] + public static string ReplaceHashValue + { + get; set; + } + } +}