-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #295 from microsoft/zhiyuanliang/preview-merge-fro…
…m-main preview merge from main
- Loading branch information
Showing
174 changed files
with
134,336 additions
and
9,741 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,7 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
// | ||
using Consoto.Banking.AccountService.FeatureFilters; | ||
|
||
namespace Consoto.Banking.AccountService | ||
class AccountServiceContext : IAccountContext | ||
{ | ||
class AccountServiceContext : IAccountContext | ||
{ | ||
public string AccountId { get; set; } | ||
} | ||
} | ||
public string AccountId { get; set; } | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,27 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
// | ||
using Consoto.Banking.AccountService.FeatureFilters; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.FeatureManagement; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
|
||
namespace Consoto.Banking.AccountService.FeatureManagement | ||
/// <summary> | ||
/// A filter that uses the feature management context to ensure that the current task has the notion of an account id, and that the account id is allowed. | ||
/// This filter will only be executed if an object implementing <see cref="IAccountContext"/> is passed in during feature evaluation. | ||
/// </summary> | ||
[FilterAlias("AccountId")] | ||
class AccountIdFilter : IContextualFeatureFilter<IAccountContext> | ||
{ | ||
/// <summary> | ||
/// A filter that uses the feature management context to ensure that the current task has the notion of an account id, and that the account id is allowed. | ||
/// This filter will only be executed if an object implementing <see cref="IAccountContext"/> is passed in during feature evaluation. | ||
/// </summary> | ||
[FilterAlias("AccountId")] | ||
class AccountIdFilter : IContextualFeatureFilter<IAccountContext> | ||
public Task<bool> EvaluateAsync(FeatureFilterEvaluationContext featureEvaluationContext, IAccountContext accountContext) | ||
{ | ||
public Task<bool> EvaluateAsync(FeatureFilterEvaluationContext featureEvaluationContext, IAccountContext accountContext) | ||
if (string.IsNullOrEmpty(accountContext?.AccountId)) | ||
{ | ||
if (string.IsNullOrEmpty(accountContext?.AccountId)) | ||
{ | ||
throw new ArgumentNullException(nameof(accountContext)); | ||
} | ||
throw new ArgumentNullException(nameof(accountContext)); | ||
} | ||
|
||
var allowedAccounts = new List<string>(); | ||
var allowedAccounts = new List<string>(); | ||
|
||
featureEvaluationContext.Parameters.Bind("AllowedAccounts", allowedAccounts); | ||
featureEvaluationContext.Parameters.Bind("AllowedAccounts", allowedAccounts); | ||
|
||
return Task.FromResult(allowedAccounts.Contains(accountContext.AccountId)); | ||
} | ||
return Task.FromResult(allowedAccounts.Contains(accountContext.AccountId)); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,10 +1,7 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
// | ||
namespace Consoto.Banking.AccountService.FeatureFilters | ||
public interface IAccountContext | ||
{ | ||
public interface IAccountContext | ||
{ | ||
string AccountId { get; } | ||
} | ||
string AccountId { get; } | ||
} |
Oops, something went wrong.