forked from aspnet/AspNetKatana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use SystemWebCookieManager/SystemWebChunkingCookieManager by default …
…on SystemWeb
- Loading branch information
1 parent
b286086
commit 500ca47
Showing
14 changed files
with
110 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
src/Microsoft.Owin/Extensions/AppBuilderCookieExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using Microsoft.Owin.Infrastructure; | ||
using Owin; | ||
|
||
namespace Microsoft.Owin | ||
{ | ||
/// <summary> | ||
/// Extension methods for IAppBuilder. | ||
/// </summary> | ||
public static class AppBuilderCookieExtensions | ||
{ | ||
public static void SetCookieManager(this IAppBuilder app, ICookieManager manager) | ||
{ | ||
if (app is null) | ||
{ | ||
throw new ArgumentNullException(nameof(app)); | ||
} | ||
|
||
app.SetCookieManager("infrastructure.CookieManager", manager); | ||
} | ||
|
||
public static void SetChunkingCookieManager(this IAppBuilder app, ICookieManager manager) | ||
{ | ||
if (app is null) | ||
{ | ||
throw new ArgumentNullException(nameof(app)); | ||
} | ||
|
||
app.SetCookieManager("infrastructure.ChunkingCookieManager", manager); | ||
} | ||
|
||
public static ICookieManager GetCookieManager(this IAppBuilder app) | ||
{ | ||
if (app is null) | ||
{ | ||
throw new ArgumentNullException(nameof(app)); | ||
} | ||
|
||
return app.GetCookieManager("infrastructure.CookieManager"); | ||
} | ||
|
||
public static ICookieManager GetChunkingCookieManager(this IAppBuilder app) | ||
{ | ||
if (app is null) | ||
{ | ||
throw new ArgumentNullException(nameof(app)); | ||
} | ||
|
||
return app.GetCookieManager("infrastructure.ChunkingCookieManager"); | ||
} | ||
|
||
private static void SetCookieManager(this IAppBuilder app, string name, ICookieManager manager) | ||
{ | ||
if (manager is null) | ||
{ | ||
app.Properties.Remove(name); | ||
} | ||
else | ||
{ | ||
app.Properties[name] = manager; | ||
} | ||
} | ||
|
||
private static ICookieManager GetCookieManager(this IAppBuilder app, string name) | ||
{ | ||
if (app.Properties.TryGetValue(name, out object value) && value is ICookieManager manager) | ||
{ | ||
return manager; | ||
} | ||
|
||
return null; | ||
} | ||
} | ||
} |