If I understand your intentions right you are trying to register a type for IFoo and provide a specific implementation of Abstract to it's constructor – the Bar class (that’s why you’re using the identifier). In order to do that you could try the following:
[TestMethod]
public void TestNestedConstructionWithIdentifier()
{
using (var container = new UnityContainer())
{
string identifier = Guid.NewGuid().ToString();
container.RegisterType<Abstract, Bar>(identifier);
container.RegisterType<IFoo, Foo>(identifier, new InjectionConstructor(new ResolvedParameter<Abstract>(identifier)));
var foo = container.Resolve<IFoo>(identifier);
Assert.AreEqual("Bar", foo.GetTypeOfInnerClass().Name);
}
}
As far as I know it’s not possible to tell Unity something like: I’m registering types with the same identifier so when I’m using this identifier to resolve one of those types use types registered with the same identifier while resolving – hope you understand what I mean here ;) The identifier doesn’t group or associate the registered types. Also remember that if you register a type mapping with an identifier you don’t have a default registration. So if you do something like:
container.RegisterType<Abstract, Bar>(identifier);
and then call:
container.Resolve<Abstract>();
you’ll get an exception.
I hope this helps.