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
byte[] secret = Encoding.UTF8.GetBytes("230aSD123Rqasf!@#wt324EWHgwqeafvASD@#qweTGWesd"); | |
var credentials = new SigningCredentials(new SymmetricSecurityKey(secret), SecurityAlgorithms.HmacSha256); |
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
byte[] secret = Encoding.UTF8.GetBytes("230aSD123Rqasf!@#wt324EWHgwqeafvASD@#qweTGWesd"); | |
var tokenProvider = | |
new JwtTokenProvider(new TokenProviderOptions("karazhan.org", "api.karazhan.org", | |
new SigningCredentials(new SymmetricSecurityKey(secret), SecurityAlgorithms.HmacSha256))); | |
string userId = "aevitas"; | |
var timeStamp = DateTimeOffset.UtcNow; | |
var claims = new[] | |
{ |
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
public class JwtValidationResult | |
{ | |
public JwtValidationResult(bool isValid, SecurityToken securityToken, IReadOnlyList<Claim> claims, | |
IReadOnlyList<ClaimsIdentity> identities) | |
{ | |
IsValid = isValid; | |
SecurityToken = securityToken; | |
Claims = claims; | |
Identities = identities; | |
} |
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
SecurityToken validatedToken; | |
var claimsPrincipal = _handler.ValidateToken(token, validationParameters, out validatedToken); | |
var validationResult = new JwtValidationResult(validatedToken != null, validatedToken, | |
claimsPrincipal.Claims.ToList(), claimsPrincipal.Identities.ToList()); | |
return validationResult; |
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
public bool IsValidResults(IEnumerable<AuthenticationResult> values) | |
{ | |
if (values == null) | |
return false; | |
return values.All(IsValidResult); | |
bool IsValidResult(AuthenticationResult result) | |
{ | |
if (result == null) |
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
private bool HasSpecificDiscipline(out CharacterDiscipline discipline) | |
{ | |
var advancedClass = BuddyTor.Me.AdvancedClass; | |
if (advancedClass == AdvancedClass.None) | |
{ | |
discipline = CharacterDiscipline.None; | |
return false; | |
} |
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
List<string> strings = new List<string> | |
{ | |
null, | |
"hello", | |
"world" | |
}; |
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
public Maybe<int> TryParse(string value) | |
{ | |
if (int.TryParse(value, out int num)) | |
return Maybe.OfValueType(num); | |
return Maybe<int>.NoValue; | |
} |
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
public Task<bool> One() | |
{ | |
Class1.\u003COne\u003Ed__0 stateMachine = new Class1.\u003COne\u003Ed__0(); | |
stateMachine.\u003C\u003E4__this = this; | |
stateMachine.\u003C\u003Et__builder = AsyncTaskMethodBuilder<bool>.Create(); | |
stateMachine.\u003C\u003E1__state = -1; | |
stateMachine.\u003C\u003Et__builder.Start<Class1.\u003COne\u003Ed__0>(ref stateMachine); | |
return stateMachine.\u003C\u003Et__builder.Task; | |
} |
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
public async Task<bool> One() | |
{ | |
return true; | |
} | |
public Task<bool> Two() | |
{ | |
return Task.FromResult(true); | |
} |