Click here to Skip to main content
15,890,438 members
Home / Discussions / C#
   

C#

 
AnswerRe: Unzip file from resources Pin
OriginalGriff21-Aug-18 19:34
mveOriginalGriff21-Aug-18 19:34 
AnswerRe: Unzip file from resources Pin
Daniel Pfeffer21-Aug-18 20:52
professionalDaniel Pfeffer21-Aug-18 20:52 
GeneralRe: Unzip file from resources Pin
JCompiler22-Aug-18 2:33
JCompiler22-Aug-18 2:33 
GeneralRe: Unzip file from resources Pin
Richard Deeming22-Aug-18 2:43
mveRichard Deeming22-Aug-18 2:43 
GeneralRe: Unzip file from resources Pin
JCompiler22-Aug-18 3:05
JCompiler22-Aug-18 3:05 
GeneralRe: Unzip file from resources Pin
JCompiler22-Aug-18 4:30
JCompiler22-Aug-18 4:30 
GeneralRe: Unzip file from resources Pin
Richard Deeming22-Aug-18 4:42
mveRichard Deeming22-Aug-18 4:42 
AnswerRe: Unzip file from resources Pin
jschell25-Aug-18 4:36
jschell25-Aug-18 4:36 
GeneralRe: Unzip file from resources Pin
Richard Deeming28-Aug-18 3:06
mveRichard Deeming28-Aug-18 3:06 
QuestionUse custom services inside OAuthorizationProviders Pin
Member 1204569221-Aug-18 3:39
Member 1204569221-Aug-18 3:39 
AnswerRe: Use custom services inside OAuthorizationProviders Pin
Pete O'Hanlon21-Aug-18 4:01
mvePete O'Hanlon21-Aug-18 4:01 
GeneralRe: Use custom services inside OAuthorizationProviders Pin
Member 1204569221-Aug-18 4:09
Member 1204569221-Aug-18 4:09 
GeneralRe: Use custom services inside OAuthorizationProviders Pin
dan!sh 21-Aug-18 4:41
professional dan!sh 21-Aug-18 4:41 
GeneralRe: Use custom services inside OAuthorizationProviders Pin
Member 1204569221-Aug-18 8:34
Member 1204569221-Aug-18 8:34 
GeneralRe: Use custom services inside OAuthorizationProviders Pin
Dave Kreskowiak21-Aug-18 9:29
mveDave Kreskowiak21-Aug-18 9:29 
GeneralRe: Use custom services inside OAuthorizationProviders Pin
OriginalGriff21-Aug-18 4:59
mveOriginalGriff21-Aug-18 4:59 
GeneralRe: Use custom services inside OAuthorizationProviders Pin
Member 1204569221-Aug-18 8:30
Member 1204569221-Aug-18 8:30 
GeneralRe: Use custom services inside OAuthorizationProviders Pin
OriginalGriff21-Aug-18 8:38
mveOriginalGriff21-Aug-18 8:38 
GeneralRe: Use custom services inside OAuthorizationProviders Pin
Member 1204569221-Aug-18 20:27
Member 1204569221-Aug-18 20:27 
AnswerRe: Use custom services inside OAuthorizationProviders Pin
Richard Deeming22-Aug-18 2:40
mveRichard Deeming22-Aug-18 2:40 
It sounds like you're trying to use Dependency Injection with your provider instances. It's not simple, but there are a few suggestions in this StackOverflow thread[^].

For example:
C#
public class Startup
{
    public void Configuration(IAppBuilder app)
    {
        var container = SimpleInjectorConfig.Register();

        GlobalConfiguration.Configure(WebApiConfig.Register);

        Func<IAuthService> authServiceFactory = () => container.GetInstance<IAuthService>();

        var OAuthServerOptions = new OAuthAuthorizationServerOptions
        {
            AllowInsecureHttp = true,
            TokenEndpointPath = new PathString("/token"),
            AccessTokenExpireTimeSpan = TimeSpan.FromDays(1),
            Provider = new SimpleAuthorizationServerProvider(authServiceFactory),
            RefreshTokenProvider = new SimpleRefreshTokenProvider(authServiceFactory),
        };

        // Token Generation
        app.UseOAuthAuthorizationServer(OAuthServerOptions);
        app.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions());
    }
}

Your provider classes will need to be changed to take a Func<IAuthService> delegate instead of an IAuthService instance. Whenever they need an IAuthService instance, they call the factory delegate.
C#
public class SimpleAuthorizationServerProvider : OAuthAuthorizationServerProvider
{
    private readonly Func<IAuthService> _authServiceFactory;

    public SimpleAuthorizationServerProvider(Func<IAuthService> authServiceFactory)
    {
        _authServiceFactory = authServiceFactory;
    }
    
    ...
    
    // Eg:
    public override Task GrantAuthorizationCode(OAuthGrantAuthorizationCodeContext context)
    {
        IAuthService authService = _authServiceFactory();
        ...
    }




"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer

Questionhelp to solve C# codes Pin
Ali 2Fan19-Aug-18 9:32
Ali 2Fan19-Aug-18 9:32 
AnswerRe: help to solve C# codes Pin
OriginalGriff19-Aug-18 9:34
mveOriginalGriff19-Aug-18 9:34 
AnswerRe: help to solve C# codes Pin
Dave Kreskowiak20-Aug-18 10:49
mveDave Kreskowiak20-Aug-18 10:49 
QuestionHow to Merge DataGridView Cell in Winforms ? Pin
Member 245846715-Aug-18 17:32
Member 245846715-Aug-18 17:32 
AnswerRe: How to Merge DataGridView Cell in Winforms ? Pin
dan!sh 16-Aug-18 3:20
professional dan!sh 16-Aug-18 3:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.