Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

context.ParentType always null #36

Open
drch- opened this issue Sep 15, 2017 · 1 comment
Open

context.ParentType always null #36

drch- opened this issue Sep 15, 2017 · 1 comment

Comments

@drch-
Copy link

drch- commented Sep 15, 2017

dotnet 2.0 Web API project

Startup.cs registration

 config.For<IParentInfo>().Use("WithParent", ctx =>
 {
     Debug.WriteLine(ctx.ParentType?.Name ?? "NULL");
     return new ParentInfo(ctx.ParentType);
 });

ParentInfo is a simple class to capture the context.

public interface IParentInfo
{
    Guid InstanceId { get; }
    Type ParentType { get; }
}

public class ParentInfo : IParentInfo
{
    public Guid InstanceId { get; private set; } = Guid.NewGuid();

    public Type ParentType { get; private set; }

    public ParentInfo(Type parentType)
    {
        ParentType = parentType;
    }
}

ParentType on the context is always null when the API Controller is instantiated. If I reference the StructureMap container directly and resolve a IParentInfo from it, the parent type is passed in correctly as expected.

@khellang
Copy link
Member

What makes you think this is related to StructureMap.Microsoft.DependencyInjection? This looks like an issue with StructureMap itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants