本文整理汇总了C#中System.Collections.Specialized.NameValueCollection类的典型用法代码示例。如果您正苦于以下问题:C# System.Collections.Specialized.NameValueCollection类的具体用法?C# System.Collections.Specialized.NameValueCollection怎么用?C# System.Collections.Specialized.NameValueCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
System.Collections.Specialized.NameValueCollection类属于命名空间,在下文中一共展示了System.Collections.Specialized.NameValueCollection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Deserialize
public void Deserialize(System.IO.TextReader rdr, Serializer serializer)
{
string name, value, rigthPart;
var parameters = new System.Collections.Specialized.NameValueCollection();
while (rdr.Property(out name, out value, out rigthPart, parameters) && !string.IsNullOrEmpty(name)) {
switch (name.ToUpper()) {
case "CLASS": Class = value.ToEnum<Classes>(); break;
case "STATUS": Status = value.ToEnum<Statuses>(); break;
case "UID": UID = value; break;
case "ORGANIZER":
Organizer = new Contact();
Organizer.Deserialize(value, parameters);
break;
case "CATEGORIES":
Categories = value.SplitEscaped().ToList();
break;
case "DESCRIPTION": Description = value; break;
case "SEQUENCE": Sequence = value.ToInt(); break;
case "LAST-MODIFIED": LastModified = value.ToDateTime(); break;
case "DTSTAMP": DTSTAMP = value.ToDateTime(); break;
case "END": return;
default:
Properties.Add(Tuple.Create(name, value, parameters));
break;
}
}
}
示例2: ProcessRequest
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "image/png";
string prefFilter = context.Request["pref"] ?? "全て";
string cityFilter = context.Request["city"] ?? "全て";
string categoryFilter = context.Request["category"] ?? "全て";
string productFilter = context.Request["product"] ?? "全て";
string publishDayFilter = context.Request["publish"] ?? "全て";
string pickDayFilter = context.Request["pick"] ?? "全て";
string sortItem = context.Request["sort"] ?? "1";
string widthString = context.Request["width"] ?? "";
string heightString = context.Request["height"] ?? "";
int width, height;
if (Int32.TryParse(widthString, out width) == false) width = 600;
if (Int32.TryParse(heightString, out height) == false) height = 300;
width = Math.Min(1000, Math.Max(300, width));
height = Math.Min(600, Math.Max(150, height));
var list = Common.GetQuery(prefFilter, cityFilter, categoryFilter, productFilter, publishDayFilter, pickDayFilter, sortItem);
var param = list.Item1.ToList().PrepareChartParam(width, height);
using (var cl = new System.Net.WebClient())
{
var values = new System.Collections.Specialized.NameValueCollection();
foreach (var item in param)
{
values.Add(item.Substring(0, item.IndexOf('=')), item.Substring(item.IndexOf('=') + 1));
}
var resdata = cl.UploadValues("http://chart.googleapis.com/chart?chid=1", values);
context.Response.OutputStream.Write(resdata, 0, resdata.Length);
}
}
示例3: Deserialize
public void Deserialize(System.IO.TextReader rdr, Serializer serializer) {
string name, value;
var parameters = new System.Collections.Specialized.NameValueCollection();
while (rdr.Property(out name, out value, parameters) && !string.IsNullOrEmpty(name)) {
switch (name.ToUpper()) {
case "UID": UID = value; break;
case "ORGANIZER":
Organizer = new Contact();
Organizer.Deserialize(value, parameters);
break;
case "SEQUENCE": Sequence = value.ToInt(); break;
case "LAST-MODIFIED": LastModified = value.ToDateTime(); break;
case "DTSTART": LastModified = value.ToDateTime(); break;
case "DTEND": LastModified = value.ToDateTime(); break;
case "DTSTAMP": DTSTAMP = value.ToDateTime(); break;
case "FREEBUSY":
var parts = value.Split('/');
Details.Add(new DateTimeRange {
From = parts.FirstOrDefault().ToDateTime(),
To = parts.ElementAtOrDefault(1).ToDateTime()
});
break;
case "END": return;
default:
Properties.Add(Tuple.Create(name, value, parameters));
break;
}
}
}
示例4: DataBuilderFactory
static DataBuilderFactory()
{
_dataBuilders = new System.Collections.Specialized.NameValueCollection();
_assemblies = new List<string>();
_assemblies.Add(Xy.AppSetting.BinDir + "Xy.Web.dll");
LoadControl(ControlFactory.GetConfig("Data"));
}
示例5: Api
public static string Api(string Temperature,string Humidity)
{
string url = (string)Properties.Settings.Default["ApiAddress"];
string resText = "";
try {
System.Net.WebClient wc = new System.Net.WebClient();
System.Collections.Specialized.NameValueCollection ps =
new System.Collections.Specialized.NameValueCollection();
ps.Add("MachineName", (string)Properties.Settings.Default["MachineName"]);
ps.Add("Temperature", Temperature);
ps.Add("Humidity", Humidity);
byte[] ResData = wc.UploadValues(url, ps);
wc.Dispose();
resText = System.Text.Encoding.UTF8.GetString(ResData);
if (resText != "OK")
{
return "APIエラー";
}
}
catch (Exception ex){
return ex.ToString();
}
return null;
}
示例6: Initialize
public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config) {
// Validate arguments
if (config == null) throw new ArgumentNullException("config");
if (string.IsNullOrEmpty(name)) name = "SimpleSqlProfileProvider";
if (String.IsNullOrEmpty(config["description"])) {
config.Remove("description");
config.Add("description", "PAB simple SQL profile provider");
}
// Initialize base class
base.Initialize(name, config);
// Basic init
this.configuration = config;
this.applicationName = GetConfig("applicationName", "");
// Initialize connection string
ConnectionStringSettings ConnectionStringSettings = ConfigurationManager.ConnectionStrings[config["connectionStringName"]];
if (ConnectionStringSettings == null || ConnectionStringSettings.ConnectionString.Trim() == "") throw new ProviderException("Connection string cannot be blank.");
this.connectionString = ConnectionStringSettings.ConnectionString;
// Initialize table name
this.tableName = GetConfig("tableName", "Profiles");
if (!IsValidDbObjectName(this.tableName)) throw new ProviderException("Table name contains illegal characters.");
// Initialize key column name
this.keyColumnName = GetConfig("keyColumnName", "UserName");
if (!IsValidDbObjectName(this.keyColumnName)) throw new ProviderException("Key column name contains illegal characters.");
// Initialize last update column name
this.lastUpdateColumnName = GetConfig("lastUpdateColumnName", "LastUpdate");
if (!IsValidDbObjectName(this.lastUpdateColumnName)) throw new ProviderException("Last update column name contains illegal characters.");
}
示例7: UsernamePassword
public void UsernamePassword(string clientId, string clientSecret, string username, string password, string tokenRequestEndpointUrl)
{
if (string.IsNullOrEmpty(clientId)) throw new ArgumentNullException("clientId");
if (string.IsNullOrEmpty(clientSecret)) throw new ArgumentNullException("clientSecret");
if (string.IsNullOrEmpty(username)) throw new ArgumentNullException("username");
if (string.IsNullOrEmpty(password)) throw new ArgumentNullException("password");
if (string.IsNullOrEmpty(tokenRequestEndpointUrl)) throw new ArgumentNullException("tokenRequestEndpointUrl");
if (!Uri.IsWellFormedUriString(tokenRequestEndpointUrl, UriKind.Absolute)) throw new FormatException("tokenRequestEndpointUrl");
var content = new System.Collections.Specialized.NameValueCollection
{
{"grant_type", "password"},
{"client_id", clientId},
{"client_secret", clientSecret},
{"username", username},
{"password", password}
};
AuthToken = new AuthToken();
try
{
var responseBytes = WebClient.UploadValues(tokenRequestEndpointUrl, "POST", content);
var responseBody = Encoding.UTF8.GetString(responseBytes);
AuthToken = JsonConvert.DeserializeObject<AuthToken>(responseBody);
}
catch (Exception ex)
{
AuthToken.Errors = ex.Message;
}
}
示例8: OnBeforePopup
protected override bool OnBeforePopup(CefBrowser browser, CefFrame frame, string targetUrl, string targetFrameName, CefPopupFeatures popupFeatures, CefWindowInfo windowInfo, ref CefClient client, CefBrowserSettings settings, ref bool noJavascriptAccess)
{
bool res = false;
if (!string.IsNullOrEmpty(targetUrl))
{
if (webBrowser.selfRequest != null)
{
CefRequest req = CefRequest.Create();
req.FirstPartyForCookies = webBrowser.selfRequest.FirstPartyForCookies;
req.Options = webBrowser.selfRequest.Options;
/*CefPostData postData = CefPostData.Create();
CefPostDataElement element = CefPostDataElement.Create();
int index = targetUrl.IndexOf("?");
string url = targetUrl.Substring(0, index);
string data = targetUrl.Substring(index + 1);
byte[] bytes = Encoding.UTF8.GetBytes(data);
element.SetToBytes(bytes);
postData.Add(element);
*/
System.Collections.Specialized.NameValueCollection h = new System.Collections.Specialized.NameValueCollection();
h.Add("Content-Type", "application/x-www-form-urlencoded");
req.Set(targetUrl, webBrowser.selfRequest.Method, null, webBrowser.selfRequest.GetHeaderMap());
webBrowser.selfRequest = req;
}
//webBrowser.selfRequest.Set(targetUrl, webBrowser.selfRequest.Method, webBrowser.selfRequest.PostData, webBrowser.selfRequest.GetHeaderMap());
res = webBrowser.OnNewWindow(targetUrl);
if (res)
return res;
}
res = base.OnBeforePopup(browser, frame, targetUrl, targetFrameName, popupFeatures, windowInfo, ref client, settings, ref noJavascriptAccess);
return res;
}
示例9: GetAssemblyEventMapping
private System.Collections.Specialized.NameValueCollection GetAssemblyEventMapping(System.Reflection.Assembly assembly, Hl7Package package)
{
System.Collections.Specialized.NameValueCollection structures = new System.Collections.Specialized.NameValueCollection();
using (System.IO.Stream inResource = assembly.GetManifestResourceStream(package.EventMappingResourceName))
{
if (inResource != null)
{
using (System.IO.StreamReader sr = new System.IO.StreamReader(inResource))
{
string line = sr.ReadLine();
while (line != null)
{
if ((line.Length > 0) && ('#' != line[0]))
{
string[] lineElements = line.Split(' ', '\t');
structures.Add(lineElements[0], lineElements[1]);
}
line = sr.ReadLine();
}
}
}
}
return structures;
}
示例10: Process
/// <summary>
///
/// </summary>
/// <param name="userAgent"></param>
/// <param name="initialCapabilities"></param>
/// <returns></returns>
public System.Web.Configuration.CapabilitiesResult Process(string userAgent, System.Collections.IDictionary initialCapabilities)
{
System.Collections.Specialized.NameValueCollection header;
header = new System.Collections.Specialized.NameValueCollection(1);
header.Add("User-Agent", userAgent);
return Process(header, initialCapabilities);
}
示例11: CreateControllerContext
//private HtmlHelper CreateHelper()
//{
// return new HtmlHelper(new ViewContext(ControllerContext, new DummyView(), new ViewDataDictionary(), new TempDataDictionary(), new StringWriter()), new CustomViewDataContainer());
//}
private static ControllerContext CreateControllerContext()
{
string host = "www.google.com";
string proto = "http";
string userIP = "127.0.0.1";
var headers = new System.Collections.Specialized.NameValueCollection {
{"Host", host},
{"X-Forwarded-Proto", proto},
{"X-Forwarded-For", userIP}
};
var httpRequest = Substitute.For<HttpRequestBase>();
httpRequest.Url.Returns(new Uri(proto + "://" + host));
httpRequest.Headers.Returns(headers);
var httpContext = Substitute.For<HttpContextBase>();
httpContext.Request.Returns(httpRequest);
var controllerContext = new ControllerContext
{
HttpContext = httpContext
};
return controllerContext;
}
示例12: GetWebContent
public string GetWebContent(string Url, string pagenum, string cat)
{
string strResult = "";
try
{
WebClient WebClientObj = new WebClient();
System.Collections.Specialized.NameValueCollection PostVars = new System.Collections.Specialized.NameValueCollection();
PostVars.Add("Cat", cat);
PostVars.Add("mnonly", "0");
PostVars.Add("newproducts", "0");
PostVars.Add("ColumnSort", "0");
PostVars.Add("page", pagenum);
PostVars.Add("stock", "0");
PostVars.Add("pbfree", "0");
PostVars.Add("rohs", "0");
byte[] byRemoteInfo = WebClientObj.UploadValues(Url, "POST", PostVars);
//StreamReader streamRead = new StreamReader(byRemoteInfo.ToString(), Encoding.Default);
//FileStream fs = new FileStream(@"D:\\gethtml.txt", FileMode.Create);
//BinaryWriter sr = new BinaryWriter(fs);
//sr.Write(byRemoteInfo, 0, byRemoteInfo.Length);
//sr.Close();
//fs.Close();
strResult = Encoding.Default.GetString(byRemoteInfo);
}
catch (Exception ex)
{
throw ex;
}
return strResult;
}
示例13: UpdateDNSIP
public bool UpdateDNSIP(string rec_id, string IP, string name, string service_mode, string ttl)
{
string url = "https://www.cloudflare.com/api_json.html";
System.Net.WebClient wc = new System.Net.WebClient();
//NameValueCollectionの作成
System.Collections.Specialized.NameValueCollection ps = new System.Collections.Specialized.NameValueCollection();
//送信するデータ(フィールド名と値の組み合わせ)を追加
ps.Add("a", "rec_edit");
ps.Add("tkn", KEY);
ps.Add("id", rec_id);
ps.Add("email", EMAIL);
ps.Add("z", DOMAIN);
ps.Add("type", "A");
ps.Add("name", name);
ps.Add("content", IP);
ps.Add("service_mode", service_mode);
ps.Add("ttl", ttl);
//データを送信し、また受信する
byte[] resData = wc.UploadValues(url, ps);
wc.Dispose();
string resText = System.Text.Encoding.UTF8.GetString(resData);
Clipboard.SetText(resText);
return false;
}
示例14: ControlFactory
static ControlFactory()
{
_controls = new System.Collections.Specialized.NameValueCollection();
_assemblies = new List<string>();
_config = new Dictionary<string, System.Xml.XmlNodeList>();
LoadControl();
}
示例15: Main
static void Main(string[] args)
{
using (WebClient client = new WebClient())
{
System.Collections.Specialized.NameValueCollection reqparm = new System.Collections.Specialized.NameValueCollection();
reqparm.Add("username", "Matija");
reqparm.Add("passwd", "1234");
byte[] bytes = client.UploadValues("http://ates-test.algebra.hr/iis/testSubmit.aspx", "POST", reqparm);
string body = Encoding.UTF8.GetString(bytes);
Console.WriteLine(body);
WebHeaderCollection wcHeaderCollection = client.ResponseHeaders;
Console.WriteLine("\nHeaders:\n");
for (int i = 0; i < wcHeaderCollection.Count; i++)
{
Console.WriteLine(wcHeaderCollection.GetKey(i) + " = " + wcHeaderCollection.Get(i));
}
}
Console.WriteLine();
using (WebClient client = new WebClient())
{
string reply = client.DownloadString(@"http://ates-test.algebra.hr/iis/testSubmit.aspx?username=Matija&passwd=1234");
Console.WriteLine(reply);
WebHeaderCollection wcHeaderCollection = client.ResponseHeaders;
Console.WriteLine("\nHeaders:\n");
for (int i = 0; i < wcHeaderCollection.Count; i++)
{
Console.WriteLine(wcHeaderCollection.GetKey(i) + " = " + wcHeaderCollection.Get(i));
}
Console.ReadKey();
}
}