我有以下简单的Hub类来列出使用注入用户服务的用户.使用NinjectSignalRDependencyResolver的启动类.非常简单的客户端脚本.
[HubName("dashboardHub")]
public class DashboardHub : Hub
{
private readonly IUserService _users;
public DashboardHub(IUserService users)
{
_users = users;
}
public void Initialize()
{
var users = _users.ListUsers();
Clients.All.UpdateStatus(users);
}
}
Run Code Online (Sandbox Code Playgroud)
var kernel = new StandardKernel();
var resolver = new NinjectSignalRDependencyResolver(kernel);
var config = new HubConfiguration()
{
Resolver = resolver,
};
app.MapSignalR(config);
Run Code Online (Sandbox Code Playgroud)
public class NinjectSignalRDependencyResolver : DefaultDependencyResolver
{
private readonly IKernel _kernel;
public NinjectSignalRDependencyResolver(IKernel kernel)
{
_kernel = kernel;
}
public override object GetService(Type serviceType)
{
return …Run Code Online (Sandbox Code Playgroud) 我正在使用Visual Studio Team Services来构建.NET解决方案.我有一项Nuget Installer任务是恢复配置如下的解决方案的包:
Nuget.configfile有2个包源 - 一个是nuget.org(v2),另一个是自定义源(Nuget Server v2.5.40416.9020).来自nuget.org订阅源的所有包都已恢复,但自定义订阅源中的包不是,对于自定义订阅源中的每个包,都会出现如下错误消息:
无法找到包'xyz'的版本'abc'
错误:
[错误]错误:C:\ a_tasks\NuGetInstaller_333b11bd-d341-40d9-afcf-b32d5ce6f23b\0.2.22 \node_modules \nuget-task-common\NuGet\3.3.0\NuGet.exe失败,返回码:1 [错误]软件包无法安装
这在1天或2天前工作正常.
在当地一切似乎都很好.此外,我尝试使用nuget版本3.5.0和自定义版本nuget.exe,但没有成功.
有什么建议?
continuous-integration nuget visual-studio-2013 nuget-package-restore azure-devops
我有一个包含单元测试项目的解决方案。我正在使用 NUnit v3.10.1 和 NUnit3TestAdapter v3.10.0。
有没有办法配置测试名称在 Visual Studio Team Services (VSTS) 中的显示方式,也许显示测试类名称?目前它只显示测试名称:
很难理解哪个测试属于哪个类。在这种情况下,我至少有 2 个具有相同测试名称的测试类。
使用 Reshaper 的测试运行器运行相同的测试,很容易理解哪些测试属于哪些类:
我曾尝试设置TestName的的的TestFixture属性的属性或设置Description的的测试属性,没有运气:
[TestFixture(TestName = "MemoryCacheManagerTests_TryGetItem", TestOf = typeof(MemoryCacheManager))]
public class MemoryCacheManagerTests_TryGetItem : MemoryCacheManagerTests
{
[Test(Description = "MemoryCacheManagerTests_TryGetItem_WithInvalidCacheKey_ShouldThrowArgumentException")]
[TestCaseSource(typeof(InvalidCacheKeyTestCases))]
public void WithInvalidCacheKey_ShouldThrowArgumentException(string key)
{
// ...
}
}
Run Code Online (Sandbox Code Playgroud)
那么如何在 VSTS 上配置测试的名称呢?
我正在尝试使用 .NET 客户端库查找配置为使用特定代理池的所有版本和版本。
假设agentPoolId,我可以得到所有这样的构建定义:
// _connection is of type VssConnection
using (var buildClient = _connection.GetClient<BuildHttpClient>())
{
List<BuildDefinitionReference> allBuilds = await buildClient.GetDefinitionsAsync(projectName, top: 1000, queryOrder: DefinitionQueryOrder.DefinitionNameAscending);
List<BuildDefinitionReference> builds = allBuilds.Where(x => HasAgentPoolId(x, agentPoolId)).ToList();
}
private bool HasAgentPoolId(BuildDefinitionReference buildDefinition, int agentPoolId)
{
TaskAgentPoolReference pool = buildDefinition?.Queue?.Pool;
if (pool == null)
{
return false;
}
return pool.Id.Equals(agentPoolId);
}
Run Code Online (Sandbox Code Playgroud)
但是我找不到一种方法来查找具有一个或多个环境配置为使用特定代理的发布定义。有什么建议吗?
我有一个 .NET Core 构建管道,用于在 Azure DevOps 上运行一些测试。每个环境的设置都存储在配置文件中,例如:
appsettings.jsonappsettings.qa.jsonappsettings.test.json构建是非常基础的——它包含一个dotnet restore,dotnet build和dotnet test任务:
在ASPNETCORE_ENVIRONMENT环境变量设置的变量构建管道的部分:
这些构建在包含多个构建代理(私有,非托管)的 VM 上运行。
现在是奇怪的部分 -有时构建会选择错误的设置!.
经过一些调查并添加更多日志记录后,我们意识到ASPNETCORE_ENVIRONMENTvalue 有时是Development-Selfhost,而不是QA。该值似乎来自launchsettings.json测试项目引用的项目文件:
{
"profiles": {
"MyProject.PublicApi": {
"commandName": "Project",
"launchBrowser": false,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development-Selfhost"
},
"applicationUrl": "http://localhost:5028/"
}
}
}
Run Code Online (Sandbox Code Playgroud)
据在ASP.NET核心使用多个环境,launchSettings.json当一个应用程序与启动时使用的文件dotnet run:
launchSettings.json如果可用,则读取。覆盖环境变量中的environmentVariables设置launchSettings.json。
添加launchSettings.jsonto.gitignore解决了我的问题,但如果我不在 …
我收到异常 无法将类型“MySomeTypeThatImplementsISomeInterfaceAndIsPassedAs[T]ToTheClass”转换为类型“ISomeInterface”。LINQ to Entities 仅支持强制转换实体数据模型基元类型。
我的存储库看起来像
public interface IRepository<T>
{
IQueryable<T> Get(System.Linq.Expressions.Expression<System.Func<T, bool>> Query);
}
Run Code Online (Sandbox Code Playgroud)
另外,我有服务类
public abstract class FinanceServiceBase<TAccount, TParcel, TPayment>
where TAccount : IAccount
where TParcel : IParcel
where TPayment : IPayment
{
//...
IRepository<TPayment> ParcelRepository {get; private set;}
public bool MakePayment(TPayment payment)
{
//...
ParcelRepository.Get(p => p.ParcelId == 2);
// here my exception is thrown
// **p.ParcelId is in IParcel**
//...
}
}
//...
Run Code Online (Sandbox Code Playgroud)
有了这门课,我可以控制很多关于财务的事情,而无需为其他程序重写代码。我用 3 个泛型参数做了这个类,因为我不能使用 IRepository 因为我的存储库不能<out T>
ParcelId 是 Int32
TParcel …
使用Entity Framework和MVC2,我有一系列日期文本框,我想以短日期格式显示模型中的数据,但我必须使用Html.TextBoxFor才能使更新代码正常工作(尝试使用HTML) .Textbox数据永远不会保存到模型中).
<%: Html.TextBoxFor(model => model.Item.Date, String.Format("{0:d}", Model.Item.Date))%>
Run Code Online (Sandbox Code Playgroud)
我已经尝试过操作字符串格式表达式,并将元数据添加到映射到Entity Framework模型类的部分类中,但是我仍然在表单渲染中填充以下文本框:
01/01/2011 00:00:00
Run Code Online (Sandbox Code Playgroud)
而不是
01/01/2011
Run Code Online (Sandbox Code Playgroud) Where<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate);
Run Code Online (Sandbox Code Playgroud)
我将参数传递给Where方法,如下所示:f => f.Id > 4.我可以传递委托方法而不是f.Id > 4吗?
我有两张桌子:
DocumentTypeId是引用DocumentTypes表的外键.即所有文档都可以分配一个类型.
我有两节课:
public class Document
{
public string Id { get; set; }
public string Title { get; set; }
public DocumentType DocumentType { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
和
public class DocumentType
{
public string Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我有一个配置
internal class DocumentsConfiguration : EntityTypeConfiguration<Document>
{
public DocumentsConfiguration()
{
ToTable("Documents");
HasKey(document => document.Id);
Property(document => document.Id).HasColumnName("Id");
HasRequired(document => document.DocumentType);//????????
Property(document => …Run Code Online (Sandbox Code Playgroud) 在公司网络中使用代理(至少在Windows计算机上)使用Pub dart存在一个已知问题。您甚至无法运行示例,因为它们使用pub来获取软件包。如果您是先从没有代理的网络上运行示例,则从代理后面运行它们时,它们的工作原理非常好(软件包已安装)。
我的问题是:如何手动安装软件包?
例如,我当然可以从git中获得它们,但是之后要做什么才能“安装”它们,我对Dart安装目录,用户目录和似乎必要的符号链接中的内容感到困惑。可能是我错过了一些东西,但是我没有找到任何相关的好文档。
谢谢,
F。
c# ×7
.net ×5
azure-devops ×4
.net-core ×1
asp.net ×1
asp.net-mvc ×1
code-reuse ×1
dart ×1
dart-pub ×1
delegates ×1
lambda ×1
ninject ×1
nuget ×1
nunit ×1
signalr ×1
tfs-sdk ×1
unit-testing ×1