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


C# PropertyBag.GetValue方法代码示例

本文整理汇总了C#中PropertyBag.GetValue方法的典型用法代码示例。如果您正苦于以下问题:C# PropertyBag.GetValue方法的具体用法?C# PropertyBag.GetValue怎么用?C# PropertyBag.GetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PropertyBag的用法示例。


在下文中一共展示了PropertyBag.GetValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SerializationRoundtrip

		public void SerializationRoundtrip ()
		{
			var bag = new PropertyBag ();
			var t = new SerializableObject {
				SomeValue = "test1"
			};
			bag.SetValue ("foo", t);

			var w = new StringWriter ();
			var ser = new XmlDataSerializer (new DataContext ());
			ser.Serialize (w, bag);

			SerializableObject.CreationCount = 0;

			var data = w.ToString ();
			bag = ser.Deserialize<PropertyBag> (new StringReader (data));

			// SerializableObject is not instantiated if not queried
			Assert.AreEqual (0, SerializableObject.CreationCount);

			t = bag.GetValue<SerializableObject> ("foo");
			Assert.NotNull (t);
			Assert.AreEqual ("test1", t.SomeValue);
		}
开发者ID:pabloescribanoloza,项目名称:monodevelop,代码行数:24,代码来源:PropertyBagTests.cs

示例2: ProducesMetadata

        public void ProducesMetadata()
        {
            string document = "value,[Metadata]\n123,abc\n456,def";
            Func<TextReader> documentReaderProvider = delegate { return new StringReader(document); };
            CsvDataSet dataSet = new CsvDataSet(documentReaderProvider, false);

            dataSet.HasHeader = true;
            dataSet.DataLocationName = "<inline>";
            Assert.AreEqual("<inline>", dataSet.DataLocationName);

            DataBinding binding = new DataBinding(0, null);
            List<IDataItem> items = new List<IDataItem>(dataSet.GetItems(new DataBinding[] { binding }, true));

            Assert.AreEqual("123", items[0].GetValue(binding));
            PropertyBag map = DataItemUtils.GetMetadata(items[0]);
            Assert.AreEqual("<inline>(2)", map.GetValue(MetadataKeys.DataLocation));
            Assert.AreEqual("abc", map.GetValue("Metadata"));

            Assert.AreEqual("456", items[1].GetValue(binding));
            map = new PropertyBag();
            items[1].PopulateMetadata(map);
            Assert.AreEqual("<inline>(3)", map.GetValue(MetadataKeys.DataLocation));
            Assert.AreEqual("def", map.GetValue("Metadata"));
        }
开发者ID:rprouse,项目名称:mbunit-v3,代码行数:24,代码来源:CsvDataSetTest.cs

示例3: GetAndSetValue

        public void GetAndSetValue()
        {
            PropertyBag bag = new PropertyBag();

            Assert.IsNull(bag.GetValue("key"));

            bag.SetValue("key", "value");
            Assert.AreEqual("value", bag.GetValue("key"));

            bag.SetValue("key", "different value");
            Assert.AreEqual("different value", bag.GetValue("key"));

            bag.SetValue("key", null);
            Assert.IsNull(bag.GetValue("key"));

            bag.Add("key", "value1");
            bag.Add("key", "value2");
            Assert.AreEqual("value1", bag.GetValue("key"));
            Assert.AreElementsEqual(new[] { "value1", "value2" }, bag["key"]);

            bag.SetValue("key", "value");
            Assert.AreElementsEqual(new[] { "value" }, bag["key"]);
        }
开发者ID:dougrathbone,项目名称:mbunit-v3,代码行数:23,代码来源:PropertyBagTest.cs


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