Skip to content

Commit 99e0554

Browse files
committed
Refactor of LibHelper, splitting each supported native libraries bundle into it's own assembly.
1 parent eecfc8f commit 99e0554

31 files changed

+817
-31
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
*.suo
2+
*/*.??proj.user
3+
*/bin
4+
*/obj
25
Packages

.nuget/NuGet.targets

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir>
55

66
<!-- Enable the restore command to run before builds -->
7-
<RestorePackages Condition=" '$(RestorePackages)' == '' ">false</RestorePackages>
7+
<RestorePackages Condition=" '$(RestorePackages)' == '' ">true</RestorePackages>
88

99
<!-- Property that enables building a package from a project -->
1010
<BuildPackage Condition=" '$(BuildPackage)' == '' ">false</BuildPackage>
1111

1212
<!-- Determines if package restore consent is required to restore packages -->
13-
<RequireRestoreConsent Condition=" '$(RequireRestoreConsent)' != 'false' ">true</RequireRestoreConsent>
13+
<RequireRestoreConsent Condition=" '$(RequireRestoreConsent)' != 'false' ">false</RequireRestoreConsent>
1414

1515
<!-- Download NuGet.exe if it does not already exist -->
1616
<DownloadNuGetExe Condition=" '$(DownloadNuGetExe)' == '' ">false</DownloadNuGetExe>
@@ -147,4 +147,4 @@
147147
</Code>
148148
</Task>
149149
</UsingTask>
150-
</Project>
150+
</Project>
15.3 MB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
using System;
2+
using System.IO;
3+
using System.Collections.Generic;
4+
using System.Text;
5+
using System.Reflection;
6+
7+
namespace WkHtmlToXSharp
8+
{
9+
public class Linux32NativeBundle : INativeLibraryBundle
10+
{
11+
private static readonly Assembly Assembly = Assembly.GetExecutingAssembly();
12+
private static readonly string ResourcesPath = typeof(Linux32NativeBundle).Namespace + ".Libs.";
13+
14+
#region INativeLibraryBundle Members
15+
16+
public bool SupportsCurrentPlatform
17+
{
18+
get {
19+
return Environment.OSVersion.Platform == PlatformID.Unix && !WkHtmlToXLibrariesManager.RunningIn64Bits;
20+
}
21+
}
22+
23+
private void DeployLibrary(WkHtmlToXLibrariesManager manager, string resource)
24+
{
25+
var fileName = resource.Substring(ResourcesPath.Length);
26+
27+
using (var stream = Assembly.GetManifestResourceStream(resource))
28+
{
29+
manager.DeployLibrary(stream, fileName, File.GetLastWriteTime(Assembly.Location));
30+
}
31+
}
32+
33+
public void DeployBundle(WkHtmlToXLibrariesManager manager)
34+
{
35+
if (manager == null) throw new ArgumentNullException("manager");
36+
37+
var resourcesList = Assembly.GetManifestResourceNames();
38+
39+
foreach (var res in resourcesList)
40+
{
41+
if (res.StartsWith(ResourcesPath))
42+
DeployLibrary(manager, res);
43+
}
44+
}
45+
46+
#endregion
47+
}
48+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("WkHtmlToXSharp.Linux32")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("Pablo Ruiz García")]
12+
[assembly: AssemblyProduct("WkHtmlToXSharp")]
13+
[assembly: AssemblyCopyright("Copyright © Pablo Ruiz García 2011~2013")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("44a28893-09f7-47ed-b019-21e4044730e3")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("0.0.0.0")]
36+
[assembly: AssemblyFileVersion("0.0.0.0")]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{32C05814-398B-436A-B76D-72EDCD15F199}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>WkHtmlToXSharp</RootNamespace>
11+
<AssemblyName>WkHtmlToXSharp.Linux32</AssemblyName>
12+
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
<TargetFrameworkProfile />
15+
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
16+
<RestorePackages>true</RestorePackages>
17+
</PropertyGroup>
18+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
19+
<DebugSymbols>true</DebugSymbols>
20+
<DebugType>full</DebugType>
21+
<Optimize>false</Optimize>
22+
<OutputPath>bin\Debug\</OutputPath>
23+
<DefineConstants>DEBUG;TRACE</DefineConstants>
24+
<ErrorReport>prompt</ErrorReport>
25+
<WarningLevel>4</WarningLevel>
26+
</PropertyGroup>
27+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
28+
<DebugType>pdbonly</DebugType>
29+
<Optimize>true</Optimize>
30+
<OutputPath>bin\Release\</OutputPath>
31+
<DefineConstants>TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
</PropertyGroup>
35+
<ItemGroup>
36+
<Reference Include="System" />
37+
<Reference Include="System.Core" />
38+
</ItemGroup>
39+
<ItemGroup>
40+
<Compile Include="Properties\AssemblyInfo.cs" />
41+
<Compile Include="Linux32NativeBundle.cs" />
42+
</ItemGroup>
43+
<ItemGroup>
44+
<ProjectReference Include="..\WkHtmlToXSharp\WkHtmlToXSharp.csproj">
45+
<Project>{3dadecbf-6d08-4090-9a1d-2064d0466381}</Project>
46+
<Name>WkHtmlToXSharp</Name>
47+
</ProjectReference>
48+
</ItemGroup>
49+
<ItemGroup>
50+
<EmbeddedResource Include="Libs\libwkhtmltox0.so.gz" />
51+
</ItemGroup>
52+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
53+
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
54+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
55+
Other similar extension points exist, see Microsoft.Common.targets.
56+
<Target Name="BeforeBuild">
57+
</Target>
58+
<Target Name="AfterBuild">
59+
</Target>
60+
-->
61+
</Project>
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="Common.Logging" version="2.1.2" targetFramework="net35" />
4+
</packages>
15.7 MB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
using System;
2+
using System.IO;
3+
using System.Collections.Generic;
4+
using System.Text;
5+
using System.Reflection;
6+
7+
namespace WkHtmlToXSharp
8+
{
9+
public class Linux64NativeBundle : INativeLibraryBundle
10+
{
11+
private static readonly Assembly Assembly = Assembly.GetExecutingAssembly();
12+
private static readonly string ResourcesPath = typeof(Linux64NativeBundle).Namespace + ".Libs.";
13+
14+
#region INativeLibraryBundle Members
15+
16+
public bool SupportsCurrentPlatform
17+
{
18+
get {
19+
return Environment.OSVersion.Platform == PlatformID.Unix && WkHtmlToXLibrariesManager.RunningIn64Bits;
20+
}
21+
}
22+
23+
private void DeployLibrary(WkHtmlToXLibrariesManager manager, string resource)
24+
{
25+
var fileName = resource.Substring(ResourcesPath.Length);
26+
27+
using (var stream = Assembly.GetManifestResourceStream(resource))
28+
{
29+
manager.DeployLibrary(stream, fileName, File.GetLastWriteTime(Assembly.Location));
30+
}
31+
}
32+
33+
public void DeployBundle(WkHtmlToXLibrariesManager manager)
34+
{
35+
if (manager == null) throw new ArgumentNullException("manager");
36+
37+
var resourcesList = Assembly.GetManifestResourceNames();
38+
39+
foreach (var res in resourcesList)
40+
{
41+
if (res.StartsWith(ResourcesPath))
42+
DeployLibrary(manager, res);
43+
}
44+
}
45+
46+
#endregion
47+
}
48+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("WkHtmlToXSharp.Linux64")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("Microsoft")]
12+
[assembly: AssemblyProduct("WkHtmlToXSharp.Linux64")]
13+
[assembly: AssemblyCopyright("Copyright © Microsoft 2013")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("778b4aeb-6d60-46f5-9eaa-7ed8d4655482")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{23B0D174-40F4-4BB3-A5AA-02F7E3D8A420}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>WkHtmlToXSharp</RootNamespace>
11+
<AssemblyName>WkHtmlToXSharp.Linux64</AssemblyName>
12+
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
<TargetFrameworkProfile />
15+
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
16+
<RestorePackages>true</RestorePackages>
17+
</PropertyGroup>
18+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
19+
<DebugSymbols>true</DebugSymbols>
20+
<DebugType>full</DebugType>
21+
<Optimize>false</Optimize>
22+
<OutputPath>bin\Debug\</OutputPath>
23+
<DefineConstants>DEBUG;TRACE</DefineConstants>
24+
<ErrorReport>prompt</ErrorReport>
25+
<WarningLevel>4</WarningLevel>
26+
</PropertyGroup>
27+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
28+
<DebugType>pdbonly</DebugType>
29+
<Optimize>true</Optimize>
30+
<OutputPath>bin\Release\</OutputPath>
31+
<DefineConstants>TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
</PropertyGroup>
35+
<ItemGroup>
36+
<Reference Include="System" />
37+
<Reference Include="System.Core" />
38+
</ItemGroup>
39+
<ItemGroup>
40+
<Compile Include="Linux64NativeBundle.cs" />
41+
<Compile Include="Properties\AssemblyInfo.cs" />
42+
</ItemGroup>
43+
<ItemGroup>
44+
<EmbeddedResource Include="Libs\libwkhtmltox0.so.gz" />
45+
</ItemGroup>
46+
<ItemGroup>
47+
<ProjectReference Include="..\WkHtmlToXSharp\WkHtmlToXSharp.csproj">
48+
<Project>{3dadecbf-6d08-4090-9a1d-2064d0466381}</Project>
49+
<Name>WkHtmlToXSharp</Name>
50+
</ProjectReference>
51+
</ItemGroup>
52+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
53+
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
54+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
55+
Other similar extension points exist, see Microsoft.Common.targets.
56+
<Target Name="BeforeBuild">
57+
</Target>
58+
<Target Name="AfterBuild">
59+
</Target>
60+
-->
61+
</Project>
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="Common.Logging" version="2.1.2" targetFramework="net35" />
4+
</packages>

WkHtmlToXSharp.Tests/WkHtmlToXSharp.Tests.csproj

+12
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,18 @@
113113
<Compile Include="PdfConverterTests.cs" />
114114
</ItemGroup>
115115
<ItemGroup>
116+
<ProjectReference Include="..\WkHtmlToXSharp.Linux32\WkHtmlToXSharp.Linux32.csproj">
117+
<Project>{32c05814-398b-436a-b76d-72edcd15f199}</Project>
118+
<Name>WkHtmlToXSharp.Linux32</Name>
119+
</ProjectReference>
120+
<ProjectReference Include="..\WkHtmlToXSharp.Linux64\WkHtmlToXSharp.Linux64.csproj">
121+
<Project>{23b0d174-40f4-4bb3-a5aa-02f7e3d8a420}</Project>
122+
<Name>WkHtmlToXSharp.Linux64</Name>
123+
</ProjectReference>
124+
<ProjectReference Include="..\WkHtmlToXSharp.Win32\WkHtmlToXSharp.Win32.csproj">
125+
<Project>{eff2501d-d316-40a9-9362-9f771fb6ca98}</Project>
126+
<Name>WkHtmlToXSharp.Win32</Name>
127+
</ProjectReference>
116128
<ProjectReference Include="..\WkHtmlToXSharp\WkHtmlToXSharp.csproj">
117129
<Project>{3DADECBF-6D08-4090-9A1D-2064D0466381}</Project>
118130
<Name>WkHtmlToXSharp</Name>

WkHtmlToXSharp.Tests/packages.config

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3+
<package id="Common.Logging" version="2.1.2" targetFramework="net35" />
34
<package id="NUnit" version="2.6.3" targetFramework="net35" />
45
</packages>
531 KB
Binary file not shown.
19.9 KB
Binary file not shown.
4.96 KB
Binary file not shown.
106 KB
Binary file not shown.
11 MB
Binary file not shown.

0 commit comments

Comments
 (0)