From 4fa089c9f40908f83453f1e198e97dd630b9f628 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=BB=A1=E6=BB=A1?= Date: Sat, 11 Feb 2023 17:35:30 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=88=9B=E5=BB=BAGuid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CopyrightHelper/CH.csproj | 6 ++-- CopyrightHelper/ConfigToolWindowControl.xaml | 17 +++++++-- .../ConfigToolWindowControl.xaml.cs | 12 +++++-- CopyrightHelper/Core/CopyrightCore.cs | 7 +++- CopyrightHelper/Core/StoreHelper.cs | 24 +++++++++---- CopyrightHelper/Models/StoreConfig.cs | 16 +++++++++ UnitTest/CopyrightCoreTest.cs | 8 ++--- UnitTest/UnitTest.csproj | 3 +- UnitTest/app.config | 36 +++++++++---------- 9 files changed, 88 insertions(+), 41 deletions(-) diff --git a/CopyrightHelper/CH.csproj b/CopyrightHelper/CH.csproj index 85f82bd..819ad7c 100644 --- a/CopyrightHelper/CH.csproj +++ b/CopyrightHelper/CH.csproj @@ -17,9 +17,9 @@ - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/CopyrightHelper/ConfigToolWindowControl.xaml b/CopyrightHelper/ConfigToolWindowControl.xaml index ec959a3..7210c83 100644 --- a/CopyrightHelper/ConfigToolWindowControl.xaml +++ b/CopyrightHelper/ConfigToolWindowControl.xaml @@ -23,7 +23,12 @@ - + + + + + + @@ -40,18 +45,24 @@ - + - + + + diff --git a/CopyrightHelper/ConfigToolWindowControl.xaml.cs b/CopyrightHelper/ConfigToolWindowControl.xaml.cs index 9ed2850..ab551e5 100644 --- a/CopyrightHelper/ConfigToolWindowControl.xaml.cs +++ b/CopyrightHelper/ConfigToolWindowControl.xaml.cs @@ -43,7 +43,9 @@ namespace CopyrightHelper txtYourName.Text = cfg.YourName; cbIsInsertToTop.IsChecked = cfg.IsInsertToTop; txtTimeFormat.Text = cfg.TimeFormat; - + txtEmail.Text = cfg.Email; + txtVersion.Text = cfg.Version; + BindTypeList(); lbType.SelectedIndex = 0; @@ -184,6 +186,11 @@ namespace CopyrightHelper cfg.YourName = txtYourName.Text.Trim(); cfg.IsInsertToTop = cbIsInsertToTop.IsChecked == true; var tf = txtTimeFormat.Text.Trim(); + + cfg.Email = txtEmail.Text.Trim(); + cfg.Version= txtVersion.Text.Trim (); + + if (!string.IsNullOrEmpty(tf)) { try @@ -232,8 +239,9 @@ namespace CopyrightHelper MessageBox.Show($"CopyrightHelper v{Constants.FileVersion} by Fallstar" + Environment.NewLine + "Home : http://git.oschina.net/fallstar/CopyrightHelper"); } - #endregion + #endregion + } } \ No newline at end of file diff --git a/CopyrightHelper/Core/CopyrightCore.cs b/CopyrightHelper/Core/CopyrightCore.cs index dd12323..291b95a 100644 --- a/CopyrightHelper/Core/CopyrightCore.cs +++ b/CopyrightHelper/Core/CopyrightCore.cs @@ -85,6 +85,9 @@ namespace CopyrightHelper.Core return ConvertToolItem(it); } + + + /// /// 转换为用于插入的语句 /// @@ -102,12 +105,14 @@ namespace CopyrightHelper.Core content = content.Replace("@yourname", cfg.YourName); content = content.Replace("@year", DateTime.Now.Year.ToString()); content = content.Replace("@time", DateTime.Now.ToString(tf)); + content = content.Replace("@email", cfg.Email); + content = content.Replace("@guid", Guid.NewGuid().ToString().ToUpper()); + content = content.Replace("@version", cfg.Version); //修正换行不对问题 if (content.Contains("\r\n")) content.Replace("\r\n", Environment.NewLine); else if (content.Contains("\n")) content.Replace("\n", Environment.NewLine); - return content; } #endregion diff --git a/CopyrightHelper/Core/StoreHelper.cs b/CopyrightHelper/Core/StoreHelper.cs index 4bae423..b0f82e8 100644 --- a/CopyrightHelper/Core/StoreHelper.cs +++ b/CopyrightHelper/Core/StoreHelper.cs @@ -4,6 +4,7 @@ * 说明:用于对配置文件的读写。 * ======================================================================== */ + using System; using System.Collections.Generic; using System.Linq; @@ -41,6 +42,8 @@ namespace CopyrightHelper.Core return store; } + + /// /// 生成默认配置 /// @@ -57,13 +60,20 @@ namespace CopyrightHelper.Core { Key = "*.*", }; - it.Content = @"//=================================================== -// Copyright @ @company @year -// 作者:@yourname -// 时间:@time -// 说明: -//=================================================== -"; + it.Content = +@"#region << 版 本 注 释 >> + /*---------------------------------------------------------------- + * 版权所有 Copyright © @company @year。 + * 作者:@yourname + * 时间:@time + * 邮箱:@email + * Guid:@guid + * 版本:@version + * 描述: + * + *----------------------------------------------------------------*/ + #endregion << 版 本 注 释 >>"; + cfg.Configs.Add(it); return cfg; } diff --git a/CopyrightHelper/Models/StoreConfig.cs b/CopyrightHelper/Models/StoreConfig.cs index 358e811..e78beb9 100644 --- a/CopyrightHelper/Models/StoreConfig.cs +++ b/CopyrightHelper/Models/StoreConfig.cs @@ -30,6 +30,7 @@ namespace CopyrightHelper.Models /// 你的名称 /// public string YourName { get; set; } + /// /// 公司名称 /// @@ -40,6 +41,21 @@ namespace CopyrightHelper.Models /// public string TimeFormat { get; set; } = "yyyy-MM-dd HH:mm:ss"; + /// + /// 邮箱 + /// + public string Email { get; set; } + + /// + /// 版本号 + /// + public string Version { get; set; } + + + + + + /// /// 是否将结果插入到文件头 /// diff --git a/UnitTest/CopyrightCoreTest.cs b/UnitTest/CopyrightCoreTest.cs index c5cf04c..5160901 100644 --- a/UnitTest/CopyrightCoreTest.cs +++ b/UnitTest/CopyrightCoreTest.cs @@ -1,9 +1,5 @@ -//=================================================== -// Copyright @ Thpower.com 2016 -// 作者:Fallstar -// 时间:2016-05-30 14:27:11 -// 说明: -//=================================================== + + using System; using Microsoft.VisualStudio.TestTools.UnitTesting; using CopyrightHelper.Core; diff --git a/UnitTest/UnitTest.csproj b/UnitTest/UnitTest.csproj index 13dbc4d..99537c3 100644 --- a/UnitTest/UnitTest.csproj +++ b/UnitTest/UnitTest.csproj @@ -8,7 +8,7 @@ Properties UnitTest UnitTest - v4.5.2 + v4.8 512 {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 10.0 @@ -16,6 +16,7 @@ $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages False UnitTest + true diff --git a/UnitTest/app.config b/UnitTest/app.config index cb00136..dccc410 100644 --- a/UnitTest/app.config +++ b/UnitTest/app.config @@ -1,39 +1,39 @@ - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - \ No newline at end of file + -- Gitee