我正在尝试从错误中获取输出,以便在附加的日志文件中以及调试窗口中显示.日志文件的内容工作正常,但调试窗口中没有显示任何内容.
首先,这是我的配置
<log4net>
<!--
This writes the log information to the console window. It only logs events
that are at least at the INFO level (which would mean that DEBUG events are not
captured.
-->
<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date{ABSOLUTE} [%thread] %level %logger - %message%newlineExtra Info: %property{testProperty}%newline%exception"/>
</layout>
<filter type="log4net.Filter.LevelRangeFilter">
<levelMin value="DEBUG"/>
<levelMax value="FATAL"/>
</filter>
</appender>
<!--
This stores information in the logfile.txt file. It only captures log events
that contain the key word test or error.
--> …Run Code Online (Sandbox Code Playgroud) 以前我有一个简单的字符串数组,其中包含一个看起来像的URL
<string-array name="drawerlinkitems">
<item>http://www.google.com</item>
<item>http://www.google2.com</item>
<item>http://www.google3.com</item>
</string-array>
Run Code Online (Sandbox Code Playgroud)
我能够通过电话访问值
return getResources().getStringArray(R.array.drawerlinkitems)[number];
Run Code Online (Sandbox Code Playgroud)
非常简单的东西.
我在这一点上的问题是我想做除了抓取url之外的更多动作,所以我想构建一个嵌套数组,如下所示:
<string-array name="draweritems">
<item>
<link>http://www.google.com</link>
<title>Google</title>
<icon>soon</icon>
</item>
<item>
<link>http://www.google2.com</link>
<title>Google2</title>
<icon>soon</icon>
</item>
<item>
<link>http://www.google3.com</link>
<title>Google3</title>
<icon>soon</icon>
</item>
</string-array>
Run Code Online (Sandbox Code Playgroud)
然后使用类似的东西访问它
getResources().getStringArray(R.array.draweritems)[number].getString[link];
Run Code Online (Sandbox Code Playgroud)
要么
getResources().getStringArray(R.array.draweritems)[number].getString[1];
Run Code Online (Sandbox Code Playgroud)
(显然我把getString部分搞定了)
我无法弄清楚是否甚至可以在字符串数组中执行此操作,如果不是,那么替换选项是什么.如果是,我不确定如何引用字符串数组以从子项中获取子值.如果有一种你知道的优越方法,我也不会受到这种解决方案的束缚.任何帮助将非常感激.
好吧,我的代码隐藏文件后面有以下类.它是一个非常简单的页面,只需获取TestIssue对象,将条目加载到文本框中以编辑条目,然后单击保存时,它将调用更新数据库中TestIssue的函数.
这是代码.
public partial class Issues_Edit : System.Web.UI.Page
{
protected string filter_test_director;
protected TestIssue myIssue;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string id = Request.QueryString["id"];
id = "1358";
myIssue = new TestIssue(Convert.ToInt32(id));
issue_date.Text = myIssue.Entry_Date.ToString();
issue_author.Text = myIssue.Author.Full_Name_RFL;
issue_text.Text = myIssue.Entry.Replace("<br>", "\n");
issue_text.Height = 150;
issue_text.Width = 400;
}
}
protected void SaveButton_Click(object sender, EventArgs e)
{
myIssue.Entry = issue_text.Text;
int update = TestIssueDB.UpdateIssue(myIssue);
if (update == 1)
{
//Response.Redirect("program.aspx?p=" + myIssue.Program_ID);
}
else
{
top_message.Text …Run Code Online (Sandbox Code Playgroud) 我在单元测试中有以下委托功能,它工作得很好
List<Record> RecordSet = FileData.RecordSet;
Record result = RecordSet.Find(
delegate(Record r)
{
return r.UserID == "12345";
}
);
Run Code Online (Sandbox Code Playgroud)
它很棒.我需要多次执行此搜索,因此我尝试将其添加到我可以调用的函数中,该函数将UserID作为参数,它非常相似,但由于某种原因,ALWAYS返回null.
public Record findRecord(List<Record> RecordSet, string UserID)
{
Record result = RecordSet.Find(
delegate(Record r)
{
return r.UserID.Trim() == UserID;
}
);
return null;
}
Run Code Online (Sandbox Code Playgroud)
我也尝试通过硬编码"12345"作为UserID值,也返回null.更奇怪的是,当我处于调试模式并且查看RecordSet中的值时,我确实看到具有确切UserID的Record.但由于某种原因,没有结果,但上面第一个函数中相同的代码和相同的数据返回结果就好了.
另外,仅供参考,我喜欢LINQ解决问题的方法:
Record result = RecordSet.Where(x => x.UserID == "12345").Select(x => x).First();
Run Code Online (Sandbox Code Playgroud)
但我特意寻找委托解决方案失败的原因
我有一个遗留站点(不是我写的),过去几年一直在带有 php5 的服务器上。我正在创建一个带有 php7 的新服务器,并测试哪些功能有效,哪些功能被破坏。
该网站通过包含文件来使用 pear pear/lib/DB.php。我创建了一个全新的页面,只有代码
<?php
require_once( "DB.php" );
?>
Run Code Online (Sandbox Code Playgroud)
这呈现与完整站点完全相同的错误。
出现的错误是
PHP Parse error: syntax error, unexpected 'new' (T_NEW) in /local/sites/php/pear/lib/DB.php on line 310
Run Code Online (Sandbox Code Playgroud)
该网站只需要 DB.php 因为我已将 Pear 添加到 php.iniinclude_path
检查 Pear 的版本给我以下 $ pear 版本
PEAR Version: 1.10.3
PHP Version: 7.0.15-0ubuntu0.16.04.4
Zend Engine Version: 3.0.0
Running on: Linux cdc-migration-0d 3.13.0-103-generic #150-Ubuntu SMP Thu Nov 24 10:34:17 UTC 2016 x86_64
Run Code Online (Sandbox Code Playgroud)
根据我的研究,最新版本的 Pear 与 php7 兼容,因此这些应该可以一起工作。知道为什么仅仅DB.php在测试页面上要求 就会立即生成解析错误吗?
编辑:产生错误的 pear 文件中的代码如下
function &factory($type, $options …Run Code Online (Sandbox Code Playgroud)