<StepList>
<Step>
<Name>Name1</Name>
<Desc>Desc1</Desc>
</Step>
<Step>
<Name>Name2</Name>
<Desc>Desc2</Desc>
</Step>
</StepList>
Run Code Online (Sandbox Code Playgroud)
我有这个XML,我应该如何建模类,以便我可以使用XmlSerializer对象反序列化它?
有没有办法配置log4net以在调试期间将日志打印到控制台和文件?
我试图通过在日志发生时立即观察日志来找到一种有效调试软件的方法.
写入文件对我来说是有问题的,因为我不想等到文件被刷新到磁盘然后打开它.
因此我更喜欢它写入控制台.
你有什么建议?
我添加了app.config附加附加的文件,但我无法显示结果控制台.
以下是我的app.config配置:
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IProviderService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false"/>
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None" realm=""/>
<message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8081/AP2" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IProviderService" contract="IProviderService" name="WSHttpBinding_IProviderService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
</client>
</system.serviceModel>
<log4net debug="true">
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender"> …Run Code Online (Sandbox Code Playgroud) 我有Magento 1.7.0.2德国网站.如何将管理面板默认更改为英文?(我知道我可以从下拉列表中选择语言,但是我希望它默认设置为英语)
我System.Management.Automation.Runspaces用来执行PowerShell脚本.有没有一个选项我可以读取给定脚本的退出代码?
using System.IO;
using System.Management.Automation.Runspaces;
using System.Collections.ObjectModel;
using System.Management.Automation;
namespace PowerShell
{
public class PowerShellExecuter
{
public Collection<PSObject> RunPsScript(string psScriptFile)
{
string psScript;
if (File.Exists(psScriptFile))
{
psScript = File.ReadAllText(psScriptFile);
}
else
{
throw new FileNotFoundException("Wrong path for the script file");
}
Runspace runSpace = RunspaceFactory.CreateRunspace();
runSpace.Open();
RunspaceInvoke runSpaceInvoker = new RunspaceInvoke(runSpace);
runSpaceInvoker.Invoke("Set-ExecutionPolicy Unrestricted");
Pipeline pipeLine = runSpace.CreatePipeline();
pipeLine.Commands.AddScript(psScript);
pipeLine.Commands.Add("Out-String");
Collection<PSObject> returnObjects = pipeLine.Invoke();
runSpace.Close();
return returnObjects;
}
}
}
Run Code Online (Sandbox Code Playgroud) 如何将string []解析为中间有空格的字符串如何重构此代码?
internal string ConvertStringArrayToString(string[] array)
{
StringBuilder builder = new StringBuilder();
builder.Append(array[0]);
for (int i = 1; i < array.Length; i++)
{
builder.Append(' ');
builder.Append(array[i]);
}
return builder.ToString();
}
Run Code Online (Sandbox Code Playgroud) 我有一个看起来像这样的方法:
public void UpdateTermInfo(List<Term> termInfoList)
{
foreach (Term termInfo in termInfoList)
{
UpdateTermInfo(termInfo);
}
m_xdoc.Save(FileName.FullName);
}
Run Code Online (Sandbox Code Playgroud)
Resharper建议我改变方法签名IEnumerable<Term>而不是List<Term>.这样做有什么好处?
我很熟悉一个线程中抛出的异常通常无法在另一个线程中捕获的事实.我怎样才能将错误转移到主线程?
public static void Main()
{
new Thread (Go).Start();
}
static void Go()
{
try
{
// ...
throw null; // The NullReferenceException will get caught below
// ...
}
catch (Exception ex)
{
// Typically log the exception, and/or signal another thread
// that we've come unstuck
// ...
}
}
Run Code Online (Sandbox Code Playgroud) 我想知道重构代码的最佳实践是什么样的:
应该在哪里设置退出标准,以及最佳做法是什么
private static bool Foo()
{
bool result = false;
if (DoMehod1())
{
if (DoMehod2())
{
if (DoMethod3())
{
result = true;
}
else
{
Console.WriteLine("DoMethod3 Failed");
}
}
else
{
Console.WriteLine("DoMethod2 Failed");
}
}
else
{
Console.WriteLine("DoMethod1 Failed");
}
return result;
}
Run Code Online (Sandbox Code Playgroud)
谢谢
我有以下代码,工作正常
function getFooObj() {
$.ajax({
type: "POST",
url: "Dummy.aspx/GetFooObj",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (result) {
alert('good');
}
});
}
[WebMethod]
public static FooObj GetFooObj ()
{
// some code that returns FooObj
}
Run Code Online (Sandbox Code Playgroud)
我的问题是,如果我希望我的WebMethod不是静态的,我怎么能从JS调用它?
[WebMethod]
public FooObj GetFooObj ()
{
// some code that returns FooObj
}
Run Code Online (Sandbox Code Playgroud) 我有一些客户端代码以下列格式发送日期 "1/31/2013 11:34:28 AM";
我试图将其转换为DateTime对象
string dateRequest = "1/31/2013 11:34:28 AM";
DateTime dateTime = DateTime.Parse(dateRequest);
Run Code Online (Sandbox Code Playgroud)
这个抛出
字符串未被识别为有效的DateTime.
我该如何施展它?
c# ×8
refactoring ×2
.net ×1
asp.net ×1
debugging ×1
interface ×1
javascript ×1
log4net ×1
magento ×1
powershell ×1
resharper ×1