diff --git a/Source/Plugins/FactoryEmployer.Test.cs b/Source/Plugins/FactoryEmployer.Test.cs
index beb5135..ffcd579 100644
--- a/Source/Plugins/FactoryEmployer.Test.cs
+++ b/Source/Plugins/FactoryEmployer.Test.cs
@@ -50,6 +50,16 @@ namespace Nuclex.Support.Plugins {
#endregion // class Derived
+ #region class GenericDerived
+
+ ///
+ /// Generic class derived from the abstract base to serve as concrete product
+ /// for testing the factory employer
+ ///
+ private class GenericDerived : Base { }
+
+ #endregion // class GenericDerived
+
#region class Unrelated
/// Unrelated class used to test the factory employer
@@ -112,6 +122,19 @@ namespace Nuclex.Support.Plugins {
);
}
+ ///
+ /// Tests whether the factory employer throws an exception when it is asked to
+ /// employ a class that requires generic parameters for instantiation
+ ///
+ [Test]
+ public void TestThrowOnEmployGenericClass() {
+ FactoryEmployer testEmployer = new FactoryEmployer();
+
+ Assert.Throws(
+ delegate() { testEmployer.Employ(typeof(GenericDerived<>)); }
+ );
+ }
+
///
/// Tests whether the factory employer can employ a class derived from the product
///
diff --git a/Source/Plugins/FactoryEmployer.cs b/Source/Plugins/FactoryEmployer.cs
index c316330..2fd8ab6 100644
--- a/Source/Plugins/FactoryEmployer.cs
+++ b/Source/Plugins/FactoryEmployer.cs
@@ -91,7 +91,8 @@ namespace Nuclex.Support.Plugins {
public override bool CanEmploy(Type type) {
return
PluginHelper.HasDefaultConstructor(type) &&
- typeof(ProductType).IsAssignableFrom(type);
+ typeof(ProductType).IsAssignableFrom(type) &&
+ !type.ContainsGenericParameters;
}
/// Employs the specified plugin type
@@ -107,6 +108,11 @@ namespace Nuclex.Support.Plugins {
"Cannot employ type because it cannot be cast to the factory's product type"
);
}
+ if(type.ContainsGenericParameters) {
+ throw new ArgumentException(
+ "Cannot employ type because it requires generic parameters", "type"
+ );
+ }
this.employedFactories.Add(new ConcreteFactory(type));
}
diff --git a/Source/Plugins/InstanceEmployer.Test.cs b/Source/Plugins/InstanceEmployer.Test.cs
index 9e546b5..8959f2c 100644
--- a/Source/Plugins/InstanceEmployer.Test.cs
+++ b/Source/Plugins/InstanceEmployer.Test.cs
@@ -50,6 +50,16 @@ namespace Nuclex.Support.Plugins {
#endregion // class Derived
+ #region class GenericDerived
+
+ ///
+ /// Generic class derived from the abstract base to serve as concrete product
+ /// for testing the instance employer
+ ///
+ private class GenericDerived : Base { }
+
+ #endregion // class GenericDerived
+
#region class Unrelated
/// Unrelated class used to test the instance employer
@@ -96,6 +106,19 @@ namespace Nuclex.Support.Plugins {
);
}
+ ///
+ /// Tests whether the instance employer throws an exception when it is asked to
+ /// employ a class that requires generic parameters for instantiation
+ ///
+ [Test]
+ public void TestThrowOnEmployGenericClass() {
+ InstanceEmployer testEmployer = new InstanceEmployer();
+
+ Assert.Throws(
+ delegate() { testEmployer.Employ(typeof(GenericDerived<>)); }
+ );
+ }
+
///
/// Tests whether the instance employer can employ a class derived from the product
///
diff --git a/Source/Plugins/InstanceEmployer.cs b/Source/Plugins/InstanceEmployer.cs
index 5bac170..d8e9dbe 100644
--- a/Source/Plugins/InstanceEmployer.cs
+++ b/Source/Plugins/InstanceEmployer.cs
@@ -62,7 +62,8 @@ namespace Nuclex.Support.Plugins {
public override bool CanEmploy(Type type) {
return
PluginHelper.HasDefaultConstructor(type) &&
- typeof(T).IsAssignableFrom(type);
+ typeof(T).IsAssignableFrom(type) &&
+ !type.ContainsGenericParameters;
}
/// Employs the specified plugin type
diff --git a/Source/Tracking/Transaction.cs b/Source/Tracking/Transaction.cs
index 09ecfaf..29a63e4 100644
--- a/Source/Tracking/Transaction.cs
+++ b/Source/Tracking/Transaction.cs
@@ -246,7 +246,7 @@ namespace Nuclex.Support.Tracking {
}
- /// List of event handler which have subscribed to the ended event
+ /// Event handlers which have subscribed to the ended event
///
/// Does not need to be volatile since it's only accessed inside
///