在localy克隆的git存储库中,我可以观看历史记录
git log
Run Code Online (Sandbox Code Playgroud)
在一个小工具中,我只需要存储库的历史记录,而不是代码.有没有办法克隆没有代码的存储库(仅限历史记录)?
有没有其他方法只从git存储库获取历史记录.
提前致谢
在MVC 5.2.2中,我可以设置Routes.AppendTrailingSlash为true,以便将尾部斜杠附加到URL.
但是我还有一个机器人控制器,它返回robots.txt的内容.
如何防止将Slash附加到robots.txt路由并使其在尾部斜杠中调用?
我的控制器代码:
[Route("robots.txt")]
public async Task<ActionResult> Robots()
{
string robots = getRobotsContent();
return Content(robots, "text/plain");
}
Run Code Online (Sandbox Code Playgroud)
我的路线配置看起来像这样:
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home",
action = "Index",
id = UrlParameter.Optional }
);
RouteTable.Routes.AppendTrailingSlash = true;
Run Code Online (Sandbox Code Playgroud) 我正在处理文档存储.因此我计划将SqlServer 2012与文件表一起使用.现在经过一些测试后,似乎SqlServer只索引doc而不是docx文件.
我还安装了Microsoft Filter Pack 2.0.
有人知道如何获得docx支持吗?也许还有一种获得pdf支持的方式?
非常感谢Boas
我使用fogbugz XML API 消耗了一些数据.此API始终以UTF-8提供数据.
当使用WebClient类来发出请求时,我可以设置编码.例如:
var result = new WebClient();
result.Encoding = Encoding.UTF8;
Run Code Online (Sandbox Code Playgroud)
但那HttpClient班级怎么样?
HttpClient client = new HttpClient();
Run Code Online (Sandbox Code Playgroud)
我应该使用:
client.GetByteArrayAsync(url);
Run Code Online (Sandbox Code Playgroud)
...然后将编码中的字节(UTF-8)转换为字符串?
或者有没有办法直接将内容作为UTF-8字符串?
using (var client = Connector.GetHttpClient())
{
var byteData = await client.GetByteArrayAsync(url);
data = Encoding.UTF8.GetString(byteData);
}
Run Code Online (Sandbox Code Playgroud)
最后,这里是XML响应的摘录:
<?xml version="1.0" encoding="UTF-8"?>
<response>
Run Code Online (Sandbox Code Playgroud) Json.net具有将对象转换为json的异步函数,如:
jsn = await JsonConvert.DeserializeObjectAsync<T>
Run Code Online (Sandbox Code Playgroud)
但是当我想将对象写入json文件时,我最好直接使用文件Stream.
所以我认为它应该是这样的:
var fileStream = await file.OpenAsync(FileAccessMode.ReadWrite);
using (IOutputStream outputStream = fileStream.GetOutputStreamAt(0))
{
using (StreamWriter sw = new StreamWriter(fileStream.AsStreamForWrite()))
{
using (JsonWriter jw = new JsonTextWriter(sw))
{
jw.Formatting = Formatting.Indented;
JsonSerializer serializer = new JsonSerializer();
serializer.Serialize(jw, obj);
}
}
Run Code Online (Sandbox Code Playgroud)
但是在JsonSerzializer对象上我找不到异步方法.另外我认为IO操作不应该放在自己的线程中.
推荐的方法是什么?
当我有一个自定义的asp核心中间件时,我想检索请求的取消令牌
我试着将它添加到调用的签名中,如下所示:
public async Task Invoke(HttpContext context,CancellationToken token)
Run Code Online (Sandbox Code Playgroud)
但作为儿子,我添加它不再被称为.
我究竟做错了什么?
asp.net-core-mvc asp.net-core asp.net-core-1.0 asp.net-core-middleware
在ASP.NET MVC中,我可以像这样解析Razor脚本:
string template = "It is @DateTime.Now.ToString()";
string result = Razor.Parse(template);
Run Code Online (Sandbox Code Playgroud)
但是核心中不存在这种静态.
我也读过这篇文章,但在我看来,视图代码是一个字符串,所以我不能使用find或者get查看方法ICompositeViewEngine.
关于如何在核心中解析视图字符串的任何建议?
在.net framework 4.6.2 consoleapps中使用.net标准时遇到了一些问题.
我可以把问题减少到这个:给定:
我用这个单独的类创建了一个.net标准1.5客户端库vs 2017
public class Class1
{
public List<int> Get()
{
return new List<int>() { 1, 2, 3, 4, 5, 65, 6 };
}
}
Run Code Online (Sandbox Code Playgroud)
现在我创建一个新的.net 4.6.2控制台应用程序,它只是调用此类的方法:
static void Main(string[] args)
{
var foo = new Class1();
Console.WriteLine("Done!");
Console.ReadLine();
}
Run Code Online (Sandbox Code Playgroud)
现在我明白了
System.IO.FileNotFoundException:'文件或程序集'System.Runtime,Version = 4.1.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a未找到
当我将.net standardlib nuget包添加到.net fx控制台时,它可以工作.但是那时system.runtime可以通过GAC和nuget参考来实现,这对我来说似乎很难看.
我在这里推出了这个简短的测试解决方案:https://github.com/Gentlehag/NetStandardSample
我错过了什么?
我有一些类似CustomerModel或CustomerDetailsModel正在进行的课程ModelBase.
另外,我不想为每个模型类型引入子类.
在一个案例中有一个post方法foreach.
所以我可以手动创建多个路由来调用看起来像的方法
Handle<T>(T model) where T : ModelBase
Run Code Online (Sandbox Code Playgroud)
它们只在所谓的路径上有所不同.例如:
baseurl/api/customer => CustomerModel
baseurl/api/customerdetails => CustomerDetailsModel
Run Code Online (Sandbox Code Playgroud)
我想实现一个通用的web api方法
[HttpPost]
void Post<T>(T model) where T : ModelBase
Run Code Online (Sandbox Code Playgroud)
如果我只是创建一个泛型方法,我得到一个异常,告诉我web api方法不能有泛型方法.但是前段时间我已经看到了使用某种自定义查找机制处理这个问题的web api v1的实现.但我再也想不通了.
作为一种解决方法,我创建了一个callwrapper来确定类型并调用内部泛型方法,但这感觉非常难看
public async Task<IHttpActionResult> Post(string id, string moduleType)
{
await AsyncGenericCallWrapper(moduleType);
...
Run Code Online (Sandbox Code Playgroud)
拥有上面提到的通用控制器会有很多不足之处.
private async Task AsyncGenericCallWrapper(string moduleType)
{
Type type = GetModuleType(moduleType);
var content = await Request.Content.ReadAsStringAsync();
var instance = JsonConvert.DeserializeObject(content, type);
MethodInfo method = this.GetType().GetMethod("InternalGenericMethod", BindingFlags.NonPublic | BindingFlags.Instance);
MethodInfo generic = …Run Code Online (Sandbox Code Playgroud) c# generics asp.net-web-api asp.net-web-api-routing asp.net-web-api2
在查看命令模式时,发现略有不同。也许有些能够更清楚地说明这一点。
当查看四人组时,它说每个命令都有一个执行方法,例如:http : //www.blackwasp.co.uk/Command.aspx, 例如:
myCommand.Execute(myValue);
Run Code Online (Sandbox Code Playgroud)
现在,当我查看如何在CQRS (Greg Young)中使用的命令时,我发现该命令没有执行方法。它们只是某种“命令指令”实例。在 CQRS 网络广播中也说了类似的话。
该命令由域对象处理。喜欢
class myDomainObject
{
void UpdateValue(UpdateValueCommand cmd){
this.value = cmd.value;
}
}
Run Code Online (Sandbox Code Playgroud)
它只是另一个像“CQRS-Command Pattern”这样的 CommandPattern 定义,对吗?所以当谈到一个命令时,它在“common”或“cqrs”上下文中的含义可能略有不同?还是我错过了命令模式或 CQRS 实现?
c# ×6
.net ×2
asp.net-core ×2
asp.net-mvc ×2
asp.net ×1
c#-5.0 ×1
cqrs ×1
docx ×1
encoding ×1
generics ×1
git ×1
json.net ×1
razor ×1
razorengine ×1
unicode ×1
winrt-async ×1