コード例 #1
0
        public void SingleNameValuePair()
        {
            NameValuePairCollection nameValuePairs = new NameValuePairCollection("a=b");
            NameValuePair           pair           = nameValuePairs[0];

            Assert.AreEqual(1, nameValuePairs.Count);
            Assert.AreEqual("b", nameValuePairs.GetValue("a"));
            Assert.AreEqual("a", pair.Name);
            Assert.AreEqual("b", pair.Value);
        }
コード例 #2
0
		/// <summary>
		/// Sets the values of the parameters specified in the collection
		/// </summary>
		/// <param name="collection">Collection containg the parametes to set</param>
		public void GetValues(NameValuePairCollection collection)
		{
			if (collection.ContainsKey(MaxConns))
				collection.GetPair(MaxConns).Value = this.MaximumConnections.ToString();

			if (collection.ContainsKey(MaxReqs))
				collection.GetPair(MaxReqs).Value = this.MaximumRequests.ToString();

			if (collection.ContainsKey(MpxsConns))
				collection.GetPair(MpxsConns).Value = this.SupportMultiplexedConnection ? "1" : "0";
		}
コード例 #3
0
        public void TwoNameValuePairs()
        {
            NameValuePairCollection nameValuePairs = new NameValuePairCollection("a=1;b=2");
            NameValuePair           pair1          = nameValuePairs[0];
            NameValuePair           pair2          = nameValuePairs[1];

            Assert.AreEqual(2, nameValuePairs.Count);
            Assert.AreEqual("1", nameValuePairs.GetValue("a"));
            Assert.AreEqual("a", pair1.Name);
            Assert.AreEqual("1", pair1.Value);
            Assert.AreEqual("a=1", pair1.ToString());
            Assert.AreEqual("2", nameValuePairs.GetValue("b"));
            Assert.AreEqual("b", pair2.Name);
            Assert.AreEqual("2", pair2.Value);
            Assert.AreEqual("b=2", pair2.ToString());
            Assert.AreEqual("a=1;b=2", nameValuePairs.GetList());
        }
コード例 #4
0
        public void EmptyString()
        {
            NameValuePairCollection nameValuePairs = new NameValuePairCollection(String.Empty);

            Assert.AreEqual(0, nameValuePairs.Count);
        }
コード例 #5
0
 public void SetUpFixture()
 {
     tags = new NameValuePairCollection();
     tags.Add(new NameValuePair("Test", "Value"));
     tags.Add(new NameValuePair("DATADIR", "Bitmaps/bin"));
 }
コード例 #6
0
		/// <summary>
		/// Send a reply to a GetValues request
		/// </summary>
		/// <param name="data">GetValues message body</param>
		private void SendGetValuesResult(ByteArray data)
		{
			NameValuePairCollection collection;

			//reads the collection
			using (InputStream stream = new InputStream(data))
			{
				collection = new NameValuePairCollection(stream);
			}
			
			//sets the value
			this.Properties.GetValues(collection);

			//sends the collection
			using(MemoryStream stream = new MemoryStream())
			{
				using(BinaryWriter writer = new BinaryWriter(stream))
				{
					foreach(NameValuePair item in collection)
						item.Encode(writer);

					var body = new ByteArray(stream.ToArray());
					this.SendMessage(new Message(MessageType.GetValuesResult, 0, body));
				}
			}
		}