我已经使用VSCT文件中的此设置为Visual Studio 2015的VSIX包中的工具栏定义了动态组合:
<Combo guid="cmdExplorerToolbarSearchGUID" id="cmdExplorerToolbarSearchID" priority="0x0" type="DynamicCombo"
defaultWidth="50" idCommandList="cmdExplorerToolbarSearchGetListID">
<Parent guid="grpExplorerToolbar3GUID" id="grpExplorerToolbar3ID" />
<CommandFlag>DynamicVisibility</CommandFlag>
<CommandFlag>IconAndText</CommandFlag>
<CommandFlag>StretchHorizontally</CommandFlag>
<Strings>
<CanonicalName>cmdExplorerToolbarSearch</CanonicalName>
<ButtonText>Search</ButtonText>
<ToolTipText>Search elements in the model explorer</ToolTipText>
</Strings>
</Combo>
</Combos>
Run Code Online (Sandbox Code Playgroud)
相应的DynamicStatusMenuCommand实例定义如下:
command = new DynamicStatusMenuCommand(
new EventHandler(this.OnPopUpMenuDisplayAction),
new EventHandler(this.OnCmdExplorerToolbarSearchSelected),
new CommandID(CmdExplorerToolbarSearchGUID, CmdExplorerToolbarSearchID));
commands.Add(command);
command = new DynamicStatusMenuCommand(
new EventHandler(this.OnPopUpMenuDisplayAction),
new EventHandler(this.OnCmdExplorerToolbarSearchGetList),
new CommandID(CmdExplorerToolbarSearchGUID, CmdExplorerToolbarSearchGetListID));
commands.Add(command);
Run Code Online (Sandbox Code Playgroud)
最后OnCmdExplorerToolbarSearchSelected像这样的事件处理程序:
private void OnCmdExplorerToolbarSearchSelected(object sender, EventArgs e)
{
// Process the event arguments
OleMenuCmdEventArgs args = e as OleMenuCmdEventArgs;
if (args != …Run Code Online (Sandbox Code Playgroud) 我正在努力寻找使用 Identity Server 保护多租户 Web API 的正确方法。让我解释。
我们有一个多租户 Web API,它为 ASP.NET MVC 应用程序提供服务。
API 的设置方式是每个端点都包含租户 ID 和订阅 ID,因此它可以知道它应该从哪个订阅/数据库获取数据。:
<server>/tentantId/subscriptionId/(...)
现在想象我有另一个外部应用程序(比如控制台应用程序),使用客户端凭据流,它试图“代表”客户访问某些 API 资源,这意味着将使用特定的tenantId/subscriptionId 对:
<server>/1000/1/products
每次调用到达 API 端点之一时,我都需要验证此特定客户端应用程序是否可以访问该租户/订阅。
如果身份服务器可以作为授权流程的一部分自动执行该检查,那将很有意义。
如果我们为客户添加了某种方式来注册(同意)特定客户端应用程序以访问其订阅上的 Web API,那么我们可能还可以将身份服务器设置为以范围的形式知道这一点,或者至少将该信息包含在声明,以便我们可以通过检查令牌而不是调用外部组件来执行权限检查。
这甚至可能吗?我应该尝试使用范围吗?索赔?
任何人都可以指出我正确的方向吗?
我想简化跨多个项目和团队的代码分析和各自的规则。
我们过去常常通过将分析器导入项目(Microsoft.CodeAnalysis.FxCopAnalyzers 和 StyleCop.Analyzers)的 NuGet 包来实现这一点,并定义了一个规则集来定义 VS 如何处理每个规则(错误、警告等)。
我一直在尝试使用通用的 .editorconfig 文件而不是规则集来设置它。问题是当 .editorconfig 文件从共享文件夹导入时,类似以下的设置似乎被忽略了。
dotnet_diagnostic.CA1062.severity = error
Run Code Online (Sandbox Code Playgroud)
为了对此进行测试,我有一个非常简单的场景来说明问题。
.editorconfig 文件如下:
[*.cs]
dotnet_diagnostic.CA1062.severity = error
#dotnet_code_quality.null_check_validation_methods = NotNull
Run Code Online (Sandbox Code Playgroud)
现在这个文件被导入到一个 csproj 中,如下所示:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<Import Project="..\..\_Shared\Build.props" />
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.4">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
</ItemGroup>
</Project>
Run Code Online (Sandbox Code Playgroud)
Build.props 是这样的:
<Project>
<PropertyGroup>
<SkipDefaultEditorConfigAsAdditionalFile>true</SkipDefaultEditorConfigAsAdditionalFile>
</PropertyGroup>
<ItemGroup Condition="Exists('$(MSBuildThisFileDirectory)\.editorconfig')" >
<AdditionalFiles Include="$(MSBuildThisFileDirectory)\.editorconfig" />
</ItemGroup>
</Project>
Run Code Online (Sandbox Code Playgroud)
以下代码应该会在 CA1062 上触发错误:
public int Calculate(InputData input)
{
SmartGuard.NotNull(nameof(input), input);
if (this.Multiply)
{
return input.Value * 2;
}
else
{
return …Run Code Online (Sandbox Code Playgroud) 我有一个ASP.NET Web API控制器,提供saveAndNew操作.
此类根据预期派生自System.Web.Http.ApiController.
使用SDK的2.1.0版和ApplicationInsights.config中的默认设置正确配置了Application Insights.
如果对上述操作的请求失败 - 例如状态代码为400 - 请求将在App Insights中正确记录.
问题是如果操作SUCCEEDS(状态代码200)没有记录在Application Insights中.
我已经使用Fiddler查看是否向App Insights跟踪服务发出了请求,但事实并非如此.因此问题不在于Azure门户上的Application Insights配置.
我无法弄清楚是什么阻止了对我的Web API控制器操作的所有请求被记录.
有人可以帮忙吗?
我正在使用 SQL Server Management Studio 2016(预览版)提供的 sqlpackage.exe 将数据库发布到 SQL Azure(从以前从本地数据库服务器导出的 bacpac 文件)。
问题是这个数据库是用 S0 服务目标创建的(我认为这是默认的)。
我希望能够使用 sqlpackage.exe 在导入命令中设置目标的服务目标。
我已经搜索了答案,但在此处提供的 sqlpackage.exe 文档中找不到任何内容:
https://msdn.microsoft.com/en-us/library/hh550080(v=vs.103).aspx
我看到管理工作室 UI 允许设置服务目标,我知道它在下面使用 sqlpackage.exe。
任何人都知道如何完成这项工作?
sql-server azure sql-server-2014 sql-server-2016 azure-sql-database