.NET编译器不会隐式转换System.Linq.IOrderedEnumerable<T>为System.Collections.Generic.List<T>
一个明确的演员:
using System.Collections.Generic;
var items = new List<MyType>;
var selectedItems =
from item in items
where item.Active
select item;
return (List<MyType>)selectedItems;
Run Code Online (Sandbox Code Playgroud)
发出警告:
Suspicious cast: there is no type in the solution which inherits from both System.Linq.IOrderedEnumerable<MyType> and System.Collections.Generic.List<MyType>
Run Code Online (Sandbox Code Playgroud)
这里的最佳做法是什么
我一直在调查NuGet feed主机的选项.
目前,我们使用TeamCity构建/发布TC的内置服务器包.对于指向TC的Visual Studio包源,我们发现订阅/更新过程非常缓慢 - 即使我们的开发人员工作站位于同一本地子网内,并且我们只有几十个包.
我知道的其他包裹选项:
有没有人拥有任何这些解决方案的企业级经验?
MyGet看起来非常有前景,但值得关注的是(至少根据他们的网站)只有大约1500个Feed是活跃的.如果MyGet真的流行起来,那似乎应该是150,000左右.
另外:NuGet世界中有什么类似于Maven的本地"快照"包引擎和提要服务器的概念吗?
谢谢.
在PowerShell中,是否可以将驱动器号映射到本地路径?
所以例如map x:\toc:\myfolder1\myfolder2\
密码包含PowerShell特殊字符时,我该怎么办?
Invoke-Expression -Command "net use x: $Path /USER:domain1\user1 7Ui4RT,@T /persistent:no"
Run Code Online (Sandbox Code Playgroud)
这在语法上失败 - 因为PowerShell解释7Ui4RT,@T为数组:
Invoke-Expression -Command "net use x: $Path /USER:domain1\user1 7Ui4RT`,@T /persistent:no"
Run Code Online (Sandbox Code Playgroud)
这在语法上失败 - 显然是因为PowerShell无法解释 7Ui4RT``,@T
Invoke-Expression -Command "net use x: $Path /USER:domain1\user1 "7Ui4RT,@T" /persistent:no"
Run Code Online (Sandbox Code Playgroud)
这失败是因为PowerShell将其解释7Ui4RT,@T为对象而不是字符串(error ="找不到接受参数'System.Object []'的位置参数.").
我该怎么办?
显然,这是不可能投WhereEnumerableIterator<IX>给IEnumerable<X:IX>
public interface IX
public class X1 : IX
public class X2 : IX
public void Method1(IEnumerable<IX> arg)
{
var filtered = arg.Where(e => e.GetType() == typeof(X2));
// filtered will be of type WhereEnumerableIterator<IX>
Method2(filtered as IEnumerable<X2>);
}
public void Method2(IEnumerable<X2> arg)
{
// at runtime arg will be null
}
Run Code Online (Sandbox Code Playgroud)
显然,CLR无法投WhereEnumerableIterator<IX>给IEnumerable<X2>和集导致空(有点神秘).
似乎合乎逻辑的是,可以应用过滤器IEnumerable<IX>并将结果表示为IEnumerable<X:IX>(实际上没有枚举).
但是怎么做呢?
var timestamp = DateTime.ParseExact("20140101T000000Z", "YYYYMMDDThhmmssZ", CultureInfo.InvariantCulture);
System.FormatException was unhandled by user code
HResult=-2146233033
Message=String was not recognized as a valid DateTime.
Source=mscorlib
Run Code Online (Sandbox Code Playgroud)
这对我来说没有任何意义,因为YYYYMMDDThhmmssZISO-8601 YYYY-MM-DDThh:mm:ssZ删除了特殊格式字符.
我编写了代码,通过 libgit2sharp ( v0.21.0.176 ) 以编程方式将 GitHub 私有存储库克隆到本地存储库
var cloneOptions = new CloneOptions { BranchName = "master", Checkout = true };
var cloneResult = Repository.Clone( @"https://github.com/my-organization/my-repo.git", @"c:\github\my-organization\my-repo" );
Run Code Online (Sandbox Code Playgroud)
抛出异常:
{LibGit2Sharp.LibGit2SharpException: Request failed with status code: 401
at LibGit2Sharp.Core.Ensure.HandleError(Int32 result)
at LibGit2Sharp.Core.Ensure.ZeroResult(Int32 result)
at LibGit2Sharp.Core.Proxy.git_clone(String url, String workdir, GitCloneOptions& opts)
at LibGit2Sharp.Repository.Clone(String sourceUrl, String workdirPath, CloneOptions options)
Run Code Online (Sandbox Code Playgroud)
cloneResult 值为空(由于抛出异常而从未设置)
请注意,无论 \my-repo\ 文件夹是否存在,都会抛出相同的 401 异常。
我的函数调用语法正确吗?
从命令行执行,git clone首先创建要克隆到的本地 dir 文件夹。
libgit2sharp 的Repository.Clone()工作方式不同吗?
Windows 7 Git 扩展
GitExtensions安装程序会自动添加一行.gitconfig来指示git使用GitExtensions editor
我的.gitconfig被另一个程序更改了,GitExtensions安装程序修复模式不会重新添加设置。
有人可以提供一下吗?
我已经尝试过以下语法,但它是错误的:
[core]
editor = !\"C:\\Program Files (x86)\\GitExtensions\\GitExtensions.exe\"
Run Code Online (Sandbox Code Playgroud) 只有当调用者实际需要该特定枚举元素时,c#yield compute才会延迟循环的每次迭代的执行.是否可以组合多个这样的yield return函数并仍然将动态枚举集暴露给最终调用者?
public IEnumerable<string> GetDelayedCompute1()
{
// compute ...
foreach(var s in results)
{
yield return s;
}
}
public IEnumerable<string> GetDelayedCompute2()
{
// compute ...
foreach(var s in results)
{
yield return s;
}
}
public IEnumerable<string> GetResults()
{
// how to combine results of GetDelayedCompute1 and GetDelayedCompute2
// and yield return without forcing enumeration
}
Run Code Online (Sandbox Code Playgroud) 我写了一个Puppet模块在Windows上安装Git.Puppet Master是Linux.
是否可以使用puppet资源(即没有脚本或exec)编写Puppet清单来克隆GitHub仓库?
这是一个私人仓库,因此解决方案需要包含安全凭证.
var fileIO = new FileIO();
var datafiles = _fileIo.GetFileDetails(directory)
.Where(f => !f.FileName.EndsWith(".csv"))
.Where(f => !f.FileName.EndsWith(".xls"))
.Where(f => !f.FileName.EndsWith(".xlsx"));
Run Code Online (Sandbox Code Playgroud)
似乎应该有一种更简洁的语法,该语法允许传递后缀字符串列表。
c# ×5
git ×3
linq ×3
.net ×2
git-clone ×2
ienumerable ×2
powershell ×2
windows ×2
casting ×1
concat ×1
datetime ×1
editor ×1
git-config ×1
github ×1
interface ×1
iso8601 ×1
libgit2sharp ×1
mapped-drive ×1
myget ×1
nuget ×1
nuget-server ×1
package ×1
puppet ×1
return ×1
rspec-puppet ×1
timestamp ×1
yield ×1