问题列表 - 第14876页

是否可以通过反思设置私有财产?

我可以通过反思设置私有财产吗?

public abstract class Entity
{
    private int _id;
    private DateTime? _createdOn;
    public virtual T Id
    {
        get { return _id; }
        private set { ChangePropertyAndNotify(ref _id, value, x => Id); }
    }
    public virtual DateTime? CreatedOn
    {
        get { return _createdOn; }
        private set { ChangePropertyAndNotify(ref _createdOn, value, x => CreatedOn); }
    }
}
Run Code Online (Sandbox Code Playgroud)

我已经尝试了以下它并不起作用,其中t代表一种类型Entity:

var t = typeof(Entity);
var mi = t.GetMethod("set_CreatedOn", BindingFlags.Instance | BindingFlags.NonPublic);
Run Code Online (Sandbox Code Playgroud)

我想我可以做到这一点,但我无法解决这个问题.

.net reflection properties private

117
推荐指数
4
解决办法
6万
查看次数

UIPickerView禁用行选择

我想禁用我的某些行的选择UIPickerView.就像在Coundown定时器,你尽量选择0,它不会让你滑倒备份1.或如何可以限制的日期在Date Picker...

如何禁用行中的行UIPickerView

iphone uidatepicker uipickerview

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

为什么resharper建议只读字段

为什么ReSharper在下面的示例中建议"设置"的只读字段?

如果我理解正确,readonly如果仅在构造函数中更改此字段,则应使用修饰符,但在我的示例中,我还在同一个类中的另一个方法中更改它.

我错过了什么?

public partial class OptionsForm : Form
{
    private Settings settings;

    public OptionsForm(Settings s)
    {
        settings = s;
    }

    private void SaveData()
    {
        settings.ProjectName = TextBoxProject.Text;
    }
}
Run Code Online (Sandbox Code Playgroud)

c# resharper readonly

12
推荐指数
2
解决办法
4051
查看次数

Twitter:使用Twitter API的未读直接消息

推特:

我必须是盲人,但我怎样才能知道某个用户有多少未读的直接消息?

我正在使用此文档:https://dev.twitter.com/docs

api twitter

2
推荐指数
1
解决办法
7515
查看次数

如何使用Linq to XML Query搜索节点?

在xml doc下面

    <Root>
        <Global>
        </Global>
        <local>
            <section name="A">
                <subsection name="A">
                    <innersection name="A">
                        <Property1>
                        </Property1>
                    </innersection>
                    <innersection name="B">
                        <Property1>
                        </Property1>
                    </innersection>
                </subsection>
                <subsection name="B">
                    <innersection name="A">
                        <Property1>
                        </Property1>
                    </innersection>
                    <innersection name="B">
                        <Property1>
                        </Property1>
                    </innersection>
                </subsection>
            </section>
            <section name="B">
                <subsection name="A">
                    <innersection name="A">
                        <Property1>
                        </Property1>
                    </innersection>
                    <innersection name="B">
                        <Property1>
                        </Property1>
                    </innersection>
                </subsection>
                <subsection name="B">
                    <innersection name="A">
                        <Property1>
                        </Property1>
                    </innersection>
                    <innersection name="B">
                        <Property1>
                        </Property1>
                    </innersection>
                </subsection>
            </section>
        </local>
    </Root>
Run Code Online (Sandbox Code Playgroud)

现在我想要一个使用linq到xml的单个查询中的section1,其section name ="B"和subsection name ="B"以及innersection name ="B".

.net c# xml vb.net linq-to-xml

2
推荐指数
1
解决办法
1956
查看次数

比较两个相同的字符串在PHP中返回false

这个完全超出我的范围.我想比较两个字符串.当我回显它们时,它们似乎是相同的,但当我将它们与'=='运算符进行比较时,它返回false.例如,在我的数据库上运行下面的代码时.它输出的东西像"显然苹果不等于苹果".任何人都可以对此有所了解吗?

if ($this->data['list_text']) { //user has entered into textarea
            $list = nl2br($this->data['list_text']);

            $list_array = explode('<br />',$list);

            $ranking = 1;
            $company_array = $this->CompanyList->CompanyRanking->Company->find('list',null);

            //this is the comparison bit
            foreach ($list_array as $key => $value) {
                $companyId = null;
                foreach ($company_array as $key2 => $value2) {
                    if ($value2 != $value) {
                        echo 'APPARENTLY '.$value2.' does not equal '.$value;                           
                    } else {
                        $companyId = $key2;
                        break;
                    }
                }

                $this->data['CompanyRanking'][$ranking]['ranking'] = $ranking;
                $this->data['CompanyRanking'][$ranking]['company_id'] = $companyId;
                $ranking++;
            }
        }
Run Code Online (Sandbox Code Playgroud)

php cakephp

5
推荐指数
2
解决办法
6849
查看次数

类路径上的类文件的ClassNotFoundException

我有以下代码:

    // Test TODO remove
    try {
        System.out.println(System.getProperties().getProperty("java.class.path"));
        this.getClass().getClassLoader().loadClass("mypackage.MyClass");
    } catch (ClassNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
Run Code Online (Sandbox Code Playgroud)

现在输出显示出该类位于类路径上,即:

/...some/path.../workspace/project/target/test-classes:/rest/of/the/classpath
java.lang.ClassNotFoundException: mypackage.MyClass
        ...here be stacktrace...
Run Code Online (Sandbox Code Playgroud)

我还确保类文件确实位于给定位置,即该文件存在:

/...some/path.../workspace/project/target/test-classes/mypackage/MyClass.class
Run Code Online (Sandbox Code Playgroud)

也许以下几点很重要:所示代码是在附加到jUnit测试的javaagent中执行的,我通过编程方式启动了该代码(通过Runtime.execute(...))-因此,很明显,除了背景...但仍然:如果类路径包含带有类的文件夹,那么为什么它不能被加载?

java classpath

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

Django中默认的"删除已选中"管理操作

如何在Django管理面板中删除或更改默认管理操作"删除所选X项"的详细名称?

django django-admin

16
推荐指数
5
解决办法
2万
查看次数

查找元素并添加类(jQuery)

<ul>
   <li><a href="#">LEVEL 1</a>
      <ul>
         <li>...</li>
      </ul>
   </li>
   <li><a href="#">LEVEL 1</a>
      <ul>
         <li>...</li>
      </ul>
   </li>
</ul>
Run Code Online (Sandbox Code Playgroud)

我有一个嵌套列表,我想使用jQuery类添加到containts的LI A>LEVEL 1基于此条件:if a nested UL exists AFTER UL LI A, do x else y.

谢谢.

jquery nested list

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

将HTML插入iframe

我正在创建一个浏览器HTML编辑器.我正在使用名为Code Mirror的语法高亮显示器,它非常好.

我的设置是一个iframe,它包含正在编辑的页面视图和用户编辑的纯文本HTML所在的文本区域.

我试图将编辑后的HTML从textarea插入到iframe中,显示它们呈现HTML.

这可能吗?我尝试过以下方法:

HTML设置:

<iframe id="render">

</iframe>

<textarea id="code">
HTML WILL BE 

HERE
</textarea>
<input type="submit" id="edit_button" value="Edit" />
Run Code Online (Sandbox Code Playgroud)

JQuery设置:

$('#edit_button').click(function(){
    var code = editor.getCode(); // editor.getCode() is a codemirror function which gets the HTML from the text area
    var iframe = $('#render');
    iframe.html(code)
})
Run Code Online (Sandbox Code Playgroud)

这似乎没有将HTML加载到iframe中,是否有一种将HTML插入iframe的特殊方法,或者这是不可能的?

干杯

EEF

html iframe jquery insert

18
推荐指数
3
解决办法
4万
查看次数