Skip to content

Commit

Permalink
Add AssemblyHelper
Browse files Browse the repository at this point in the history
Migrato NetStandard 2.0
Fix error on CompressHelper
  • Loading branch information
Nonobis committed Feb 20, 2018
1 parent c403640 commit 3b8adfe
Show file tree
Hide file tree
Showing 5 changed files with 164 additions and 87 deletions.
145 changes: 145 additions & 0 deletions SimpleHelper.Core/AssemblyHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;

namespace SimpleHelper.Core
{
/// <summary>
/// Class AssemblyHelper
/// </summary>
public static class AssemblyHelper
{
#region Public Properties

/// <summary>
/// Gets the assembly company.
/// </summary>
/// <value>The assembly company.</value>
public static string AssemblyCompany
{
get
{
return Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyCompanyAttribute>().Company;
}
}

/// <summary>
/// Gets the assembly copyright.
/// </summary>
/// <value>The assembly copyright.</value>
public static string AssemblyCopyright
{
get
{
return Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyCopyrightAttribute>().Copyright;
}
}

/// <summary>
/// Gets the assembly description.
/// </summary>
/// <value>The assembly description.</value>
public static string AssemblyDescription
{
get
{
return Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyDescriptionAttribute>().Description;
}
}

/// <summary>
/// Gets the get referenced assembly.
/// </summary>
/// <value>
/// The get referenced assembly.
/// </value>
public static List<AssemblyName> GetReferencedAssembly
{
get {
return Assembly.GetEntryAssembly().GetReferencedAssemblies().ToList();
}
}

/// <summary>
/// Gets the assembly directory.
/// </summary>
/// <value>The assembly directory.</value>
public static string AssemblyDirectory => Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);

/// <summary>
/// Gets the assembly product.
/// </summary>
/// <value>The assembly product.</value>
public static string AssemblyProduct
{
get
{
return Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyProductAttribute>().Product;
}
}

/// <summary>
/// Gets the assembly title.
/// </summary>
/// <value>The assembly title.</value>
public static string AssemblyTitle
{
get
{
return Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyTitleAttribute>().Title;
}
}

/// <summary>
/// Gets the assembly version.
/// </summary>
/// <value>The assembly version.</value>
public static string AssemblyVersion
{
get
{
return Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyVersionAttribute>().Version;
}
}

/// <summary>
/// Gets the current assembly.
/// </summary>
/// <value>The current assembly.</value>
public static Assembly CurrentAssembly
{
get
{
return Assembly.GetEntryAssembly();
}
}

/// <summary>
/// Gets the name of the executable.
/// </summary>
/// <value>The name of the executable.</value>
public static string ExecutableName
{
get
{
return Path.GetFileName(Assembly.GetEntryAssembly().Location);
}
}

/// <summary>
/// Gets the executable path.
/// </summary>
/// <value>The executable path.</value>
public static string ExecutablePath
{
get
{
return Assembly.GetEntryAssembly().Location;
}
}

#endregion Public Properties
}
}
2 changes: 1 addition & 1 deletion SimpleHelper.Core/CompressHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public static void DecompressTo(this Stream input, Stream output)
gz.TransfertTo(output);
}
}

/// <summary>
/// Serializes as XML and compress.
/// </summary>
Expand Down
67 changes: 0 additions & 67 deletions SimpleHelper.Core/LocalComputerHelper.cs

This file was deleted.

20 changes: 8 additions & 12 deletions SimpleHelper.Core/SimpleHelper.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

<PropertyGroup>
<Description>Simple collection of helper for your project.</Description>
<Copyright>Arnaud Dartois (c) 2017</Copyright>
<Copyright>Arnaud Dartois (c) 2017-2018</Copyright>
<AssemblyTitle>SimpleHelper.Core</AssemblyTitle>
<NeutralLanguage>en-US</NeutralLanguage>
<VersionPrefix>0.0.1-alpha</VersionPrefix>
<Authors>Arnaud Dartois</Authors>
<TargetFramework>netstandard1.6</TargetFramework>
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyName>SimpleHelper.Core</AssemblyName>
<OutputType>Library</OutputType>
<PackageId>SimpleHelper.Core</PackageId>
Expand All @@ -20,28 +20,24 @@
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<PackageReleaseNotes>Initial Version</PackageReleaseNotes>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageReleaseNotes>Added AssemblyHelper from SimpleHelper</PackageReleaseNotes>
<Version>0.0.2-alpha</Version>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NuGet.CommandLine" Version="3.5.0" />
<PackageReference Include="NuGet.CommandLine" Version="4.5.1" />
<PackageReference Include="System.Drawing.Primitives" Version="4.3.0" />
<PackageReference Include="System.IO" Version="4.3.0" />
<PackageReference Include="System.Net.NameResolution" Version="4.0.0" />
<PackageReference Include="System.Net.NetworkInformation" Version="4.3.0" />
<PackageReference Include="System.Net.Requests" Version="4.3.0" />
<PackageReference Include="System.Security.Principal.Windows" Version="4.3.0" />
<PackageReference Include="System.Net.NameResolution" Version="4.3.0" />
<PackageReference Include="System.threading.tasks.parallel" Version="4.3.0" />
<PackageReference Include="System.Threading.Thread" Version="4.3.0" />
<PackageReference Include="System.Threading.ThreadPool" Version="4.3.0" />
</ItemGroup>

<Target Name="PostcompileScript" AfterTargets="Build">
<Exec Command="dotnet pack --version-suffix $(version) --configuration Release" />
</Target>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.6' ">
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="System.ComponentModel.Primitives" Version="4.3.0" />
<PackageReference Include="System.Reflection.TypeExtensions" Version="4.3.0" />
<PackageReference Include="System.Xml.XmlSerializer" Version="4.3.0" />
Expand Down
17 changes: 10 additions & 7 deletions SimpleHelper.sln
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2026
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleHelper", "SimpleHelper\SimpleHelper.csproj", "{4C495A4D-88A6-49BC-A536-BDC54A09287C}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "SimpleHelper.Core", "SimpleHelper.Core\SimpleHelper.Core.xproj", "{EC268AC2-004A-4738-8A61-04AA05467CA3}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SimpleHelper.Core", "SimpleHelper.Core\SimpleHelper.Core.csproj", "{AAE2478B-4870-4C46-AF9E-DB3F8514E1E4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -17,12 +17,15 @@ Global
{4C495A4D-88A6-49BC-A536-BDC54A09287C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4C495A4D-88A6-49BC-A536-BDC54A09287C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4C495A4D-88A6-49BC-A536-BDC54A09287C}.Release|Any CPU.Build.0 = Release|Any CPU
{EC268AC2-004A-4738-8A61-04AA05467CA3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EC268AC2-004A-4738-8A61-04AA05467CA3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EC268AC2-004A-4738-8A61-04AA05467CA3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EC268AC2-004A-4738-8A61-04AA05467CA3}.Release|Any CPU.Build.0 = Release|Any CPU
{AAE2478B-4870-4C46-AF9E-DB3F8514E1E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AAE2478B-4870-4C46-AF9E-DB3F8514E1E4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AAE2478B-4870-4C46-AF9E-DB3F8514E1E4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AAE2478B-4870-4C46-AF9E-DB3F8514E1E4}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {102C0675-81BE-4164-B89D-6C8712F98925}
EndGlobalSection
EndGlobal

0 comments on commit 3b8adfe

Please sign in to comment.