我在项目上使用Git使用Visual Studio 2013 Express.
我创建了我的存储库,并将项目文件从另一个目录复制到其中.然后我检查了我.gitignore和.gitattributes文件. .gitignore是预配置的,并且看起来涵盖了此时我需要忽略的所有提交.
我在"团队资源管理器"选项卡下的Visual Studio中选择了"更改"选项卡,并按预期方式查看了所有文件未跟踪.然后我点击"全部添加".我假设VS只会将与我的文件不匹配的文件添加.gitignore到"包含的更改"列表中.而是将所有文件添加到"包含的更改"列表中.
然后我想,也许.gitignore文件将在提交时使用,并且只提交与那些文件不匹配的文件.gitignore.所以我添加了一条提交消息,然后单击"提交".
当我从"更改"选项卡的"操作"下拉列表中选择"查看历史记录"时,我会看到"我的团队资源管理器"视图左侧的窗格,其中显示了我所做的所有提交.只有1个提交.当我双击该提交时,将显示"团队资源管理器"选项卡,Commit 8db34b1c并且我的项目中的所有文件都在树视图中列出,其名称后面带有[添加].
例如,即使我包含行App_Data/Movies.mdf,App_Data/Movies.ldf也会列出.gitignore
# SQL Server files
App_Data/*.mdf
App_Data/*.ldf
Run Code Online (Sandbox Code Playgroud)
我不明白.gitignore文件是如何在这里使用的,或者"包含的更改","排除的更改"或"未跟踪的文件"部分是什么意思.
将理解对上述行为和部分的解释.
编辑 -
我删除了我的.git目录,创建了一个新的repo,再次复制了我的项目文件,然后截取了我看到的内容.
这是我的.gitignore文件和我的"更改"标签的图像.

有这个问题和这个msdn问题表明其他人似乎也有问题.我尝试删除我的.git目录中VS添加的.xml文件(如msdn问题中所述),但这并没有解决我的问题.
编辑2 -
这是我目前的目录结构:
/MvcMovie/
|--.git/
|
|---MvcMovie/
| |--App_Data/
| | |--Movies.mdf
| | |--Movies.ldf
| |
| |--App_Start/
| |--etc...
|
|--packages/
|--.gitignore
|--.gitattributes
|--MvcMovie.sln
|MvcMovie.v12.suo
Run Code Online (Sandbox Code Playgroud) 我正在阅读一本关于MVC的书中的一些LINQ示例,我想知道下面的选择调用有什么用途.也许这是一个错字,但我在书的勘误表中没有看到任何提及它.
foreach( Product p in products
.Where( e => e.Name == productParam.Name )
.Select( e => e ) ) {
p.Price = productParam.Price;
}
Run Code Online (Sandbox Code Playgroud)
我测试了两个这样的例子,其中包括.Select(e => e)和一个不包含的内容,代码是相同的.由于Where返回由谓词过滤的IEnumerable,那么何时需要select调用(具有上面的特定谓词)?它真的做了什么吗?它可以在一些奇怪的角落里吗?
Map的类型定义如下
interface MapConstructor {
new <K, V>(): Map<K, V>;
new <K, V>(iterable: IterableShim<[K, V]>): Map<K, V>;
prototype: Map<any, any>;
}
Run Code Online (Sandbox Code Playgroud)
我想使用第二个构造函数new <K, V>(iterable: IterableShim<[K, V]>): Map<K, V>;
我定义了一个类型,type ChangeMap = { [key: string]: Array<string> };其使用方式如下
let changeMap: ChangeMap = { A: ["Car", "Boat"], B: ["Plane", "Rocket"] };
Run Code Online (Sandbox Code Playgroud)
我想创建一个Map<number, ChangeMap>我可以轻松完成的任务,但我对如何构建我想要初始化的数据感到Map困惑
public changeOptions = new Map<number, ChangeMap>( ... what goes here ... ?)
Run Code Online (Sandbox Code Playgroud)
这是可能的还是我需要初始化我的Map没有值然后调用changeOptions.set(1, changeMap);给它值?
---编辑#1
为了回答下面@Paarth 的问题,number中的键changeOptions …
您可以通过dir(obj)在Chrome开发工具控制台中调用并单击右侧指向dir此文件中定义位置的链接显示来查找此文件.
这个文件背后有什么细节?
这个脚本是Chrome调试器的一部分还是V8的一些接口?
为什么2007年苹果版权最高?
当我打开这个文件时,VM之后的数字标识符总是不同的.VMXXXX标识符来自哪里?
这些文件是否已公开显示,如果是这样,您如何访问它们?
谢谢!

我有一个Azure功能应用程序(使用更新的.net class library方法),我使用静态构造函数初始化,以便共享生成的资源.
官方文档建议像HttpClient 在web api中共享资源.
Azure函数C#脚本开发人员参考文档底部的讨论提到放置HttpClient一个静态变量以防止对每个请求进行重新实例化,因为它是线程安全的.
我想知道两件事.
静态构造函数是否可以初始化所有请求使用的昂贵的"设置"资源?
如果这种方法没问题,如果这些资源的初始化失败,如何在静态构造函数中配置错误日志记录?
这是我的班级定义
public static class HttpSubmissionTrigger
{
private static readonly SendGridClient sendGridClient;
private static readonly Func<IDictionary<string, object>, string> template;
private static readonly EmailAddress senderEmail;
private static readonly string emailTitle;
private static readonly HttpResponseMessage errorResponse;
static HttpSubmissionTrigger()
{
// ... initialization of above static members here
}
public static async Task<HttpResponseMessage> Run(...)
{
// ... use static members here to send emails, respond to client …Run Code Online (Sandbox Code Playgroud) 我曾见过这样的例子这
public IHttpActionResult GetProduct(int id)
{
Product item = repository.Get(id);
if (item == null)
{
throw new HttpResponseException(HttpStatusCode.NotFound);
}
return Ok(item);
}
Run Code Online (Sandbox Code Playgroud)
但我也想象这是一个选择
public IHttpActionResult GetProduct(int id)
{
Product item = repository.Get(id);
if (item == null)
{
return NotFound();
}
return Ok(item);
}
Run Code Online (Sandbox Code Playgroud)
抛出异常或简单地返回 NotFound(IHttpActionResult 实例)是否有优势?
我知道在响应/请求管道中有一些阶段可以处理这些结果中的任何一个,就像第一个例子一样
public class NotFoundExceptionFilterAttribute : ExceptionFilterAttribute
{
public override void OnException(HttpActionExecutedContext context)
{
if (context.Exception is NotFoundException)
{
// Do some custom stuff here ...
context.Response = new HttpResponseMessage(HttpStatusCode.NotFound);
}
}
}
... …Run Code Online (Sandbox Code Playgroud) 我正在开发一个使用.net Web Api 2开发的API.我看过许多关于Web Api版本1的博客帖子和SO问题,但是相比之下,使用版本2中所做的更改的答案似乎很少.
比较这两种处理控制器中"错误"的方法 ItemsController
System.Web.Http.Results// GET api/user/userID/item/itemID
[Route("{itemID:int}", Name="GetItem")]
[ResponseType(typeof(ItemDTO))]
public IHttpActionResult Get(int userID, int itemID)
{
if (userID < 0 || itemID < 0) return BadRequest("Provided user id or item id is not valid");
ItemDTO item = _repository.GetItem(itemID);
if (item == null) return NotFound();
if (item.UserID != userID) return BadRequest("Item userID does not match route userID");
return Ok<ItemDTO>(item);
}
Run Code Online (Sandbox Code Playgroud)
// ex) in WebApiConfig.cs
// config.Services.Replace(typeof(IExceptionHandler), new GlobalExceptionHandler());
public class GlobalExceptionHandler : ExceptionHandler
{ …Run Code Online (Sandbox Code Playgroud) 我创建了一个自定义中间件来处理我的Api应用程序中的异常。
我想将请求ID与异常以及我在应用程序中执行的任何其他日志记录相关联。然后,我想处理所有异常,并使用requestId生成的I 响应客户端。
这样一来,他们可以通过与我联系requestId,我可以在日志中查询并查看他们收到错误时的情况。
这是Invoke我的中间件的和requestId响应中的发送。
public async Task Invoke(HttpContext context, ILoggerFactory loggerFactory)
{
var requestId = Guid.NewGuid();
var requestScopeLogger = loggerFactory.CreateLogger("AppRequest");
using (requestScopeLogger.BeginScope("Request {requestId}", requestId))
{
try
{
await next(context);
}
catch (Exception ex)
{
await HandleExceptionAsync(context, ex, requestId);
}
}
}
private Task HandleExceptionAsync(HttpContext context, Exception exception, Guid requestId)
{
...
var response = JsonConvert.SerializeObject(new { errorMessage = clientResult.message, requestId });
context.Response.ContentType = "application/json";
context.Response.StatusCode = (int)clientResult.code;
return context.Response.WriteAsync(response);
}
Run Code Online (Sandbox Code Playgroud)
中间件先于我的其他组件(StaticFiles,Swagger,Mvc)注册 …
我了解Ninject的某些功能,并且已经能够将其用于IoC。
当我使用NuGet将对Ninject的引用添加到VS2010中的项目中时,我会在列表中看到其他Ninject扩展。特别是Ninject.MVC3。同样在Ninject网站上的扩展名(http://www.ninject.org/extensions.html)上,我看到了Ninject.Web.Mvc。
如果我正在创建MVC3应用程序,是否需要使用Ninject的此扩展?我对Noject for IoC的类/接口的基本使用是否需要标准库以外的内容?
MVC3项目中的Ninject和Ninject.MVC3 / Ninject.Web.Mvc有什么区别?
c# ×4
asp.net ×2
asp.net-core ×1
azure ×1
git ×1
gitignore ×1
httpresponse ×1
javascript ×1
linq ×1
logging ×1
ninject ×1
typescript ×1
v8 ×1