本文整理汇总了C#中System.Collections.Specialized.NameValueCollection.Set方法的典型用法代码示例。如果您正苦于以下问题:C# NameValueCollection.Set方法的具体用法?C# NameValueCollection.Set怎么用?C# NameValueCollection.Set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Specialized.NameValueCollection
的用法示例。
在下文中一共展示了NameValueCollection.Set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToModelTest
public void ToModelTest()
{
var collection = new NameValueCollection();
collection.Set("DecimalNullableValue", "");
collection.Set("DecimalValue", "10");
var model = HttpRequestExtension.ToModel(collection, new NullableModel()) as NullableModel;
Assert.AreEqual(null, model.DecimalNullableValue);
Assert.AreEqual(10, model.DecimalValue);
}
示例2: SubComplexPropertyIndexFormat
public void SubComplexPropertyIndexFormat()
{
NameValueCollection nv = new NameValueCollection();
nv.Set("IP", "192.168.8.91");
nv.Set("UserName", "wangqj");
ComplexObject obj = new ComplexObject { Headers = nv };
string htmlContent = new MailTemplet(@"Hello,{Request.Headers[""IP""].Length}, TotalCount:{Request.Headers.Count}!").SetVariable("Request", obj)
.ToHtmlContent();
//Console.Write(htmlContent);
Debug.Assert(htmlContent.Equals("Hello,12, TotalCount:2!"));
}
示例3: PublishAction
public string PublishAction(string action, string objectType, string objectUrl)
{
requireAuthorization();
NameValueCollection parameters = new NameValueCollection();
parameters.Set(objectType, objectUrl);
return this.Publish("me", this.applicationNamespace + ":" + action, parameters);
}
示例4: SendNotifications
internal static void SendNotifications(IEnumerable<string> apiKeys, string application, string header, string message)
{
var data = new NameValueCollection();
data["AuthorizationToken"] = "";
data["Body"] = message;
data["IsImportant"] = IsImportant;
data["IsSilent"] = IsSilent;
data["Source"] = application;
data["TimeToLive"] = TimeToLive;
data["Title"] = header;
if (!Validate(data))
{
return;
}
foreach (var apiKey in apiKeys)
{
using (var client = new WebClient())
{
data.Set("AuthorizationToken", apiKey);
client.Headers[HttpRequestHeader.ContentType] = RequestContentType;
client.UploadValuesAsync(new Uri(RequestUrl), data);
}
}
}
示例5: ExpectedRavenDbCallsAreMade
public void ExpectedRavenDbCallsAreMade()
{
// Arrange
string expectedAppName = "You are everything ... to me";
string appPath = "Application path";
var subject = TestStoreProviderFactory.SetupStoreProvider(appPath, MockHostingProvider);
NameValueCollection keyPairs = new NameValueCollection();
keyPairs.Set("applicationName", expectedAppName);
object lockId = 0;
string providedSessionId = "A sessionId";
SessionStateDocument sessionObject = TestSessionDocumentFactory.CreateSessionStateDocument(providedSessionId, expectedAppName);
sessionObject.Expiry = DateTime.UtcNow.AddDays(1);
var sessionItems = new SessionStateItemCollection();
sessionItems["ACar"] = new Car("A6", "Audi");
sessionObject.SessionItems = subject.Serialize(sessionItems);
SessionStateStoreData item = RavenSessionStateStoreProvider.Deserialize(null, sessionObject.SessionItems, 10);
MockDocumentSession.Setup(cmd => cmd.Store(It.IsAny<SessionStateDocument>())).Verifiable();
MockDocumentSession.Setup(cmd => cmd.SaveChanges()).Verifiable();
subject.Initialize("A name", keyPairs, MockDocumentStore.Object);
// Act
subject.CreateUninitializedItem(new HttpContext(new SimpleWorkerRequest("", "", "", "", new StringWriter())), providedSessionId, 10);
// Assert
MockDocumentSession.Verify(cmd => cmd.Store(It.IsAny<SessionStateDocument>()), Times.Once());
MockDocumentSession.Verify(cmd => cmd.SaveChanges(), Times.Once());
}
开发者ID:CorporateActionMan,项目名称:RavenDbSessionStateStoreProvider,代码行数:35,代码来源:CreateUninitializedItemTests.cs
示例6: TestFedeo
public void TestFedeo()
{
XmlSerializer ser = new XmlSerializer(typeof(OpenSearchDescription));
var osd = (OpenSearchDescription)ser.Deserialize(XmlReader.Create(new FileStream("../Samples/fedeo-osdd.xml", FileMode.Open, FileAccess.Read)));
GenericOpenSearchable os = new GenericOpenSearchable(osd, new OpenSearchEngine());
OpenSearchEngine ose = new OpenSearchEngine();
ose.LoadPlugins();
var url = new OpenSearchUrl("http://fedeo.esa.int/opensearch/request/?httpAccept=application/atom%2Bxml&parentIdentifier=urn:eop:DLR:EOWEB:Geohazard.Supersite.TerraSAR-X_SSC&startDate=2014-01-01T00:00:00Z&endDate=2015-04-20T00:00:00Z&recordSchema=om");
NameValueCollection parameters = new NameValueCollection();
parameters.Set("maximumRecords", "1");
NameValueCollection nvc;
if (url != null)
nvc = HttpUtility.ParseQueryString(url.Query);
else
nvc = new NameValueCollection();
parameters.AllKeys.SingleOrDefault(k =>
{
nvc.Set(k, parameters[k]);
return false;
});
var request = OpenSearchRequest.Create(os, os.GetQuerySettings(ose), nvc);
}
示例7: DocumentStoreNotProvided_ValidConnectionStringDoesNotThrowConfigurationErrorsException
public void DocumentStoreNotProvided_ValidConnectionStringDoesNotThrowConfigurationErrorsException()
{
// Arrange
string expectedAppName = "You are everything ... to me";
string appPath = "Application path";
string connectionStringName = "AConnectionString";
var subject = TestStoreProviderFactory.SetupStoreProvider(appPath, MockHostingProvider);
NameValueCollection keyPairs = new NameValueCollection();
keyPairs.Set("applicationName", expectedAppName);
keyPairs.Set("connectionStringName", connectionStringName);
// Act
TestDelegate act = () => subject.Initialize("", keyPairs, null);
// Assert
Assert.DoesNotThrow(act, "null connection string should throw configuration errors");
}
示例8: DocumentStoreNotProvided_ValidConnectionStringEnsuresDocumentStoreCreated
public void DocumentStoreNotProvided_ValidConnectionStringEnsuresDocumentStoreCreated()
{
// Arrange
string expectedAppName = "You are everything ... to me";
string appPath = "Application path";
string connectionStringName = "AConnectionString";
var subject = TestStoreProviderFactory.SetupStoreProvider(appPath, MockHostingProvider);
NameValueCollection keyPairs = new NameValueCollection();
keyPairs.Set("applicationName", expectedAppName);
keyPairs.Set("connectionStringName", connectionStringName);
IDocumentStore docStore = null;
// Act
subject.Initialize("", keyPairs, docStore);
// Assert
Assert.IsNotNull(subject.DocumentStore);
}
示例9: ConfigNotProvidedThrowsArgumentNullException
public void ConfigNotProvidedThrowsArgumentNullException()
{
// Arrange
string expectedAppName = "You are everything ... to me";
string appPath = "Application path";
string connectionStringName = "AConnectionString";
var subject = TestStoreProviderFactory.SetupStoreProvider(appPath, MockHostingProvider);
NameValueCollection keyPairs = new NameValueCollection();
keyPairs.Set("applicationName", expectedAppName);
keyPairs.Set("connectionStringName", connectionStringName);
IDocumentStore docStore = null;
// Act
TestDelegate act = () => subject.Initialize("", null, docStore);
// Assert
Assert.Throws<ArgumentNullException>(act, "Config cannot be null");
}
示例10: UrlSet
public static string UrlSet(this HtmlHelper helper, HttpRequestBase request, string queryName, object queryValue)
{
if (queryName != null && queryValue != null)
{
string path = request.Path;
NameValueCollection query = new NameValueCollection(request.QueryString);
query.Set(queryName, queryValue.ToString());
return CreateUrl(path, query);
}
return request.RawUrl;
}
示例11: Delete
public object Delete(TypeDeleteRequest request)
{
IOpenSearchableElasticType type = ecf.GetOpenSearchableElasticTypeByNameOrDefault(request.IndexName, request.TypeName);
NameValueCollection parameters = new NameValueCollection();
parameters.Set("uid", request.Id);
var results = OpenSearchService.QueryResult(type, parameters);
var response = Delete(type, results);
return new HttpResult(response, "application/json");
}
示例12: SetNameValues
/// <summary>
/// 读取文件中的键值对,加载进内存集合
/// </summary>
/// <param name="doc">文档对象模型</param>
/// <param name="mv">键值对集合</param>
public static void SetNameValues(XmlDocument doc,NameValueCollection mv)
{
XmlElement root = doc.DocumentElement;
foreach (XmlNode node in root.ChildNodes)
{
if (node.Attributes != null && node.Attributes["key"].Value != null)
{
string key = node.Attributes["key"].Value.ToString();
string value = node.Attributes["value"].Value.ToString();
mv.Set(key, value);
}
}
}
示例13: Get
public object Get(OpenSearchQueryRequest request)
{
IOpenSearchableElasticType type = ecf.GetOpenSearchableElasticTypeByNameOrDefault(request.IndexName, request.TypeName);
NameValueCollection parameters = new NameValueCollection(Request.QueryString);
if (request.AdditionalParameters != null) {
foreach (var key in request.AdditionalParameters.AllKeys) {
parameters.Set(key, request.AdditionalParameters[key]);
}
}
return OpenSearchService.Query(type, parameters);
}
示例14: InjectSecretsInto
public void InjectSecretsInto(NameValueCollection collection)
{
var secretReader = _secretReaderFactory.CreateSecretReader();
var secretInjector = _secretReaderFactory.CreateSecretInjector(secretReader);
IEnumerable keys = new List<string>(collection.AllKeys);
foreach (string key in keys)
{
var framedString = collection[key];
var newValue = secretInjector.InjectAsync(framedString).Result;
collection.Set(key, newValue);
}
}
示例15: WhenAttributeIsWhitespaceNameSetToHostingEnvironmentApplicationPath
public void WhenAttributeIsWhitespaceNameSetToHostingEnvironmentApplicationPath()
{
// Arrange
string expectedAppPath = "Candy Girl you are my world";
var subject = TestStoreProviderFactory.SetupStoreProvider(expectedAppPath, MockHostingProvider);
NameValueCollection keyPairs = new NameValueCollection();
keyPairs.Set("applicationName", " ");
// Act
subject.Initialize("", keyPairs, MockDocumentStore.Object);
// Assert
Assert.AreEqual(expectedAppPath, subject.ApplicationName);
}