Skip to content

Commit 813e404

Browse files
committed
Moved sample project into a different solution.
1 parent 6721384 commit 813e404

16 files changed

+95
-84
lines changed

LazyAssemblyLoading.sln

-28
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,8 @@ VisualStudioVersion = 12.0.40629.0
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LazyAssemblyLoading", "LazyAssemblyLoading\LazyAssemblyLoading.csproj", "{0B51A58E-0311-4404-873B-AE66E185D1B4}"
77
EndProject
8-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tester", "Tester\Tester.csproj", "{393232E7-57CD-4D52-B45D-DF408E8DA5DF}"
9-
ProjectSection(ProjectDependencies) = postProject
10-
{B2404333-8B58-4B1B-B92C-3254C3863B8E} = {B2404333-8B58-4B1B-B92C-3254C3863B8E}
11-
EndProjectSection
12-
EndProject
138
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LazyAssemblyLoadingUnitTest", "LazyAssemblyLoadingUnitTest\LazyAssemblyLoadingUnitTest.csproj", "{F6FF7D76-E531-47DA-A381-27F3080CE026}"
149
EndProject
15-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestAssembly1", "TestAssembly1\TestAssembly1.csproj", "{B2404333-8B58-4B1B-B92C-3254C3863B8E}"
16-
EndProject
17-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Sample", "Sample", "{17E3DFC3-C5AF-4191-AC9F-281F16B79D3D}"
18-
EndProject
19-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestInterfaces", "TestInterfaces\TestInterfaces.csproj", "{AA95AC6B-105D-4A4F-A2B3-00F8495B5582}"
20-
EndProject
2110
Global
2211
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2312
Debug|Any CPU = Debug|Any CPU
@@ -28,29 +17,12 @@ Global
2817
{0B51A58E-0311-4404-873B-AE66E185D1B4}.Debug|Any CPU.Build.0 = Debug|Any CPU
2918
{0B51A58E-0311-4404-873B-AE66E185D1B4}.Release|Any CPU.ActiveCfg = Release|Any CPU
3019
{0B51A58E-0311-4404-873B-AE66E185D1B4}.Release|Any CPU.Build.0 = Release|Any CPU
31-
{393232E7-57CD-4D52-B45D-DF408E8DA5DF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
32-
{393232E7-57CD-4D52-B45D-DF408E8DA5DF}.Debug|Any CPU.Build.0 = Debug|Any CPU
33-
{393232E7-57CD-4D52-B45D-DF408E8DA5DF}.Release|Any CPU.ActiveCfg = Release|Any CPU
34-
{393232E7-57CD-4D52-B45D-DF408E8DA5DF}.Release|Any CPU.Build.0 = Release|Any CPU
3520
{F6FF7D76-E531-47DA-A381-27F3080CE026}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
3621
{F6FF7D76-E531-47DA-A381-27F3080CE026}.Debug|Any CPU.Build.0 = Debug|Any CPU
3722
{F6FF7D76-E531-47DA-A381-27F3080CE026}.Release|Any CPU.ActiveCfg = Release|Any CPU
3823
{F6FF7D76-E531-47DA-A381-27F3080CE026}.Release|Any CPU.Build.0 = Release|Any CPU
39-
{B2404333-8B58-4B1B-B92C-3254C3863B8E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
40-
{B2404333-8B58-4B1B-B92C-3254C3863B8E}.Debug|Any CPU.Build.0 = Debug|Any CPU
41-
{B2404333-8B58-4B1B-B92C-3254C3863B8E}.Release|Any CPU.ActiveCfg = Release|Any CPU
42-
{B2404333-8B58-4B1B-B92C-3254C3863B8E}.Release|Any CPU.Build.0 = Release|Any CPU
43-
{AA95AC6B-105D-4A4F-A2B3-00F8495B5582}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
44-
{AA95AC6B-105D-4A4F-A2B3-00F8495B5582}.Debug|Any CPU.Build.0 = Debug|Any CPU
45-
{AA95AC6B-105D-4A4F-A2B3-00F8495B5582}.Release|Any CPU.ActiveCfg = Release|Any CPU
46-
{AA95AC6B-105D-4A4F-A2B3-00F8495B5582}.Release|Any CPU.Build.0 = Release|Any CPU
4724
EndGlobalSection
4825
GlobalSection(SolutionProperties) = preSolution
4926
HideSolutionNode = FALSE
5027
EndGlobalSection
51-
GlobalSection(NestedProjects) = preSolution
52-
{393232E7-57CD-4D52-B45D-DF408E8DA5DF} = {17E3DFC3-C5AF-4191-AC9F-281F16B79D3D}
53-
{B2404333-8B58-4B1B-B92C-3254C3863B8E} = {17E3DFC3-C5AF-4191-AC9F-281F16B79D3D}
54-
{AA95AC6B-105D-4A4F-A2B3-00F8495B5582} = {17E3DFC3-C5AF-4191-AC9F-281F16B79D3D}
55-
EndGlobalSection
5628
EndGlobal

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public Lazy<IPlugin, IPluginMetadata>[] Plugins { get; set; }
2626
public Lazy<IDependency> Dependency { get; set; }
2727
```
2828

29-
A sample program can be seen in the "Tester" project.
29+
A sample program can be found in the "Sample" folder.
3030

3131
## Motivation
3232

TestInterfaces/IPlugin.cs Sample/Interfaces/IPlugin.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using System.Text;
55
using System.Threading.Tasks;
66

7-
namespace TestInterfaces
7+
namespace Interfaces
88
{
99
public interface IPlugin
1010
{

TestInterfaces/IPluginMetadata.cs Sample/Interfaces/IPluginMetadata.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using System.Text;
55
using System.Threading.Tasks;
66

7-
namespace TestInterfaces
7+
namespace Interfaces
88
{
99
public interface IPluginMetadata
1010
{

TestInterfaces/TestInterfaces.csproj Sample/Interfaces/Interfaces.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
<ProjectGuid>{AA95AC6B-105D-4A4F-A2B3-00F8495B5582}</ProjectGuid>
88
<OutputType>Library</OutputType>
99
<AppDesignerFolder>Properties</AppDesignerFolder>
10-
<RootNamespace>TestInterfaces</RootNamespace>
11-
<AssemblyName>TestInterfaces</AssemblyName>
10+
<RootNamespace>Interfaces</RootNamespace>
11+
<AssemblyName>Interfaces</AssemblyName>
1212
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
1313
<FileAlignment>512</FileAlignment>
1414
</PropertyGroup>

TestInterfaces/PluginExportAttribute.cs Sample/Interfaces/PluginExportAttribute.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using System.Text;
66
using System.Threading.Tasks;
77

8-
namespace TestInterfaces
8+
namespace Interfaces
99
{
1010
[MetadataAttribute]
1111
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]

TestInterfaces/Properties/AssemblyInfo.cs Sample/Interfaces/Properties/AssemblyInfo.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
// General Information about an assembly is controlled through the following
66
// set of attributes. Change these attribute values to modify the information
77
// associated with an assembly.
8-
[assembly: AssemblyTitle("TestInterfaces")]
8+
[assembly: AssemblyTitle("Interfaces")]
99
[assembly: AssemblyDescription("")]
1010
[assembly: AssemblyConfiguration("")]
1111
[assembly: AssemblyCompany("")]
12-
[assembly: AssemblyProduct("TestInterfaces")]
12+
[assembly: AssemblyProduct("Interfaces")]
1313
[assembly: AssemblyCopyright("Copyright © 2016")]
1414
[assembly: AssemblyTrademark("")]
1515
[assembly: AssemblyCulture("")]
File renamed without changes.

Tester/Tester.csproj Sample/LazyAssemblyLoadingSample/LazyAssemblyLoadingSample.csproj

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
<ProjectGuid>{393232E7-57CD-4D52-B45D-DF408E8DA5DF}</ProjectGuid>
88
<OutputType>Exe</OutputType>
99
<AppDesignerFolder>Properties</AppDesignerFolder>
10-
<RootNamespace>Tester</RootNamespace>
11-
<AssemblyName>Tester</AssemblyName>
10+
<RootNamespace>LazyAssemblyLoadingSample</RootNamespace>
11+
<AssemblyName>LazyAssemblyLoadingSample</AssemblyName>
1212
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
1313
<FileAlignment>512</FileAlignment>
1414
<TargetFrameworkProfile />
@@ -50,13 +50,13 @@
5050
<None Include="App.config" />
5151
</ItemGroup>
5252
<ItemGroup>
53-
<ProjectReference Include="..\LazyAssemblyLoading\LazyAssemblyLoading.csproj">
53+
<ProjectReference Include="..\..\LazyAssemblyLoading\LazyAssemblyLoading.csproj">
5454
<Project>{0b51a58e-0311-4404-873b-ae66e185d1b4}</Project>
5555
<Name>LazyAssemblyLoading</Name>
5656
</ProjectReference>
57-
<ProjectReference Include="..\TestInterfaces\TestInterfaces.csproj">
57+
<ProjectReference Include="..\Interfaces\Interfaces.csproj">
5858
<Project>{aa95ac6b-105d-4a4f-a2b3-00f8495b5582}</Project>
59-
<Name>TestInterfaces</Name>
59+
<Name>Interfaces</Name>
6060
</ProjectReference>
6161
</ItemGroup>
6262
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

Tester/Program.cs Sample/LazyAssemblyLoadingSample/Program.cs

+14-13
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
1-
using LazyAssemblyLoading;
2-
using LazyAssemblyLoading.Serialization;
3-
using System;
4-
using System.Collections.Generic;
1+
using System;
52
using System.ComponentModel.Composition;
63
using System.ComponentModel.Composition.Hosting;
74
using System.Linq;
85
using System.Reflection;
9-
using System.Text;
10-
using System.Threading.Tasks;
11-
using TestInterfaces;
6+
using Interfaces;
7+
using LazyAssemblyLoading;
8+
using LazyAssemblyLoading.Serialization;
129

13-
namespace Tester
10+
namespace LazyAssemblyLoadingSample
1411
{
1512
class Program : MarshalByRefObject
1613
{
1714
private const string DataFile = @"C:\partInformation.xml";
15+
private const string PluginAssemblyName = "PluginAssembly";
16+
private const string PluginAssemblyFileName = "PluginAssembly.dll";
1817

1918
[ImportMany]
2019
public Lazy<IPlugin, IPluginMetadata>[] Plugins { get; set; }
@@ -24,20 +23,22 @@ static void Main(string[] args)
2423
// Serialize the plugin assembly's exports to a file.
2524
// This is done in a different app domain, which is then immediately unloaded so the assembly is not loaded after this line.
2625
// In a real-world application, the serialization process would probably take place in the plugin's post-build event.
27-
CreatePartInformationInAnotherAppDomain("TestAssembly1.dll", DataFile);
26+
CreatePartInformationInAnotherAppDomain(PluginAssemblyFileName, DataFile);
2827

2928
// Compose
3029
var p = new Program();
3130
p.ComposeUsingLazyAssemblyCatalog();
3231

3332
// Plugin metadata is accessible even though the plugin assembly has not been loaded
34-
Console.WriteLine("Plugin name: {0}", p.Plugins[0].Metadata.Name);
35-
Console.WriteLine("Is Loaded: {0}", IsAssemblyLoaded("TestAssembly1"));
33+
string pluginName = p.Plugins[0].Metadata.Name;
34+
Console.WriteLine("Plugin name (taken from metadata): {0}", pluginName);
35+
Console.WriteLine("Is assembly {0} loaded: {1}", PluginAssemblyName, IsAssemblyLoaded(PluginAssemblyName));
3636

3737
// Accessing the plugin itself will implicitly load its assembly
38-
Console.WriteLine("Creating plugin");
38+
Console.WriteLine("Creating plugin {0} by accessing its Value property", pluginName);
3939
var plugin = p.Plugins[0].Value;
40-
Console.WriteLine("Is Loaded: {0}", IsAssemblyLoaded("TestAssembly1"));
40+
Console.WriteLine("Is assembly {0} loaded: {1}", PluginAssemblyName, IsAssemblyLoaded(PluginAssemblyName));
41+
4142
plugin.Initialize();
4243
}
4344

Tester/Properties/AssemblyInfo.cs Sample/LazyAssemblyLoadingSample/Properties/AssemblyInfo.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
// General Information about an assembly is controlled through the following
66
// set of attributes. Change these attribute values to modify the information
77
// associated with an assembly.
8-
[assembly: AssemblyTitle("Tester")]
8+
[assembly: AssemblyTitle("LazyAssemblyLoadingSample")]
99
[assembly: AssemblyDescription("")]
1010
[assembly: AssemblyConfiguration("")]
1111
[assembly: AssemblyCompany("")]
12-
[assembly: AssemblyProduct("Tester")]
12+
[assembly: AssemblyProduct("LazyAssemblyLoadingSample")]
1313
[assembly: AssemblyCopyright("Copyright © 2014")]
1414
[assembly: AssemblyTrademark("")]
1515
[assembly: AssemblyCulture("")]

Sample/PluginAssembly/MyPlugin.cs

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System;
2+
using Interfaces;
3+
4+
namespace PluginAssembly
5+
{
6+
[PluginExport("My Plugin", "1.0")]
7+
public class MyPlugin : IPlugin
8+
{
9+
public void Initialize()
10+
{
11+
Console.WriteLine("MyPlugin initialized!");
12+
}
13+
}
14+
}

TestAssembly1/TestAssembly1.csproj Sample/PluginAssembly/PluginAssembly.csproj

+7-7
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,24 @@
77
<ProjectGuid>{B2404333-8B58-4B1B-B92C-3254C3863B8E}</ProjectGuid>
88
<OutputType>Library</OutputType>
99
<AppDesignerFolder>Properties</AppDesignerFolder>
10-
<RootNamespace>TestAssembly1</RootNamespace>
11-
<AssemblyName>TestAssembly1</AssemblyName>
10+
<RootNamespace>PluginAssembly</RootNamespace>
11+
<AssemblyName>PluginAssembly</AssemblyName>
1212
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
1313
<FileAlignment>512</FileAlignment>
1414
</PropertyGroup>
1515
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1616
<DebugSymbols>true</DebugSymbols>
1717
<DebugType>full</DebugType>
1818
<Optimize>false</Optimize>
19-
<OutputPath>..\Tester\bin\Debug\</OutputPath>
19+
<OutputPath>..\LazyAssemblyLoadingSample\bin\Debug\</OutputPath>
2020
<DefineConstants>DEBUG;TRACE</DefineConstants>
2121
<ErrorReport>prompt</ErrorReport>
2222
<WarningLevel>4</WarningLevel>
2323
</PropertyGroup>
2424
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
2525
<DebugType>pdbonly</DebugType>
2626
<Optimize>true</Optimize>
27-
<OutputPath>..\Tester\bin\Release\</OutputPath>
27+
<OutputPath>..\LazyAssemblyLoadingSample\bin\Release\</OutputPath>
2828
<DefineConstants>TRACE</DefineConstants>
2929
<ErrorReport>prompt</ErrorReport>
3030
<WarningLevel>4</WarningLevel>
@@ -40,13 +40,13 @@
4040
<Reference Include="System.Xml" />
4141
</ItemGroup>
4242
<ItemGroup>
43-
<Compile Include="TestPlugin1.cs" />
43+
<Compile Include="MyPlugin.cs" />
4444
<Compile Include="Properties\AssemblyInfo.cs" />
4545
</ItemGroup>
4646
<ItemGroup>
47-
<ProjectReference Include="..\TestInterfaces\TestInterfaces.csproj">
47+
<ProjectReference Include="..\Interfaces\Interfaces.csproj">
4848
<Project>{aa95ac6b-105d-4a4f-a2b3-00f8495b5582}</Project>
49-
<Name>TestInterfaces</Name>
49+
<Name>Interfaces</Name>
5050
</ProjectReference>
5151
</ItemGroup>
5252
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

TestAssembly1/Properties/AssemblyInfo.cs Sample/PluginAssembly/Properties/AssemblyInfo.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
// General Information about an assembly is controlled through the following
66
// set of attributes. Change these attribute values to modify the information
77
// associated with an assembly.
8-
[assembly: AssemblyTitle("TestAssembly1")]
8+
[assembly: AssemblyTitle("PluginAssembly")]
99
[assembly: AssemblyDescription("")]
1010
[assembly: AssemblyConfiguration("")]
1111
[assembly: AssemblyCompany("")]
12-
[assembly: AssemblyProduct("TestAssembly1")]
12+
[assembly: AssemblyProduct("PluginAssembly")]
1313
[assembly: AssemblyCopyright("Copyright © 2016")]
1414
[assembly: AssemblyTrademark("")]
1515
[assembly: AssemblyCulture("")]

Sample/Sample.sln

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 2013
4+
VisualStudioVersion = 12.0.40629.0
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LazyAssemblyLoadingSample", "LazyAssemblyLoadingSample\LazyAssemblyLoadingSample.csproj", "{393232E7-57CD-4D52-B45D-DF408E8DA5DF}"
7+
ProjectSection(ProjectDependencies) = postProject
8+
{B2404333-8B58-4B1B-B92C-3254C3863B8E} = {B2404333-8B58-4B1B-B92C-3254C3863B8E}
9+
EndProjectSection
10+
EndProject
11+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Interfaces", "Interfaces\Interfaces.csproj", "{AA95AC6B-105D-4A4F-A2B3-00F8495B5582}"
12+
EndProject
13+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PluginAssembly", "PluginAssembly\PluginAssembly.csproj", "{B2404333-8B58-4B1B-B92C-3254C3863B8E}"
14+
EndProject
15+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LazyAssemblyLoading", "..\LazyAssemblyLoading\LazyAssemblyLoading.csproj", "{0B51A58E-0311-4404-873B-AE66E185D1B4}"
16+
EndProject
17+
Global
18+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
19+
Debug|Any CPU = Debug|Any CPU
20+
Release|Any CPU = Release|Any CPU
21+
EndGlobalSection
22+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
23+
{393232E7-57CD-4D52-B45D-DF408E8DA5DF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
24+
{393232E7-57CD-4D52-B45D-DF408E8DA5DF}.Debug|Any CPU.Build.0 = Debug|Any CPU
25+
{393232E7-57CD-4D52-B45D-DF408E8DA5DF}.Release|Any CPU.ActiveCfg = Release|Any CPU
26+
{393232E7-57CD-4D52-B45D-DF408E8DA5DF}.Release|Any CPU.Build.0 = Release|Any CPU
27+
{AA95AC6B-105D-4A4F-A2B3-00F8495B5582}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
28+
{AA95AC6B-105D-4A4F-A2B3-00F8495B5582}.Debug|Any CPU.Build.0 = Debug|Any CPU
29+
{AA95AC6B-105D-4A4F-A2B3-00F8495B5582}.Release|Any CPU.ActiveCfg = Release|Any CPU
30+
{AA95AC6B-105D-4A4F-A2B3-00F8495B5582}.Release|Any CPU.Build.0 = Release|Any CPU
31+
{B2404333-8B58-4B1B-B92C-3254C3863B8E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
32+
{B2404333-8B58-4B1B-B92C-3254C3863B8E}.Debug|Any CPU.Build.0 = Debug|Any CPU
33+
{B2404333-8B58-4B1B-B92C-3254C3863B8E}.Release|Any CPU.ActiveCfg = Release|Any CPU
34+
{B2404333-8B58-4B1B-B92C-3254C3863B8E}.Release|Any CPU.Build.0 = Release|Any CPU
35+
{0B51A58E-0311-4404-873B-AE66E185D1B4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
36+
{0B51A58E-0311-4404-873B-AE66E185D1B4}.Debug|Any CPU.Build.0 = Debug|Any CPU
37+
{0B51A58E-0311-4404-873B-AE66E185D1B4}.Release|Any CPU.ActiveCfg = Release|Any CPU
38+
{0B51A58E-0311-4404-873B-AE66E185D1B4}.Release|Any CPU.Build.0 = Release|Any CPU
39+
EndGlobalSection
40+
GlobalSection(SolutionProperties) = preSolution
41+
HideSolutionNode = FALSE
42+
EndGlobalSection
43+
EndGlobal

TestAssembly1/TestPlugin1.cs

-19
This file was deleted.

0 commit comments

Comments
 (0)