我刚编辑了用户详细信息页面的路由,如下所示:
routes.MapRoute(
"UserDetails", // Route name
"{controller}/{action}/{id}/{title}", // URL with parameters
new { controller = "Users", action = "Details", id = UrlParameter.Optional, title = UrlParameter.Optional } // Parameter defaults
);
Run Code Online (Sandbox Code Playgroud)
现在,当我的网址看起来像这样:localhost/Users/Details/1/ShawnMclean
图片不会从控制器和site.master加载.(不知道为什么css和javascript有正确的网址).如果网址是localhost/Users/Details/1那么一切都很好.
我的img in site.master并Details.aspx在旧网址中看起来像这样:
<img src="../../Content/Images/logo3.png" />
Run Code Online (Sandbox Code Playgroud)
但是当url获得一个额外的参数时,图像实际上位于 ../../../Content/Images/logo3.png
有没有办法让图像和其他静态内容的网址发生变化?
我想在wpf或silverlight中创建一个小数学求解器应用程序,显示有效.类似于Microsoft Math可以做的事情.如何根据方程中的行数,使括号中的图形能够垂直拉伸?
是否有任何包含这些图形的库并显示.net的步骤?
如何在mocks上设置我的测试方法接受对象的存储库?
这是我到目前为止:
Service.cs
public int AddCountry(string countryName)
{
Country country = new Country();
country.CountryName = countryName;
return geographicsRepository.SaveCountry(country).CountryId;
}
Run Code Online (Sandbox Code Playgroud)
test.cs中
[Test]
public void Insert_Country()
{
//Setup
var geographicsRepository = new Mock<IGeographicRepository>();
geographicsRepository.Setup(x => x.SaveCountry(It.Is<Country>(c => c.CountryName == "Jamaica"))); //How do I return a 1 here?
GeographicService geoService = new GeographicService(geographicsRepository.Object);
int id = geoService.AddCountry("Jamaica");
Assert.AreEqual(1, id);
}
Run Code Online (Sandbox Code Playgroud)
SaveCountry(Country country); 返回一个int.
我需要做两件事:
我需要创建第二个测试Insert_Duplicate_Country_Throws_Exception().在我的安装程序中,当我这样做时,如何告诉存储库抛出错误:
int id = geoService.AddCountry("Jamaica");
int id = geoService.AddCountry("Jamaica");
Run Code Online (Sandbox Code Playgroud)框架:
我正在使用Automapper将列表映射到另一个列表,但似乎我的项目未被复制.
这是我的代码:
var roles = userRepo.GetRoles(null).ToList();
Mapper.CreateMap < List<Domain.Role>, List<Role>>();
var mappedRole = Mapper.Map<List<Domain.Role>, List<Role>>(roles); //the count is 0, list empty :(
Mapper.AssertConfigurationIsValid();
Run Code Online (Sandbox Code Playgroud)
Domain.Role
public class Role
{
public int RoleId { get; set; }
public string RoleName { get; set; }
public List<User> Users { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
角色
public class Role
{
public int RoleId { get; set; }
public string RoleName { get; set; }
}
Run Code Online (Sandbox Code Playgroud) 我需要在文本框的内容发生变化时随时触发事件.
我不能使用keyup,也不能使用keypress.
如果按住键,键盘和键盘功能不起作用.
Keypress在文本实际更改之前触发.它也不识别退格或删除.
所以现在我假设我将不得不构建一些自定义逻辑或下载插件.那里有插件吗?或者,如果我应该建立一个,我应该注意什么约束?
例如.Facebook通过顶级搜索来实现这一目标.你可以按住.
另一个例子是编写stackoverflow问题.在编辑器的正下方,内容被实时复制,退格并且每个都可以正常复制.他们是如何做到的呢?
这是我的来源:
public class User
{
public int UserId { get; set; }
public Address Address { get; set; }
}
public class Address
{
public string Address { get; set; }
public string State {get; set; }
}
Run Code Online (Sandbox Code Playgroud)
这是我的目的地:
public class UserVM
{
public int UserId { get; set; }
public string Address { get; set; }
public string State { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我该如何进行映射?当他们说扁平化是自动的时,普通的创建地图不起作用.
我不知道关键字是什么,所以这里是我想要的一个例子:
return from i in userRepo.GetUsers()
select new SimpleUser{
i.UserId,
i.Name
};
Run Code Online (Sandbox Code Playgroud)
userRepo.GetUsers()返回类型IQueryable<User>.我想将其转换IQueryable<SimpleUser>为我可以限制对User域的某些属性的访问.
如果不对此类翻译进行硬编码,我该怎么做?那些像automapper或ValueInjecter这样的工具怎么样呢?
此外,这项技术叫做什么?
我需要将Pre-build script path参数添加到我的构建定义文件中.我没有看到它接受参数的位置,也没有在Advanced Builds下显示多少,如下所示:

查看构建过程模板文件时GitTemplate.12.xaml,它显示它应该接受更多参数,如下所示AdvancedBuildSettings:

正如您所看到的,PostActionScriptPath参数的值是:
New Microsoft.TeamFoundation.Build.Common.BuildParameter(" { ""MSBuildArguments"": """",
""MSBuildPlatform"": ""Auto"", ""PreActionScriptPath"": """",
""PreActionScriptArguments"": """", ""PostActionScriptPath"": """",
""PostActionScriptArguments"": """", ""RunCodeAnalysis"": ""AsConfigured"" } ")
Run Code Online (Sandbox Code Playgroud)
任何人都知道如何打开此参数,以便我可以输入值PreActionScriptPath?这也发生在另一个构建定义中,该定义清楚地表明它接受.xaml文件中的参数.
我正在开发一个带有一些深层嵌套(长命名空间)文件的项目.该项目不会编译,因为大多数资源文件的文件名太长.例如.
Resource file
"obj\Debug\xxxx.xxxxxxxxxxxxx.xxxx.Services.DeliveryChannels.Web.Common.Resources.xxxxxxxxxxxxxxxxxxx.resources" has an invalid name. The item metadata "%(FullPath)" cannot be applied to the path
"obj\Debug\xxxx.xxxxxxxxxxxxx.xxxx.Services.DeliveryChannels.Web.Common.Resources.xxxxxxxxxxxxxxxxxxx.resources".
D:\Projects\XXXXX\TFS\xxxxx.xxxxx\src\xxxxx.xxxxxxxx.xxxxx\svcs\channels\web\src\xxxxxxx.Web.Common\obj\Debug\xxxx.xxxxxxxxxxxx.xxxxxx.Services.xxxxxxxxxx.Web.Common.Resources.xxxxxxxxxxxxxxxxxx.resources
Run Code Online (Sandbox Code Playgroud)
另一个错误:
File name
'..\..\..\..\..\obj\Debug\xxxx.xxxxxxxxxxxxx.xxxx.Services.DeliveryChannels.Web.Common.Resources.xxxxxxxxxxxxxxxxxxx.resources' is too long or invalid
Run Code Online (Sandbox Code Playgroud)
如何防止编译器将.resource文件重命名为命名空间?我希望编译后资源文件名也一样.
我试图根据传入的参数的泛型来推断方法的返回类型。但是,该参数是来自泛型接口的实现,因此,我假设打字稿推断将根据参数的基数来确定类型。
示例代码:
interface ICommand<T> {}
class GetSomethingByIdCommand implements ICommand<string> {
constructor(public readonly id: string) {}
}
class CommandBus implements ICommandBus {
execute<T>(command: ICommand<T>): T {
return null as any // ignore this, this will be called through an interface eitherway
}
}
const bus = new CommandBus()
// badResult is {}
let badResult = bus.execute(new GetSomethingByIdCommand('1'))
// goodResult is string
let goodResult = bus.execute<string>(new GetSomethingByIdCommand('1'))
Run Code Online (Sandbox Code Playgroud)
我想做的是第一次execute调用,并让Typescript推断正确的返回值,string在这种情况下,此返回值是基于GetSomethingByIdCommand实现的。
我试过使用条件类型,但不确定这是否是解决方案或如何应用它。
asp.net-mvc ×3
.net ×2
automapper ×2
c# ×2
azure-devops ×1
javascript ×1
jquery ×1
math ×1
moq ×1
nunit ×1
silverlight ×1
tfs ×1
tfsbuild ×1
typescript ×1
unit-testing ×1
wpf ×1