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


C# AttributeCollection.GetAttributeValue方法代码示例

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


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

示例1: TestGettingAnAttributeThatExists

        public void TestGettingAnAttributeThatExists()
        {
            AttributeCollection attributes = new AttributeCollection();
            AttributeValue newAttributeValue = new AttributeValue("Test Value");

            // Add the attribute
            attributes.Add("Test", newAttributeValue);

            // Check if the attribute exists (by name)
            Assert.AreEqual<AttributeValue>(attributes.GetAttributeValue("Test"), newAttributeValue);
            Assert.AreEqual<AttributeValue>(attributes["Test"], newAttributeValue);

            // Check if the attribute exists (by attribute)
            Assert.AreEqual<AttributeValue>(attributes.GetAttributeValue("Test"), newAttributeValue);
            Assert.AreEqual<AttributeValue>(attributes["Test"], newAttributeValue);
        }
开发者ID:senfo,项目名称:snaglV2,代码行数:16,代码来源:AttributeCollectionTests.cs

示例2: TestAttributePropertyChangedEvent

        public void TestAttributePropertyChangedEvent()
        {
            AttributeCollection attributes = new AttributeCollection();

            object oldValue = null;
            object newValue = null;
            string propertyChanged = string.Empty;

            // Setup the event handler
            attributes.AttributeValuePropertyChanged += (object sender, Berico.Common.Events.PropertyChangedEventArgs<object> e) =>
                {
                    oldValue = e.OldValue;
                    newValue = e.NewValue;
                    propertyChanged = e.PropertyName;
                };

            // Add some attributes to the collection
            attributes.Add("Test1", new AttributeValue("Test Value1"));
            attributes.Add("Test2", new AttributeValue("Test Value2"));
            attributes.Add("Test3", new AttributeValue("Test Value3"));
            attributes.Add("Test4", new AttributeValue("Test Value4"));

            // Retrieve one of the attributes to test
            AttributeValue testAttributeValue = attributes.GetAttributeValue("Test3");

            // Make change to property
            EnqueueCallback(() => testAttributeValue.Value = "New Value");

            // Wait for event to complete
            EnqueueConditional(() => propertyChanged != string.Empty);

            // Test that event was appropriately fires and handled
            EnqueueCallback(() => Assert.AreEqual<string>("Value", propertyChanged));
            EnqueueCallback(() => Assert.AreEqual<string>("New Value", newValue as string));
            EnqueueCallback(() => Assert.AreEqual<string>("Test Value3", oldValue as string));

            // Reset testing fields
            EnqueueCallback(() => propertyChanged = string.Empty);
            EnqueueCallback(() => oldValue = null);
            EnqueueCallback(() => newValue = null);

            EnqueueTestComplete();
        }
开发者ID:senfo,项目名称:snaglV2,代码行数:43,代码来源:AttributeCollectionTests.cs

示例3: TestGettingAnAttributeThatDoesNotExist

        public void TestGettingAnAttributeThatDoesNotExist()
        {
            AttributeCollection attributes = new AttributeCollection();
            AttributeValue foundAttributeValue = attributes.GetAttributeValue("Test");

            Assert.IsNull(foundAttributeValue);
        }
开发者ID:senfo,项目名称:snaglV2,代码行数:7,代码来源:AttributeCollectionTests.cs


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