Skip to content

Commit 9f45a7d

Browse files
新增程序集信息管理器项目:AssemblyInfoManager
1 parent 1f38b46 commit 9f45a7d

20 files changed

Lines changed: 1695 additions & 0 deletions

AssemblyInfoManager.csproj

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
6+
<ProductVersion>8.0.30703</ProductVersion>
7+
<SchemaVersion>2.0</SchemaVersion>
8+
<ProjectGuid>{6FDF8B53-E1B7-4980-B957-CA4CD1204E22}</ProjectGuid>
9+
<OutputType>WinExe</OutputType>
10+
<AppDesignerFolder>Properties</AppDesignerFolder>
11+
<RootNamespace>SourcePro.Csharp.Lab</RootNamespace>
12+
<AssemblyName>assinfo</AssemblyName>
13+
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
14+
<TargetFrameworkProfile>
15+
</TargetFrameworkProfile>
16+
<FileAlignment>512</FileAlignment>
17+
</PropertyGroup>
18+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
19+
<PlatformTarget>x86</PlatformTarget>
20+
<DebugSymbols>true</DebugSymbols>
21+
<DebugType>full</DebugType>
22+
<Optimize>false</Optimize>
23+
<OutputPath>bin\Debug\</OutputPath>
24+
<DefineConstants>DEBUG;TRACE</DefineConstants>
25+
<ErrorReport>prompt</ErrorReport>
26+
<WarningLevel>4</WarningLevel>
27+
</PropertyGroup>
28+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
29+
<PlatformTarget>x86</PlatformTarget>
30+
<DebugType>none</DebugType>
31+
<Optimize>true</Optimize>
32+
<OutputPath>bin\Release\</OutputPath>
33+
<DefineConstants>TRACE</DefineConstants>
34+
<ErrorReport>prompt</ErrorReport>
35+
<WarningLevel>4</WarningLevel>
36+
</PropertyGroup>
37+
<PropertyGroup>
38+
<ApplicationIcon>Icon.ico</ApplicationIcon>
39+
</PropertyGroup>
40+
<PropertyGroup>
41+
<SignAssembly>true</SignAssembly>
42+
</PropertyGroup>
43+
<PropertyGroup>
44+
<AssemblyOriginatorKeyFile>Sn.pfx</AssemblyOriginatorKeyFile>
45+
</PropertyGroup>
46+
<ItemGroup>
47+
<Reference Include="System" />
48+
<Reference Include="System.Configuration" />
49+
<Reference Include="System.Core" />
50+
<Reference Include="System.Xml.Linq" />
51+
<Reference Include="System.Data.DataSetExtensions" />
52+
<Reference Include="Microsoft.CSharp" />
53+
<Reference Include="System.Data" />
54+
<Reference Include="System.Deployment" />
55+
<Reference Include="System.Drawing" />
56+
<Reference Include="System.Windows.Forms" />
57+
<Reference Include="System.Xml" />
58+
</ItemGroup>
59+
<ItemGroup>
60+
<Compile Include="Entity\AssemblyInformation.cs" />
61+
<Compile Include="Entity\AssemblyVersion.cs" />
62+
<Compile Include="Globalization\Culture.cs" />
63+
<Compile Include="Program.cs" />
64+
<Compile Include="Properties\AssemblyInfo.cs" />
65+
<Compile Include="Resources\Resource.cs" />
66+
<Compile Include="Resources\ResourceReader.cs" />
67+
<Compile Include="Windows\MainWindow.cs">
68+
<SubType>Form</SubType>
69+
</Compile>
70+
<Compile Include="Windows\MainWindow.Designer.cs">
71+
<DependentUpon>MainWindow.cs</DependentUpon>
72+
</Compile>
73+
<EmbeddedResource Include="Properties\Resources.resx">
74+
<Generator>ResXFileCodeGenerator</Generator>
75+
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
76+
<SubType>Designer</SubType>
77+
</EmbeddedResource>
78+
<Compile Include="Properties\Resources.Designer.cs">
79+
<AutoGen>True</AutoGen>
80+
<DependentUpon>Resources.resx</DependentUpon>
81+
<DesignTime>True</DesignTime>
82+
</Compile>
83+
<EmbeddedResource Include="Windows\MainWindow.resx">
84+
<DependentUpon>MainWindow.cs</DependentUpon>
85+
</EmbeddedResource>
86+
<None Include="app.config" />
87+
<None Include="Properties\Settings.settings">
88+
<Generator>SettingsSingleFileGenerator</Generator>
89+
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
90+
</None>
91+
<Compile Include="Properties\Settings.Designer.cs">
92+
<AutoGen>True</AutoGen>
93+
<DependentUpon>Settings.settings</DependentUpon>
94+
<DesignTimeSharedInput>True</DesignTimeSharedInput>
95+
</Compile>
96+
<None Include="Sn.pfx" />
97+
</ItemGroup>
98+
<ItemGroup>
99+
<Content Include="Icon.ico" />
100+
<EmbeddedResource Include="Resources\Icon.ico" />
101+
</ItemGroup>
102+
<ItemGroup />
103+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
104+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
105+
Other similar extension points exist, see Microsoft.Common.targets.
106+
<Target Name="BeforeBuild">
107+
</Target>
108+
<Target Name="AfterBuild">
109+
</Target>
110+
-->
111+
</Project>

AssemblyInfoManager.sln

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 11.00
3+
# Visual Studio 2010
4+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AssemblyInfoManager", "AssemblyInfoManager.csproj", "{6FDF8B53-E1B7-4980-B957-CA4CD1204E22}"
5+
EndProject
6+
Global
7+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
8+
Debug|x86 = Debug|x86
9+
Release|x86 = Release|x86
10+
EndGlobalSection
11+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
12+
{6FDF8B53-E1B7-4980-B957-CA4CD1204E22}.Debug|x86.ActiveCfg = Debug|x86
13+
{6FDF8B53-E1B7-4980-B957-CA4CD1204E22}.Debug|x86.Build.0 = Debug|x86
14+
{6FDF8B53-E1B7-4980-B957-CA4CD1204E22}.Release|x86.ActiveCfg = Release|x86
15+
{6FDF8B53-E1B7-4980-B957-CA4CD1204E22}.Release|x86.Build.0 = Release|x86
16+
EndGlobalSection
17+
GlobalSection(SolutionProperties) = preSolution
18+
HideSolutionNode = FALSE
19+
EndGlobalSection
20+
EndGlobal

Entity/AssemblyInformation.cs

Lines changed: 234 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,234 @@
1+
#region README
2+
3+
/*
4+
* README
5+
*
6+
* Current Thread User : GUOCOLAND\wangyucai
7+
* Machine Name : GLCHQWYCWINW7
8+
* Visual Studio : Microsoft Visual Studio 2010 Ultimate Edition
9+
* Create Time : 2014-11-20 16:23:34
10+
* Common Language Runtime : 4.0.30319.18444
11+
* Minimum .Net Framework Version : 4.0
12+
*
13+
* SourcePro Studio 2014
14+
* Project Url : https://github.com/SourceproStudio/CodeTemplates
15+
* Home Page Url : https://github.com/SourceproStudio
16+
* E-mail Address : MasterDuner@yeah.net or Yucai.Wang-Public@outlook.com
17+
* QQ : 180261899
18+
*/
19+
20+
#endregion
21+
22+
using System.ComponentModel;
23+
using System.IO;
24+
using System.Text.RegularExpressions;
25+
26+
namespace SourcePro.Csharp.Lab.Entity
27+
{
28+
/// <summary>
29+
/// <para>
30+
/// 定义了程序集信息实体。
31+
/// </para>
32+
/// <para>
33+
/// Namespace : <see cref="SourcePro.Csharp.Lab.Entity"/>
34+
/// </para>
35+
/// <para>
36+
/// Type : <see cref="AssemblyInformation"/>
37+
/// </para>
38+
/// <para>
39+
/// The minimum .Net Framework version requirements : 4.0
40+
/// </para>
41+
/// <para>
42+
/// Can not inherit from <see cref="AssemblyInformation"/> !
43+
/// </para>
44+
/// </summary>
45+
/// <seealso cref="SourcePro.Csharp.Lab.Entity"/>
46+
/// <remarks>
47+
/// Can not inherit from <see cref="AssemblyInformation"/> !
48+
/// </remarks>
49+
public sealed class AssemblyInformation
50+
{
51+
private AssemblyVersion _version;
52+
private string _title;
53+
private string _description;
54+
private string _companyName;
55+
private string _productName;
56+
private string _copyright;
57+
private string _trademark;
58+
private const string AssemblyTitle = @"^\[assembly\s?:\s*AssemblyTitle\(\""(?<AssemblyTitle>[\u0020\u0021\u0023-\uFFFF]*)\""\)]";
59+
private const string AssemblyDescription = @"^\[assembly\s?:\s*AssemblyDescription\(\""(?<AssemblyDescription>[\u0020\u0021\u0023-\uFFFF]*)\""\)]";
60+
private const string AssemblyCompany = @"^\[assembly\s?:\s*AssemblyCompany\(\""(?<AssemblyCompany>[\u0020\u0021\u0023-\uFFFF]*)\""\)]";
61+
private const string AssemblyProduct = @"^\[assembly\s?:\s*AssemblyProduct\(\""(?<AssemblyProduct>[\u0020\u0021\u0023-\uFFFF]*)\""\)]";
62+
private const string AssemblyCopyright = @"^\[assembly\s?:\s*AssemblyCopyright\(\""(?<AssemblyCopyright>[\u0020\u0021\u0023-\uFFFF]*)\""\)]";
63+
private const string AssemblyTrademark = @"^\[assembly\s?:\s*AssemblyTrademark\(\""(?<AssemblyTrademark>[\u0020\u0021\u0023-\uFFFF]*)\""\)]";
64+
65+
#region AssemblyInformation Constructors
66+
67+
/// <summary>
68+
/// <para>
69+
/// 用于初始化一个<see cref="AssemblyInformation" />对象实例。
70+
/// </para>
71+
/// </summary>
72+
public AssemblyInformation()
73+
{
74+
this.Version = new AssemblyVersion();
75+
}
76+
77+
#endregion
78+
79+
#region Version
80+
/// <summary>
81+
/// 设置或获取程序集版本信息。
82+
/// </summary>
83+
[Description("Set or get the assembly's version information.")]
84+
[Category("Base Information")]
85+
[TypeConverter(typeof(ExpandableObjectConverter))]
86+
public AssemblyVersion Version
87+
{
88+
get { return _version; }
89+
set { _version = value; }
90+
}
91+
#endregion
92+
93+
#region Title
94+
/// <summary>
95+
/// 设置或获取程序集标题。
96+
/// </summary>
97+
[Description("Set or get the assembly's title.")]
98+
[Category("Base Information")]
99+
public string Title
100+
{
101+
get { return _title; }
102+
set { _title = value; }
103+
}
104+
#endregion
105+
106+
#region Description
107+
/// <summary>
108+
/// 设置或获取程序集的描述信息。
109+
/// </summary>
110+
[Description("Set or get the assembly's description.")]
111+
[Category("Base Information")]
112+
public string Description
113+
{
114+
get { return _description; }
115+
set { _description = value; }
116+
}
117+
#endregion
118+
119+
#region CompanyName
120+
/// <summary>
121+
/// 设置或获取发布程序集的公司名称。
122+
/// </summary>
123+
[Description("Set or get the publishing company name of the assembly.")]
124+
[Category("Base Information")]
125+
public string CompanyName
126+
{
127+
get { return _companyName; }
128+
set { _companyName = value; }
129+
}
130+
#endregion
131+
132+
#region ProductName
133+
/// <summary>
134+
/// 设置或获取产品名称。
135+
/// </summary>
136+
[Description("Set or set product name of the assembly.")]
137+
[Category("Base Information")]
138+
public string ProductName
139+
{
140+
get { return _productName; }
141+
set { _productName = value; }
142+
}
143+
#endregion
144+
145+
#region Copyright
146+
/// <summary>
147+
/// 设置或获取程序集的版权声明。
148+
/// </summary>
149+
[Description("Set or get copyright declaration of the assembly.")]
150+
[Category("Base Information")]
151+
public string Copyright
152+
{
153+
get { return _copyright; }
154+
set { _copyright = value; }
155+
}
156+
#endregion
157+
158+
#region Trademark
159+
/// <summary>
160+
/// 设置或获取程序集的商标。
161+
/// </summary>
162+
[Description("Set or get trademark of the assembly.")]
163+
[Category("Base Information")]
164+
public string Trademark
165+
{
166+
get { return _trademark; }
167+
set { _trademark = value; }
168+
}
169+
#endregion
170+
171+
#region Create
172+
/// <summary>
173+
/// 从模板文件创建<see cref="AssemblyInformation"/>对象实例。
174+
/// </summary>
175+
/// <param name="fileName">模板文件名称。</param>
176+
/// <returns><see cref="AssemblyInformation"/>对象实例。</returns>
177+
static public AssemblyInformation Create(string fileName)
178+
{
179+
AssemblyInformation info = new AssemblyInformation();
180+
if (!File.Exists(fileName))
181+
{
182+
return info;
183+
}
184+
else
185+
{
186+
using (Stream templateStream = File.OpenRead(fileName))
187+
{
188+
using (StreamReader reader = new StreamReader(templateStream))
189+
{
190+
try
191+
{
192+
while (!reader.EndOfStream)
193+
{
194+
SetProperties(reader.ReadLine(), info);
195+
}
196+
}
197+
finally
198+
{
199+
reader.Close();
200+
templateStream.Close();
201+
}
202+
}
203+
}
204+
}
205+
return info;
206+
}
207+
#endregion
208+
209+
#region SetProperties
210+
/// <summary>
211+
/// 设置属性值。
212+
/// </summary>
213+
/// <param name="s">当前行的文本内容。</param>
214+
/// <param name="instance">新创建的<see cref="AssemblyInformation"/>对象实例。</param>
215+
private static void SetProperties(string s, AssemblyInformation instance)
216+
{
217+
if (!string.IsNullOrWhiteSpace(s))
218+
{
219+
if (Regex.IsMatch(s, AssemblyTitle)) instance.Title = Regex.Match(s, AssemblyTitle).Groups["AssemblyTitle"].Value;
220+
if (Regex.IsMatch(s, AssemblyDescription)) instance.Description = Regex.Match(s, AssemblyDescription).Groups["AssemblyDescription"].Value;
221+
if (Regex.IsMatch(s, AssemblyCompany)) instance.CompanyName = Regex.Match(s, AssemblyCompany).Groups["AssemblyCompany"].Value;
222+
if (Regex.IsMatch(s, AssemblyProduct)) instance.ProductName = Regex.Match(s, AssemblyProduct).Groups["AssemblyProduct"].Value;
223+
if (Regex.IsMatch(s, AssemblyCopyright)) instance.Copyright = Regex.Match(s, AssemblyCopyright).Groups["AssemblyCopyright"].Value;
224+
if (Regex.IsMatch(s, AssemblyTrademark)) instance.Trademark = Regex.Match(s, AssemblyTrademark).Groups["AssemblyTrademark"].Value;
225+
if (AssemblyVersion.IsMatchAssemblyVersion(s)) instance.Version = AssemblyVersion.Create(s);
226+
}
227+
}
228+
#endregion
229+
}
230+
}
231+
232+
/*
233+
* Copyright © 2014 Wang Yucai. All rights reserved.
234+
*/

0 commit comments

Comments
 (0)