或者,换句话说,SQL Server 2012的SqlStudio.bin在哪里?通过查看这个其他的SO问题似乎没有预期的地方.
我在我的项目中安装了一个软件包版本,但在测试期间我发现了它的问题.我尝试了显而易见的事情,Update-Package -Id Foo.Bar -Version 1.0.0 -Force
但Update-Package cmdlet没有-Force参数,并且它不允许更新早期版本.如何降级我的包依赖项(不使用源代码控制!)
注意:此问题现在无关紧要,因为Update-Package MyPackage -Version [an earlier version]
在最新版本的NuGet软件包管理器中开箱即用.你甚至不需要-Force
开关.
在PowerShell中,如何测试变量是否包含数值?
目前,我正试图这样做,但似乎总是回归false
.
add-type -Language CSharpVersion3 @'
public class Helpers {
public static bool IsNumeric(object o) {
return o is byte || o is short || o is int || o is long
|| o is sbyte || o is ushort || o is uint || o is ulong
|| o is float || o is double || o is decimal
;
}
}
'@
filter isNumeric($InputObject) {
[Helpers]::IsNumeric($InputObject)
}
PS> 1 | isNumeric
False
Run Code Online (Sandbox Code Playgroud) 当Expression<T>
被编译,是由框架隐式缓存由此得到的代码?我正在考虑静态Regex
方法,其中框架隐式编译并缓存最后几个正则表达式.
如果没有缓存编译Expression<T>
对象,您是否可以推荐一些最佳实践来保持编译时间,或者如果我手动缓存表达式,可能会导致问题的任何问题?
public MyResultType DoSomething(int arg1, int arg2)
{
var result = invokeHandler(
(IDoSomethingHandler h) => h.DoSomething(arg1, arg2)
);
return result;
}
private TResult invokeHandler<T, TResult>(Expression<Func<T, TResult>> action)
where T : class
{
// Here, I might want to check to see if action is already cached.
var compiledAction = action.Compile();
var methodCallExpr = action as MethodCallExpression;
// Here, I might want to store methodCallExpr in a cache somewhere.
var handler = …
Run Code Online (Sandbox Code Playgroud) 嗨,我注意到以下代码片段的一些奇怪的行为
function test
{
$LASTEXITCODE = $null
ping asdfs
Write-Host "Last exitcode: $LASTEXITCODE"
}
test
Write-Host "Last exitcode: $LASTEXITCODE"
Run Code Online (Sandbox Code Playgroud)
这个输出是
Ping request could not find host asdfs. Please check the name and try again.
Last exitcode:
Last exitcode: 1
Run Code Online (Sandbox Code Playgroud)
为什么$ LASTEXITCODE没有在test()函数中设置?
这是我现在遇到的一个问题的概括,当我从一个函数中调用Win32 .exe并且$ LASTEXITCODE没有返回我在函数中期望的值时
如何使用Windsor容器将appSettings条目(从app.config或web.config)的值注入服务?如果我想将一个Windsor属性的值注入服务中,我会做这样的事情:
<properties>
<importantIntegerProperty>666</importantIntegerProperty>
</properties>
<component
id="myComponent"
service="MyApp.IService, MyApp"
type="MyApp.Service, MyApp"
>
<parameters>
<importantInteger>#{importantIntegerProperty}</importantInteger>
</parameters>
</component>
Run Code Online (Sandbox Code Playgroud)
但是,我真正想做的是#{importantIntegerProperty}
从应用程序设置变量中获取值,该变量可能是这样定义的:
<appSettings>
<add key="importantInteger" value="666"/>
</appSettings>
Run Code Online (Sandbox Code Playgroud)
编辑:澄清; 我意识到,温莎和David Hayden的文章指出,滑盖式枪口指的是实际上是关于他自己的(David Hayden的)IoC容器,而不是温莎.
我肯定不是第一个遇到这个问题的人,所以我想知道的是其他人如何解决这个问题?
我是一个C#人,试图从Erik Meijer的第9频道网络广播中自学Haskell.我遇到了一个有趣的谜题,其中包括使用zip和mod跳过列表中的每个'n'元素.
every :: Int -> [a] -> [a]
every _ [] = []
every n xs = [x | (x,i) <- zip xs [1..], i `mod` n == 0]
Run Code Online (Sandbox Code Playgroud)
如果我们可以避免使用mod,我一直认为它可能更有效(对于非常大的列表或流).
我想懒惰地创建一个重复的整数列表,这样我们就可以简单地比较i和n的值.
repeatInts :: Int -> [Int]
Run Code Online (Sandbox Code Playgroud)
这样调用无限repeatInts 3
回报[1,2,3,1,2,3,1,2,3,1,2,3,..]
.
鉴于此,我们可以every
像这样重新定义:
every :: Int -> [a] -> [a]
every _ [] = []
every n xs = [x | (x,i) <- zip xs (repeatInts n), i == n]
Run Code Online (Sandbox Code Playgroud)
所以我的问题是:你将如何实施repeatInts
?
我的解决方案中有一个项目,它起源于C#库项目.它在代码方面对它没有任何兴趣,它只是在我的解决方案中用作其他项目的依赖项,以确保它是首先构建的.构建此项目的一个副作用是创建一个共享的AssemblyInfo.cs,其中包含其他项目正在使用的版本号.
我通过在.csproj文件中添加以下内容来完成此操作:
<ItemGroup>
<None Include="Properties\AssemblyInfo.Shared.cs.in" />
<Compile Include="Properties\AssemblyInfo.Shared.cs" />
<None Include="VersionInfo.targets" />
</ItemGroup>
<Import Project="$(ProjectDir)VersionInfo.targets" />
<Target Name="BeforeBuild" DependsOnTargets="UpdateSharedAssemblyInfo" />
Run Code Online (Sandbox Code Playgroud)
引用的文件VersionInfo.targets包含以下内容:
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<!--
Some properties defining tool locations and the name of the
AssemblyInfo.Shared.cs.in file etc.
-->
</PropertyGroup>
<Target Name="UpdateSharedAssemblyInfo">
<!--
Uses the Exec task to run one of the tools to generate
AssemblyInfo.Shared.cs based on the location of AssemblyInfo.Shared.cs.in
and some of the other properties.
-->
</Target>
</Project>
Run Code Online (Sandbox Code Playgroud)
VersionInfo.targets文件的内容可以简单地嵌入.csproj文件中,但它是外部的,因为我试图将所有这些内容转换为项目模板.我希望模板的用户能够将新项目添加到解决方案,编辑VersionInfo.targets文件,然后运行构建.
问题是修改和保存VersionInfo.targets文件并重建解决方案没有任何效果 - 项目文件使用.targets文件中的值,就像打开项目时一样.即使卸载和重新加载项目也没有效果.为了获得新值,我需要关闭Visual Studio并重新打开它(或重新加载解决方案).
如何设置它以使配置在.csproj文件外部而不在构建之间缓存?
是否有免费的代码覆盖工具适用于从命令行运行的.NET 4和NUnit(因此适合在构建服务器上使用)?
请注意,在这种情况下,任何需要Visual Studio版本高于Professional的工具都不合适.
我问这个问题,因为我不能让NCover 1.5.8在.NET 4 C#app上使用NUnit 2.5.5.我可以运行单元测试,我可以生成Coverage.Xml文件,但它是空的 - 它不包含序列点.经过大量的研究,我得出结论,这是因为NCover 1.5.8根本不适用于.NET 4.但是,如果您更了解,请随时回答其他用户提出的问题.
.NET结构中的成员相等性测试使用的算法是什么?我想知道这一点,以便我可以使用它作为我自己的算法的基础.
我试图为任意对象(在C#中)编写递归成员相等性测试,以测试DTO的逻辑相等性.如果DTO是结构体,这是相当容易的(因为ValueType.Equals主要是正确的事情),但这并不总是合适的.我还想覆盖任何IEnumerable对象(但不是字符串!)的比较,以便比较它们的内容而不是它们的属性.
事实证明这比我预期的要难.任何提示将不胜感激.我会接受证明最有用的答案或提供最有用信息的链接.
谢谢.