我想使用Newtonsoft.Json将CookieContainer导出到JSON,但遗憾的是CookieContainer没有枚举器或东西,所以我不能循环使用它...
编辑:使用我发布的解决方案,它将是这样的:
private static void Main(string[] args)
{
CookieContainer cookieContainer = new CookieContainer();
cookieContainer.Add(new Cookie("name1", "value1", "/", ".testdomain1.com"));
cookieContainer.Add(new Cookie("name2", "value1", "/path1/", ".testdomain1.com"));
cookieContainer.Add(new Cookie("name2", "value1", "/path1/path2/", ".testdomain1.com"));
cookieContainer.Add(new Cookie("name1", "value1", "/", ".testdomain2.com"));
cookieContainer.Add(new Cookie("name2", "value1", "/path1/", ".testdomain2.com"));
cookieContainer.Add(new Cookie("name2", "value1", "/path1/path2/", ".testdomain2.com"));
CookieCollection cookies = GetAllCookies(cookieContainer);
Console.WriteLine(JsonConvert.SerializeObject(cookies, Formatting.Indented));
Console.Read();
}
Run Code Online (Sandbox Code Playgroud) 我定义的选项越多,在必须修改它们时就必须输入的内容越多.所以我正在寻找更短版本的Properties.Settings.Default.varX
我试过了:
Properties.Settings settings = Properties.Settings.Default;
settings.var1 = "x";
settings.var2 = "y";
settings.var3 = "Z";
Properties.Settings.Default = settings;
Run Code Online (Sandbox Code Playgroud)
但是Properties.Settings.Default是只读的,Save函数没有重载.
那么除了一次又一次地键入Properties.Settings.Default之外还有其他方法吗?
从github下载的zip的文件夹名称就像%repository-name%-master,但是我需要那个文件夹%repository-name%
可以这样做吗?
我正在尝试使用php的soap服务,但似乎php创建的请求格式无法被服务解释.我到目前为止的简单例子:
ini_set("soap.wsdl_cache_enabled", "0");
$client = new SoapClient('http://publicbetawebservices.hotel.de/V2_8/FreeHotelSearchWebService.svc?WSDL',array("trace"=>1));
try {
$response = $client->GetWebservicesVersion();
} catch(Exception $e){
print_r($e);
}
Run Code Online (Sandbox Code Playgroud)
输出:
SoapFault Object
(
[message:protected] => Unable to parse URL
[string:Exception:private] =>
[code:protected] => 0
[file:protected] => /var/www/test.php
[line:protected] => 6
[trace:Exception:private] => Array
(
[0] => Array
(
[function] => __doRequest
[class] => SoapClient
[type] => ->
[args] => Array
(
[0] => <?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://webservices.hotel.de/V2_8/"><SOAP-ENV:Body><ns1:GetWebservicesVersion/></SOAP-ENV:Body></SOAP-ENV:Envelope>
[1] =>
[2] => http://webservices.hotel.de/V2_8/IBaseService/GetWebservicesVersion
[3] => 1
[4] => 0
)
) …Run Code Online (Sandbox Code Playgroud) 我的表单上有多组控件,它们在特定事件上一起更改......但每次更改都是相同的,只有控件的名称不同.
所以我必须这样做:
label1.Text = "ready";
label2.Text = "let's go";
label1.ForeColor = System.Drawing.Color.Green;
label2.ForeColor = System.Drawing.Color.LightGreen
textbox1.Enabled = true;
textbox2.Enabled = true;
button1.Enabled = true;
button2.Enabled = true;
Run Code Online (Sandbox Code Playgroud)
要么
label1.Text = "not ready";
label2.Text = "just waiting to get ready";
label1.ForeColor = System.Drawing.Color.Red;
label2.ForeColor = System.Drawing.Color.Orange;
textbox1.Enabled = false;
textbox2.Enabled = false;
button1.Enabled = false;
button2.Enabled = false;
Run Code Online (Sandbox Code Playgroud)
在每个事件中,但对于label3 + label4或label5 + label6等而不是.
所以我的想法是,如果可以将控件组放在类似于容器的东西中,然后使用容器作为参数调用方法.
喜欢:
setReady(container);
setNotReady(container);
Run Code Online (Sandbox Code Playgroud)
然后这个方法会做我想要的所有东西.
所以我的问题是,这样的方法将如何看起来像resp.如何以这种方式访问容器内的控件?或者是否有更好的方法来处理这样的事情?
我在选项对话框中有一个"恢复默认值"按钮,并且只想恢复在此表单中受影响的值,而不是整个Properties.Settings.Default
所以我尝试过:
var backup = Properties.Settings.Default;
Properties.Settings.Default.Reload();
overwriteControls();
Properties.Settings.Default = backup;
Run Code Online (Sandbox Code Playgroud)
但遗憾的是,由于备份似乎也发生了变化,因此无法正常工作Reload()?为什么以及如何正确地执行此操作?
c# ×4
winforms ×3
.net ×1
containers ×1
controls ×1
github ×1
grouping ×1
php ×1
settings ×1
shortcut ×1
soap ×1
soap-client ×1
web-services ×1
wsdl ×1