diff --git a/src/DotNurse.Injector/DotNurseInjectorOptions.cs b/src/DotNurse.Injector/DotNurseInjectorOptions.cs
index 5432277..e3e49ab 100644
--- a/src/DotNurse.Injector/DotNurseInjectorOptions.cs
+++ b/src/DotNurse.Injector/DotNurseInjectorOptions.cs
@@ -11,12 +11,6 @@ public class DotNurseInjectorOptions
///
public Assembly Assembly { get; set; }
- ///
- /// Filter objects by name with given algorithm.
- ///
- [Obsolete("This property has a typo. Please use SelectImplementation property instead of this.")]
- public Func SelectImplementtion { get => SelectImplementation; set => SelectImplementation = value; }
-
///
/// Filter objects by name with given algorithm.
///
@@ -31,4 +25,9 @@ public class DotNurseInjectorOptions
/// Filters only objects which inherits directly from this type. For ex.: typeof(BaseRepository<>)
///
public Type ImplementationBase { get; set; }
+
+ ///
+ /// Register the type as self too. True by default.
+ ///
+ public bool SelfRegister { get; set; } = true;
}
diff --git a/src/DotNurse.Injector/Startup.cs b/src/DotNurse.Injector/Startup.cs
index 357793f..fe19f2c 100644
--- a/src/DotNurse.Injector/Startup.cs
+++ b/src/DotNurse.Injector/Startup.cs
@@ -80,7 +80,7 @@ public static IServiceCollection RegisterTypes(
foreach (var type in types)
{
- if (type.GetCustomAttribute() != null || type.GetCustomAttribute() != null)
+ if (type.GetCustomAttribute() != null)
continue;
if (!options.SelectImplementation(type))
@@ -94,7 +94,10 @@ public static IServiceCollection RegisterTypes(
var interfaces = type.GetInterfaces();
- services.Add(new ServiceDescriptor(type, type, lifetime));
+ if (options.SelfRegister)
+ {
+ services.Add(new ServiceDescriptor(type, type, lifetime));
+ }
if (interfaces.Length == 1)
{