I
I
Ivan Balan2015-02-18 21:17:04
ASP.NET
Ivan Balan, 2015-02-18 21:17:04

What's the difference between OWINContext.Get() and its generic method?

When the application starts in the startup.cs class, I set the contexts of the database, user managers, and so on.
It is done like this:

app.CreatePerOwinContext(ApplicationDbContext.Create);
        app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);

I don't understand why Get is used to create a database context, and a generic method is used for ApplicationUserManager? What is the difference, because we just set a callback function.
And one more thing: I can get these contexts in the application like this:
context.Get<ApplicationDbContext>())
context.GetUserManager<ApplicationUserManager>()

Why is Get used to get the database context and GetUserManager for the user manager, and why can't I write
context.get()?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander S, 2015-02-23
@FirstX

1. habrahabr.ru/post/227351 - point 3, a custom manager is created and the type is not explicitly specified. I assume that in your example - if you remove the brackets with the type of manager, nothing criminal will happen.
2. Apparently because in the second case there is a stricter restriction on the method signature than just Get. And there, it may be necessary to use and call methods that are defined in the UserManager class, parent for all managers. GetUserManager<T>And accordingly, there is a restriction in the method signature where <T> : UserManager.
To be honest, I didn’t look at the source code as it really is, but I’m 90% sure that +/- is so

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question