小编Roo*_*ian的帖子

带有Razor的ASP.NET MVC 3可重用表格显示模板

有没有一种使用新的Razor语法在ASP.NET MVC3中创建表格显示模板的好方法?

在ASP.NET MVC 2中,Phil Haack撰写了关于表格显示模板的博客.ASP.NET MVC3中有更好的方法吗?

编辑:

是否也可以根据模型元数据渲染网格?因此,我不想使用WebGrid API手动定义列,而是使用模型元数据.我看到的问题是,您每次都必须使用WebGrid API手动定义表.我想有可能有一种可重复使用的表!

编辑:那么使用模型元数据创建网格有什么好的做法吗?

c# razor asp.net-mvc-3

7
推荐指数
2
解决办法
9875
查看次数

C#Building Fluent API用于方法调用

我该怎么做才能说InvokeMethod可以调用一个方法,当使用像Repeat这样的特殊选项时,它应该在Repeat之后执行.

我现在的问题是该方法在知道必须被调用100次之前就已经执行了.

class Program
{
    static void Main()
    {
        const bool shouldRun = true;

        new MethodExecuter()
            .ForAllInvocationsUseCondition(!Context.WannaShutDown)
                .InvokeMethod(A.Process).Repeat(100)
                .When(shouldRun).ThenInvokeMethod(B.Process).Repeat(10)
            .ForAllInvocationsUseCondition(Context.WannaShutDown)
                .When(shouldRun).ThenInvokeMethod(C.Process);
    }
}
Run Code Online (Sandbox Code Playgroud)

MethodExpression的

public class MethodExpression
{
    private bool _isTrue = true;
    private readonly MethodExecuter _methodExecuter;
    public MethodExpression(bool isTrue, MethodExecuter methodExecuter)
    {
        _isTrue = isTrue;
        _methodExecuter = methodExecuter;
    }

    public MethodExecuter ThenInvokeMethod(Action action)
    {
        if (_isTrue)
        {
            action.Invoke();
            _isTrue = false;
        }
        return _methodExecuter;
    }
}
Run Code Online (Sandbox Code Playgroud)

MethodExecuter

public class MethodExecuter
{
    private bool …
Run Code Online (Sandbox Code Playgroud)

c# fluent-interface

7
推荐指数
1
解决办法
1147
查看次数

"操作可以使运行时不稳定"和DynamicMethod使用值类型

我试图推广以下IL(来自Reflector):

.method private hidebysig instance void SetValue(valuetype Test.TestFixture/ValueSource& thing, string 'value') cil managed
{
    .maxstack 8
    L_0000: nop 
    L_0001: ldarg.1 
    L_0002: ldarg.2 
    L_0003: call instance void Test.TestFixture/ValueSource::set_Value(string)
    L_0008: nop 
    L_0009: ret 
}
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试使用DynamicMethod重现此IL时:

        [Test]
    public void Test_with_DynamicMethod()
    {
        var sourceType = typeof(ValueSource);
        PropertyInfo property = sourceType.GetProperty("Value");

        var setter = property.GetSetMethod(true);
        var method = new DynamicMethod("Set" + property.Name, null, new[] { sourceType.MakeByRefType(), typeof(string) }, true);
        var gen = method.GetILGenerator();

        gen.Emit(OpCodes.Ldarg_1); // Load input to stack
        gen.Emit(OpCodes.Ldarg_2); // Load value to stack …
Run Code Online (Sandbox Code Playgroud)

c# cil

6
推荐指数
1
解决办法
1056
查看次数

如何在visual basic中保存断点6

如何在Visual Basic 6中保存断点?有加载项吗?现在我有MZ-Tools,但不幸的是他们没有保存断点.

vb6 breakpoints

6
推荐指数
2
解决办法
3744
查看次数

Powershell:递归移动文件

我试图将所有构建输出文件和文件夹复制到Bin文件夹(OutputDir/Bin),但保留在OutputDir中的一些文件除外.在文件夹将永远不会被删除.

初始条件:

Output
   config.log4net
   file1.txt
   file2.txt
   file3.dll
   ProjectXXX.exe
   en
      foo.txt
   fr
      foo.txt
   de
      foo.txt
Run Code Online (Sandbox Code Playgroud)

目标:

Output
   Bin
      file1.txt
      file2.txt
      file3.dll
      en
         foo.txt
      fr
         foo.txt
      de
         foo.txt
   config.log4net
   ProjectXXX.exe
Run Code Online (Sandbox Code Playgroud)

我的第一次尝试:

$binaries = $args[0]
$binFolderName = "bin"
$binFolderPath = Join-Path $binaries $binFolderName

New-Item $binFolderPath -ItemType Directory

Get-Childitem -Path $binaries | ? {$_.Name -notlike "ProjectXXX.*" -and $_.Name -ne "config.log4net" -and $_.Name -ne $binFolderName }  | Move-Item -Destination $binFolderPath
Run Code Online (Sandbox Code Playgroud)

这不起作用,因为Move-Item无法覆盖文件夹.

我的第二次尝试:

function …
Run Code Online (Sandbox Code Playgroud)

powershell scripting move

6
推荐指数
1
解决办法
6362
查看次数

加速VisualStudio 2010和Resharper 6.1:是否值得使用RamDisk?

起初我希望在Stackeroverflow上创建这样一个问题是好的,如果不告诉我:)

我有16GB的DDR3内存,我认为可以通过创建一个RAM磁盘加速VisualStudio和Resharper.

你们中的任何人都有过这种情况的经验吗?或者你能给我一些提示吗?

我的想法是将Visual Studio,Resharper和解决方案文件安装/复制到RAM磁盘.

resharper visual-studio-2010 visual-studio resharper-6.1

5
推荐指数
1
解决办法
2182
查看次数

TFS 2010 API:队列同步构建并获取每个排队构建的状态:"在代理上运行(等待构建代理)"

可以同步排队构建吗?

我试过这样的事情:

CodeActivity:

[BuildActivity(HostEnvironmentOption.Agent)]
public sealed class QueueNewBuild : CodeActivity<BuildResult>
{
    // The Team Project that the build definition belongs to.
    [RequiredArgument]
    public InArgument<IBuildDetail> BuildDetail { get; set; }

    // The build definition to queue
    [RequiredArgument]
    public InArgument<String> BuildDefinition { get; set; }

    protected override BuildResult Execute(CodeActivityContext context)
    {
        // Obtain the runtime value of the input arguments
        var buildDefinitionName = context.GetValue(BuildDefinition);
        var buildDetail = context.GetValue(BuildDetail);

        // Obtain the Team Project for the current build definition.
        var tfsProject = buildDetail.BuildDefinition.TeamProject; …
Run Code Online (Sandbox Code Playgroud)

c# tfs tfs2010 build-agent

5
推荐指数
1
解决办法
4974
查看次数

有没有办法用测试数据创建一个类型的实例?

我有一个类型,并希望用测试数据创建它的实例.

我知道像NBuilderAutoFixture这样的框架可以创建在设计时(<T>)已知类型的实例.这些框架是否能够基于仅在runtime(Type)中已知的类型创建实例?

最后,我想做一些事情:

var value = Builder.Create(type);
var constant = Expression.Constant(value, type);
Run Code Online (Sandbox Code Playgroud)

c# autofixture nbuilder

5
推荐指数
1
解决办法
386
查看次数

在UserNamePasswordValidator之前是否有一个WCF扩展点?

UserNamePasswordValidator.Validate(username, password)为每个WCF请求调用之前,我需要运行一些东西.

我已经尝试使用了一个IDispatchMessageInspector,但检查员被调用UserNamePasswordValidator.Validate.

是否有之前调用的WCF扩展点UserNamePasswordValidator

c# wcf

5
推荐指数
1
解决办法
152
查看次数

为什么我应该优先选择基于HTTP RPC JSON-Messaging样式的HTTP REST和CQRS?

每当我读到Web服务应该如何通信时,首先出现的是:

使用REST,因为它将客户端和服务器分离!

我想建立一个Web服务,每个QueryCommand是一个HTTP-端点.使用REST,我会有更少的端点,因为它考虑资源而不是操作的性质(通常比资源有更多的操作).

  • 为什么使用RPC over REST有更强的耦合?
  • 使用REST而非RPC Json-Messaging样式有什么好处?

附加信息:使用消息传递我的意思是同步消息(请求/响应)

更新:我认为只有一个Http端点可以处理QueryCommand取决于给定的Http动词也是可能/更好的.

rest rpc json cqrs

5
推荐指数
1
解决办法
603
查看次数