小编Red*_*edX的帖子

asp.net mvc 3远程属性传递3个字段

我想使用RemoteAttribute将三个字段传递给我的控制器.我该怎么做?

 public int ID1 { get; set; }  
 public int ID2 { get; set; }  

 [Remote("CheckTopicExists", "Groups", AdditionalFields = "ID1", ErrorMessage = " ")]  
 public string Topic { get; set; }   

        public ActionResult CheckTopicExists(string topic, int ID1,int ID2)   
        {
            return Json(true, JsonRequestBehavior.AllowGet);
        }
Run Code Online (Sandbox Code Playgroud)

我怎样才能将三个字段传递给该函数?

attributes asp.net-mvc-3

11
推荐指数
1
解决办法
1万
查看次数

带有方括号的git log

我正在尝试获取其名称中带方括号的文件的日志.万一重要:操作系统是Windows,我正在使用git bash.

如果您创建了一个文件,[]其名称一样[Start_here].bat那么git log将无法正常工作.

我试过了:

git log '[Start_here].bat'

git log \[Start_here\].bat

git log '\[Start_here\].bat'

git log -- '[Start_here].bat'

git log -- \[Start_here\].bat

git log -- '\[Start_here\].bat'
Run Code Online (Sandbox Code Playgroud)

而且他们似乎都没有工作.要么它没有显示任何提交,要么显示无关提交列表.

有人有一个有效的解决方案吗?

注意:

git mv '[Start_here].bat' 'start_here.bat'

git log --follow start_here.bat 
Run Code Online (Sandbox Code Playgroud)

确实显示了文件更改的历史记录.

编辑:

使用在新repo中执行的以下脚本,我可以看到git log正确行为,直到您添加子模块.然后它开始列出所有改变了子模块的提交......

#!/usr/bin/env bash

set -x

rm -rf test-repo
rm -rf test-submodule

mkdir test-submodule

pushd test-submodule

git init
git config --local user.name tester1
git config --local user.email test@here.com

echo "a single line" > file.txt
git …
Run Code Online (Sandbox Code Playgroud)

windows git git-bash

8
推荐指数
1
解决办法
585
查看次数

ResourceDictionary.MergedDictionaries 的不同使用方式

我正在浏览我们产品中的一些代码,并看到一些同事以我以前从未见过的方式使用 ResourceDictionary.MergedDictionaries:

    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <toolTips:ToolTips />
                <styles:ControlStyles />
                <icons:IconDictionary />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>
Run Code Online (Sandbox Code Playgroud)

tooltips:ToolTips MergedDictionaries 中的所有其他元素都是 ResourceDictionaries。

根据互联网使用这些的常规方法是使用<ResourceDictionary Source="uri to your xaml file"/>.

那么两者之间有什么实际区别吗?

如果这种方式有效,为什么不更频繁地使用它,因为它可以很好地完成代码完成?

c# xaml

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

字符串中相同数字的单独序列

我正在尝试做一个小任务,要求将数字转换为电话键盘的字母,例如,如果输入为222则表示电话按钮"2"(http://upload.wikimedia.org/wikipedia/commons/7/ 7d/Telephone-keypad.png)被推3次,输出应该是"C"等等.首先,我应该做的是将所有序列分开,例如22255-444分为222,55, - ,444和然后我认为把一切都搞清楚,但现在问题是我的功能无法读取最后的序列

#include <iostream>
#include <fstream>
using namespace std;
//-------------------------------------------------------------------------

void encode(string text, string &result, int &i)
{
 char keyboard[10][4] = {
    {' ',' ',' ',' '},
    {'.','?','!','.'},
    {'a','b','c','a'},
    {'d','e','f','d'},
    {'g','h','i','g'},
    {'j','k','l','j'},
    {'m','n','o','m'},
    {'p','r','q','s'},
    {'t','u','v','t'},
    {'w','x','y','z'}
  };

  int j;
  for(j = i; j<text.size();j++)
  {
    if(text[i] != text[j] || j == text.size())
    {
        result = text.substr(i, j-i);
        i = j-1;
        break;
    }

  }
  cout << result << endl;

}



int main()
{
  ifstream fd("sms.in");
  string text;
  string …
Run Code Online (Sandbox Code Playgroud)

c++ string

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

C++数组元素的构造顺序

C++中是否有关于数组元素构造顺序的保证?

#include <iostream>
using namespace std;

struct A {
  A() { cout << this << endl; }
};

int main()
{
  cout << "[0] is " << new A[3];
}
Run Code Online (Sandbox Code Playgroud)

打印出来

0x602010
0x602011
0x602012
[0] is 0x602010
Run Code Online (Sandbox Code Playgroud)

意味着元素是按照[0],[1]和[2]的顺序构建的.该语言是否保证该顺序?

c++ arrays constructor

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

获取当前文件的来源路径

我正在使用此处第一个响应中的插件获取本地 vimrc:Vim:对目录中的文件应用设置

现在我想做的是将这个本地 vimrc 文件的当前路径添加到 vims 路径。

我知道这%:p:h给了我当前文件的路径。但它是被打开的文件而不是被搜索的配置文件。

let s:local_path = expand('%:p:h')
exec "set path+=".s:local_path
Run Code Online (Sandbox Code Playgroud)

有谁知道如何获取源文件的路径?

vim

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

Visual Studio 2015 Update 1,铿锵错误

当我在我的项目(Visual Studio 2015 Update 1)中尝试使用Visual Codegen的新clang时,我收到以下错误:

clang.exe : error : cannot specify -o when generating multiple output files
Run Code Online (Sandbox Code Playgroud)

这只是一个新创建的项目,具有自动生成的主要功能.

我真的不知道该怎么办.

任何帮助赞赏.

c++ clang visual-studio-2015

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

确定类是否具有用户定义的__init__

我试图确定我通过参数收到__init__的类是否在传递的类中具有用户定义的函数.没有任何超级课程.

class HasInit(object):
  def __init__(self):
    pass

class NoInit(object):
  pass

class Base(object):
  def __init__(self):
    pass

class StillNoInit(Base):
  pass

def has_user_defined_init_in(clazz):
  return True if # the magic

assert has_user_defined_init_in(HasInit) == True
assert has_user_defined_init_in(NoInit) == False
assert has_user_defined_init_in(StillNoInit) == False
Run Code Online (Sandbox Code Playgroud)

python python-2.7

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

`if x:`完全等同于`如果bool(x)为True:`?

对于我们正在编写的小型测试框架,我正在尝试提供一些实用程序功能.

其中之一应该是等同于if x:但如果这是完全 equivallent到if bool(x) is True:那么我可以只提供一个函数来检查if x is True:if x:.

这种否定也是等同的吗?if bool(x) is False:等于if not x:

python

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

带参数的自由函数,获取返回类型

我有一个函数,我想让变量返回计算值从函数的返回类型自动推导出来.

我已经看到Decltype返回成员函数的函数,我知道decltype(func()) var我可以得到返回类型.但这只适用于没有参数的函数.如果我有一个参数,我必须decltype(func(/* some dummy value convertible to argument type*/))得到返回类型.

是否有任何方法可以执行上述操作而无需指定虚拟值?

auto func(int a) -> std::deque<decltype(a)> {

  // lots of code

  /* ideally */
  decltype(func)::return_type result;

  /* fill result*/

  return result;
}
Run Code Online (Sandbox Code Playgroud)

c++ c++11

3
推荐指数
1
解决办法
534
查看次数