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


C# PropertyBag.FromXml方法代码示例

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


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

示例1: PropertyBagTwoWayValueTypeSerializationTest

        public void PropertyBagTwoWayValueTypeSerializationTest()
        {
            var bag = new PropertyBag<decimal>();

            bag.Add("key", 10M);
            bag.Add("Key1", 100.10M);
            bag.Add("Key2", 200.10M);
            bag.Add("Key3", 300.10M);
            string xml = bag.ToXml();

            TestContext.WriteLine(bag.ToXml());

            bag.Clear();

            bag.FromXml(xml);

            Assert.IsTrue(bag["Key1"] == 100.10M);
            Assert.IsTrue(bag["Key3"] == 300.10M);
        }
开发者ID:CocoaLab,项目名称:WestwindToolkit,代码行数:19,代码来源:PropertyBagTest.cs

示例2: PropertyBagTwoWayObjectSerializationTest

        public void PropertyBagTwoWayObjectSerializationTest()
        {
            var bag = new PropertyBag();

            bag.Add("key", "Value");
            bag.Add("Key2", 100.10M);
            bag.Add("Key3", Guid.NewGuid());
            bag.Add("Key4", DateTime.Now);
            bag.Add("Key5", true);
            bag.Add("Key7", new byte[3] { 42, 45, 66 } );
            bag.Add("Key8", null);
            bag.Add("Key9", new ComplexObject() { Name = "Rick",
            Entered = DateTime.Now,
            Count = 10 });

            string xml = bag.ToXml();

            TestContext.WriteLine(bag.ToXml());

            bag.Clear();

            bag.FromXml(xml);

            Assert.IsTrue(bag["key"] as string == "Value");
            Assert.IsInstanceOfType( bag["Key3"], typeof(Guid));
            Assert.IsNull(bag["Key8"]);
            //Assert.IsNull(bag["Key10"]);

            Assert.IsInstanceOfType(bag["Key9"], typeof(ComplexObject));
        }
开发者ID:CocoaLab,项目名称:WestwindToolkit,代码行数:30,代码来源:PropertyBagTest.cs

示例3: GetProperties

        /// <summary>
        /// Loads the Properties dictionary with values from a Properties property of 
        /// an item object. Once loaded you can access the dictionary to read and write
        /// values from it arbitrarily and use SetProperties to write the values back
        /// in serialized form to the underlying property for database storage.
        /// </summary>
        /// <param name="stringFieldNameToLoadFrom">The name of the field to load the XML properties from.</param>
        protected void GetProperties(string stringFieldNameToLoadFrom = "Properties", object entity = null)
        {
            Properties = null;

            if (entity == null)
                entity = Item;

            // Always create a new property bag
            Properties = new PropertyBag();

            string fieldValue = ReflectionUtils.GetProperty(entity, stringFieldNameToLoadFrom) as string;
            if (string.IsNullOrEmpty(fieldValue))
                return;

            // load up Properties from XML                       
            Properties.FromXml(fieldValue);
        }
开发者ID:RickStrahl,项目名称:Westwind.QueueMessageManager,代码行数:24,代码来源:QueueMessageManager.cs


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