当前位置: 首页>>代码示例>>C#>>正文


C# NameValueCollection.Set方法代码示例

本文整理汇总了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);
 }
开发者ID:Wangzr,项目名称:TrioFramework,代码行数:9,代码来源:RequestExtensionTest.cs

示例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!"));
        }
开发者ID:vbyte,项目名称:fmq,代码行数:13,代码来源:TempletTest.cs

示例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);
		}
开发者ID:kisspa,项目名称:spring-net-social-facebook,代码行数:7,代码来源:OpenGraphTemplate.cs

示例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);
                }
            }
        }
开发者ID:Giecha,项目名称:AlarmWorkflow,代码行数:26,代码来源:Pushalot.cs

示例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);
        }
开发者ID:Terradue,项目名称:DotNetOpenSearch,代码行数:28,代码来源:TestOsddAttribute.cs

示例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");
        }
开发者ID:CorporateActionMan,项目名称:RavenDbSessionStateStoreProvider,代码行数:17,代码来源:InitializeTests.cs

示例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);
        }
开发者ID:CorporateActionMan,项目名称:RavenDbSessionStateStoreProvider,代码行数:19,代码来源:InitializeTests.cs

示例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");
        }
开发者ID:CorporateActionMan,项目名称:RavenDbSessionStateStoreProvider,代码行数:19,代码来源:InitializeTests.cs

示例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;
 }
开发者ID:coolnameismy,项目名称:dev-tips,代码行数:11,代码来源:HtmlHelpers.cs

示例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");
        }
开发者ID:Terradue,项目名称:DotNetElasticCas,代码行数:11,代码来源:TypesService.cs

示例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);
         }
     }
 }
开发者ID:felix-tien,项目名称:TechLab,代码行数:18,代码来源:FileHelper.cs

示例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);
        }
开发者ID:Terradue,项目名称:DotNetElasticCas,代码行数:13,代码来源:OpenSearchQueryRequestService.cs

示例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);
            }
        }
开发者ID:NuGet,项目名称:NuGet.Services.Dashboard,代码行数:14,代码来源:ConfigurationProcessor.cs

示例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);
        }
开发者ID:CorporateActionMan,项目名称:RavenDbSessionStateStoreProvider,代码行数:14,代码来源:ApplicationNameTests.cs


注:本文中的System.Collections.Specialized.NameValueCollection.Set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。