我可以通过反思设置私有财产吗?
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)
我想我可以做到这一点,但我无法解决这个问题.
我想禁用我的某些行的选择UIPickerView.就像在Coundown定时器,你尽量选择0,它不会让你滑倒备份1.或如何可以限制的日期在Date Picker...
如何禁用行中的行UIPickerView?
为什么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) 在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".
这个完全超出我的范围.我想比较两个字符串.当我回显它们时,它们似乎是相同的,但当我将它们与'=='运算符进行比较时,它返回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) 我有以下代码:
// 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(...))-因此,很明显,除了背景...但仍然:如果类路径包含带有类的文件夹,那么为什么它不能被加载?
如何在Django管理面板中删除或更改默认管理操作"删除所选X项"的详细名称?
<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.
谢谢.
我正在创建一个浏览器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
.net ×2
c# ×2
jquery ×2
api ×1
cakephp ×1
classpath ×1
django ×1
django-admin ×1
html ×1
iframe ×1
insert ×1
iphone ×1
java ×1
linq-to-xml ×1
list ×1
nested ×1
php ×1
private ×1
properties ×1
readonly ×1
reflection ×1
resharper ×1
twitter ×1
uidatepicker ×1
uipickerview ×1
vb.net ×1
xml ×1