diff --git a/src/Ninject/IHaveBindingRoot.cs b/src/Ninject/IHaveBindingRoot.cs
new file mode 100644
index 00000000..b8b0a30d
--- /dev/null
+++ b/src/Ninject/IHaveBindingRoot.cs
@@ -0,0 +1,15 @@
+using Ninject.Syntax;
+
+namespace Ninject
+{
+ ///
+ /// Indicates the object has a reference to a .
+ ///
+ public interface IHaveBindingRoot
+ {
+ ///
+ /// Gets the associated binding root.
+ ///
+ IBindingRoot BindingRoot { get; }
+ }
+}
\ No newline at end of file
diff --git a/src/Ninject/Ninject.Android.csproj b/src/Ninject/Ninject.Android.csproj
index 6438737d..45f095c2 100644
--- a/src/Ninject/Ninject.Android.csproj
+++ b/src/Ninject/Ninject.Android.csproj
@@ -104,6 +104,7 @@
+
diff --git a/src/Ninject/Ninject.Net45.csproj b/src/Ninject/Ninject.Net45.csproj
index 40001910..deabd048 100644
--- a/src/Ninject/Ninject.Net45.csproj
+++ b/src/Ninject/Ninject.Net45.csproj
@@ -109,6 +109,7 @@
+
diff --git a/src/Ninject/Ninject.WinRT.csproj b/src/Ninject/Ninject.WinRT.csproj
index ae644c44..e728e252 100644
--- a/src/Ninject/Ninject.WinRT.csproj
+++ b/src/Ninject/Ninject.WinRT.csproj
@@ -91,6 +91,7 @@
+
diff --git a/src/Ninject/Ninject.Wpa81.csproj b/src/Ninject/Ninject.Wpa81.csproj
index 5c0d9122..3d3c4605 100644
--- a/src/Ninject/Ninject.Wpa81.csproj
+++ b/src/Ninject/Ninject.Wpa81.csproj
@@ -75,6 +75,7 @@
+
diff --git a/src/Ninject/Ninject.csproj b/src/Ninject/Ninject.csproj
index a6f97d39..d0e86b77 100644
--- a/src/Ninject/Ninject.csproj
+++ b/src/Ninject/Ninject.csproj
@@ -116,6 +116,7 @@
+
diff --git a/src/Ninject/Ninject.iOS-Unified.csproj b/src/Ninject/Ninject.iOS-Unified.csproj
index a7329129..a3ca25bc 100644
--- a/src/Ninject/Ninject.iOS-Unified.csproj
+++ b/src/Ninject/Ninject.iOS-Unified.csproj
@@ -103,6 +103,7 @@
+
diff --git a/src/Ninject/Ninject.iOS.csproj b/src/Ninject/Ninject.iOS.csproj
index 0ce69722..a9173213 100644
--- a/src/Ninject/Ninject.iOS.csproj
+++ b/src/Ninject/Ninject.iOS.csproj
@@ -97,6 +97,7 @@
+
diff --git a/src/Ninject/Planning/Bindings/BindingBuilder.cs b/src/Ninject/Planning/Bindings/BindingBuilder.cs
index e4892c8b..21f0abad 100644
--- a/src/Ninject/Planning/Bindings/BindingBuilder.cs
+++ b/src/Ninject/Planning/Bindings/BindingBuilder.cs
@@ -42,9 +42,10 @@ public class BindingBuilder
/// The binding to build.
/// The ninject configuration settings.
/// The names of the services.
- public BindingBuilder(IBindingConfiguration bindingConfiguration, INinjectSettings settings, string serviceNames)
+ public BindingBuilder(IBindingConfiguration bindingConfiguration, IBindingRoot bindingRoot, INinjectSettings settings, string serviceNames)
{
this.BindingConfiguration = bindingConfiguration;
+ this.BindingRoot = bindingRoot;
this.ServiceNames = serviceNames;
this.BindingConfiguration.ScopeCallback = settings.DefaultScopeCallback;
}
@@ -54,6 +55,11 @@ public BindingBuilder(IBindingConfiguration bindingConfiguration, INinjectSettin
///
public IBindingConfiguration BindingConfiguration { get; private set; }
+ ///
+ /// Gets the associated binding root.
+ ///
+ public IBindingRoot BindingRoot { get; private set; }
+
///
/// Gets the names of the services.
///
@@ -81,7 +87,7 @@ protected IBindingWhenInNamedWithOrOnSyntax InternalTo(Type implementation
StandardProvider.AssignProviderCallback(this.BindingConfiguration, implementation);
this.BindingConfiguration.Target = BindingTarget.Type;
- return new BindingConfigurationBuilder(this.BindingConfiguration, this.ServiceNames);
+ return new BindingConfigurationBuilder(this.BindingConfiguration, this.BindingRoot, this.ServiceNames);
}
///
@@ -97,7 +103,7 @@ protected IBindingWhenInNamedWithOrOnSyntax InternalToConfigura
this.BindingConfiguration.Target = BindingTarget.Constant;
this.BindingConfiguration.ScopeCallback = StandardScopeCallbacks.Singleton;
- return new BindingConfigurationBuilder(this.BindingConfiguration, this.ServiceNames);
+ return new BindingConfigurationBuilder(this.BindingConfiguration, this.BindingRoot, this.ServiceNames);
}
///
@@ -112,7 +118,7 @@ protected IBindingWhenInNamedWithOrOnSyntax InternalToMethod callbackProvider;
this.BindingConfiguration.Target = BindingTarget.Method;
- return new BindingConfigurationBuilder(this.BindingConfiguration, this.ServiceNames);
+ return new BindingConfigurationBuilder(this.BindingConfiguration, this.BindingRoot, this.ServiceNames);
}
///
@@ -126,7 +132,7 @@ protected IBindingWhenInNamedWithOrOnSyntax InternalToProvider<
this.BindingConfiguration.ProviderCallback = ctx => provider;
this.BindingConfiguration.Target = BindingTarget.Provider;
- return new BindingConfigurationBuilder(this.BindingConfiguration, this.ServiceNames);
+ return new BindingConfigurationBuilder(this.BindingConfiguration, this.BindingRoot, this.ServiceNames);
}
///
@@ -142,7 +148,7 @@ protected IBindingWhenInNamedWithOrOnSyntax ToProviderInternal<
this.BindingConfiguration.ProviderCallback = ctx => ctx.Kernel.Get();
this.BindingConfiguration.Target = BindingTarget.Provider;
- return new BindingConfigurationBuilder(this.BindingConfiguration, this.ServiceNames);
+ return new BindingConfigurationBuilder(this.BindingConfiguration, this.BindingRoot, this.ServiceNames);
}
///
@@ -157,7 +163,7 @@ protected IBindingWhenInNamedWithOrOnSyntax ToProviderInternal(Type provid
this.BindingConfiguration.ProviderCallback = ctx => ctx.Kernel.Get(providerType) as IProvider;
this.BindingConfiguration.Target = BindingTarget.Provider;
- return new BindingConfigurationBuilder(this.BindingConfiguration, this.ServiceNames);
+ return new BindingConfigurationBuilder(this.BindingConfiguration, this.BindingRoot, this.ServiceNames);
}
///
@@ -179,7 +185,7 @@ protected IBindingWhenInNamedWithOrOnSyntax InternalToConstruct
this.BindingConfiguration.Target = BindingTarget.Type;
this.AddConstructorArguments(ctorExpression, newExpression.Parameters[0]);
- return new BindingConfigurationBuilder(this.BindingConfiguration, this.ServiceNames);
+ return new BindingConfigurationBuilder(this.BindingConfiguration, this.BindingRoot, this.ServiceNames);
}
///
diff --git a/src/Ninject/Planning/Bindings/BindingBuilder{T1,T2,T3,T4}.cs b/src/Ninject/Planning/Bindings/BindingBuilder{T1,T2,T3,T4}.cs
index fe7bc601..8b1821ce 100644
--- a/src/Ninject/Planning/Bindings/BindingBuilder{T1,T2,T3,T4}.cs
+++ b/src/Ninject/Planning/Bindings/BindingBuilder{T1,T2,T3,T4}.cs
@@ -44,8 +44,8 @@ public class BindingBuilder : BindingBuilder, IBindingToSyntaxThe binding to build.
/// The ninject configuration settings.
/// The names of the services.
- public BindingBuilder(IBindingConfiguration bindingConfigurationConfiguration, INinjectSettings settings, string serviceNames)
- : base(bindingConfigurationConfiguration, settings, serviceNames)
+ public BindingBuilder(IBindingConfiguration bindingConfigurationConfiguration, IBindingRoot bindingRoot, INinjectSettings settings, string serviceNames)
+ : base(bindingConfigurationConfiguration, bindingRoot, settings, serviceNames)
{
}
#pragma warning restore 1584
diff --git a/src/Ninject/Planning/Bindings/BindingBuilder{T1,T2,T3}.cs b/src/Ninject/Planning/Bindings/BindingBuilder{T1,T2,T3}.cs
index c79633b5..4d3fbd95 100644
--- a/src/Ninject/Planning/Bindings/BindingBuilder{T1,T2,T3}.cs
+++ b/src/Ninject/Planning/Bindings/BindingBuilder{T1,T2,T3}.cs
@@ -43,8 +43,8 @@ public class BindingBuilder : BindingBuilder, IBindingToSyntaxThe binding to build.
/// The ninject configuration settings.
/// The names of the services.
- public BindingBuilder(IBindingConfiguration bindingConfigurationConfiguration, INinjectSettings settings, string serviceNames)
- : base(bindingConfigurationConfiguration, settings, serviceNames)
+ public BindingBuilder(IBindingConfiguration bindingConfigurationConfiguration, IBindingRoot bindingRoot, INinjectSettings settings, string serviceNames)
+ : base(bindingConfigurationConfiguration, bindingRoot, settings, serviceNames)
{
}
#pragma warning restore 1584
diff --git a/src/Ninject/Planning/Bindings/BindingBuilder{T1,T2}.cs b/src/Ninject/Planning/Bindings/BindingBuilder{T1,T2}.cs
index bda8a3fa..d7f1b7d1 100644
--- a/src/Ninject/Planning/Bindings/BindingBuilder{T1,T2}.cs
+++ b/src/Ninject/Planning/Bindings/BindingBuilder{T1,T2}.cs
@@ -42,8 +42,8 @@ public class BindingBuilder : BindingBuilder, IBindingToSyntax
/// The binding to build.
/// The ninject configuration settings.
/// The names of the services.
- public BindingBuilder(IBindingConfiguration bindingConfigurationConfiguration, INinjectSettings settings, string serviceNames)
- : base(bindingConfigurationConfiguration, settings, serviceNames)
+ public BindingBuilder(IBindingConfiguration bindingConfigurationConfiguration, IBindingRoot bindingRoot, INinjectSettings settings, string serviceNames)
+ : base(bindingConfigurationConfiguration, bindingRoot, settings, serviceNames)
{
}
#pragma warning restore 1584
diff --git a/src/Ninject/Planning/Bindings/BindingBuilder{T1}.cs b/src/Ninject/Planning/Bindings/BindingBuilder{T1}.cs
index 1b1f41f0..ef7fc619 100644
--- a/src/Ninject/Planning/Bindings/BindingBuilder{T1}.cs
+++ b/src/Ninject/Planning/Bindings/BindingBuilder{T1}.cs
@@ -43,8 +43,8 @@ public class BindingBuilder : BindingBuilder, IBindingToSyntax
/// The binding to build.
/// The ninject configuration settings.
/// The names of the services.
- public BindingBuilder(IBinding binding, INinjectSettings settings, string serviceNames)
- : base(binding.BindingConfiguration, settings, serviceNames)
+ public BindingBuilder(IBinding binding, IBindingRoot bindingRoot, INinjectSettings settings, string serviceNames)
+ : base(binding.BindingConfiguration, bindingRoot, settings, serviceNames)
{
this.Binding = binding;
}
@@ -64,7 +64,7 @@ public IBindingWhenInNamedWithOrOnSyntax ToSelf()
StandardProvider.AssignProviderCallback(this.BindingConfiguration, this.Binding.Service);
this.Binding.Target = BindingTarget.Self;
- return new BindingConfigurationBuilder(this.Binding.BindingConfiguration, this.ServiceNames);
+ return new BindingConfigurationBuilder(this.Binding.BindingConfiguration, this.BindingRoot, this.ServiceNames);
}
///
diff --git a/src/Ninject/Planning/Bindings/BindingConfigurationBuilder.cs b/src/Ninject/Planning/Bindings/BindingConfigurationBuilder.cs
index 2df02af3..9a99931a 100644
--- a/src/Ninject/Planning/Bindings/BindingConfigurationBuilder.cs
+++ b/src/Ninject/Planning/Bindings/BindingConfigurationBuilder.cs
@@ -52,14 +52,20 @@ public class BindingConfigurationBuilder : IBindingConfigurationSyntax
///
public IBindingConfiguration BindingConfiguration { get; private set; }
+ ///
+ /// Gets the associated binding root.
+ ///
+ public IBindingRoot BindingRoot { get; private set; }
+
///
/// Initializes a new instance of the BindingBuilder<T> class.
///
/// The binding configuration to build.
/// The names of the configured services.
- public BindingConfigurationBuilder(IBindingConfiguration bindingConfiguration, string serviceNames)
+ public BindingConfigurationBuilder(IBindingConfiguration bindingConfiguration, IBindingRoot bindingRoot, string serviceNames)
{
this.BindingConfiguration = bindingConfiguration;
+ this.BindingRoot = bindingRoot;
this.serviceNames = serviceNames;
}
diff --git a/src/Ninject/ReadonlyKernel.cs b/src/Ninject/ReadonlyKernel.cs
index 4873dc9a..044c647a 100644
--- a/src/Ninject/ReadonlyKernel.cs
+++ b/src/Ninject/ReadonlyKernel.cs
@@ -327,7 +327,7 @@ private List GetBindingsFromFirstResolverThatReturnsAtLeastOneBinding(
private void AddReadonlyKernelBinding(T readonlyKernel, Multimap bindings)
{
var binding = new Binding(typeof(T));
- new BindingBuilder(binding, this.Settings, typeof(T).Format()).ToConstant(readonlyKernel);
+ new BindingBuilder(binding, null, this.Settings, typeof(T).Format()).ToConstant(readonlyKernel);
bindings.Add(typeof(T), binding);
}
diff --git a/src/Ninject/Syntax/BindingRoot.cs b/src/Ninject/Syntax/BindingRoot.cs
index b8cffb2c..9b4319b5 100644
--- a/src/Ninject/Syntax/BindingRoot.cs
+++ b/src/Ninject/Syntax/BindingRoot.cs
@@ -57,7 +57,7 @@ public IBindingToSyntax Bind()
var binding = new Binding(service);
this.AddBinding(binding);
- return new BindingBuilder(binding, this.Settings, service.Format());
+ return new BindingBuilder(binding, this, this.Settings, service.Format());
#endif
}
@@ -77,7 +77,7 @@ public IBindingToSyntax Bind()
this.AddBinding(new Binding(typeof(T2), firstBinding.BindingConfiguration));
var serviceNames = new[] { typeof(T1).Format(), typeof(T2).Format() };
- return new BindingBuilder(firstBinding.BindingConfiguration, this.Settings, string.Join(", ", serviceNames));
+ return new BindingBuilder(firstBinding.BindingConfiguration, this, this.Settings, string.Join(", ", serviceNames));
#endif
}
@@ -99,7 +99,7 @@ public IBindingToSyntax Bind()
this.AddBinding(new Binding(typeof(T3), firstBinding.BindingConfiguration));
var serviceNames = new[] { typeof(T1).Format(), typeof(T2).Format(), typeof(T3).Format() };
- return new BindingBuilder(firstBinding.BindingConfiguration, this.Settings, string.Join(", ", serviceNames));
+ return new BindingBuilder(firstBinding.BindingConfiguration, this, this.Settings, string.Join(", ", serviceNames));
#endif
}
@@ -123,7 +123,7 @@ public IBindingToSyntax Bind()
this.AddBinding(new Binding(typeof(T4), firstBinding.BindingConfiguration));
var serviceNames = new[] { typeof(T1).Format(), typeof(T2).Format(), typeof(T3).Format(), typeof(T4).Format() };
- return new BindingBuilder(firstBinding.BindingConfiguration, this.Settings, string.Join(", ", serviceNames));
+ return new BindingBuilder(firstBinding.BindingConfiguration, this, this.Settings, string.Join(", ", serviceNames));
#endif
}
@@ -151,7 +151,7 @@ public IBindingToSyntax