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


C# PageData.SetValue方法代码示例

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


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

示例1: PageData

        public void GivenPageWithPropertyValueAndPropertyGroups_CreateAndPopulateTypedInstance_ReturnsTypedInstanceWithPropertyValues()
        {
            PageData sourcePage = new PageData();

            sourcePage.Property.Add("LongStringProperty", new PropertyString());
            sourcePage.SetValue("LongStringProperty", "one");
            sourcePage.Property.Add("ImageOne-ImageUrl", new PropertyString());
            sourcePage.SetValue("ImageOne-ImageUrl", "two");
            sourcePage.Property.Add("ImageOne-AltText", new PropertyString());
            sourcePage.SetValue("ImageOne-AltText", "three");
            sourcePage.Property.Add("ImageTwo-ImageUrl", new PropertyString());
            sourcePage.SetValue("ImageTwo-ImageUrl", "four");
            sourcePage.Property.Add("ImageTwo-AltText", new PropertyString());
            sourcePage.SetValue("ImageTwo-AltText", "five");
            sourcePage.Property.Add("ImageThree-ImageUrl", new PropertyString());
            sourcePage.SetValue("ImageThree-ImageUrl", "six");
            sourcePage.Property.Add("ImageThree-AltText", new PropertyString());
            sourcePage.SetValue("ImageThree-AltText", "seven");

            TypedPageActivator activator = new TypedPageActivator();

            TestPageTypeWithPropertyGroups page = activator.CreateAndPopulateTypedInstance(sourcePage, typeof(TestPageTypeWithPropertyGroups)) as TestPageTypeWithPropertyGroups;

            Assert.Equal("one", page.LongStringProperty);
            Assert.Equal("two", page.ImageOne.ImageUrl);
            Assert.Equal("three", page.ImageOne.AltText);
            Assert.Equal("four", page.ImageTwo.ImageUrl);
            Assert.Equal("five", page.ImageTwo.AltText);
            Assert.Equal("six", page.ImageThree.ImageUrl);
            Assert.Equal("seven", page.ImageThree.AltText);

        }
开发者ID:stenis,项目名称:Page-Type-Builder,代码行数:32,代码来源:TypedPageActivatorTests.cs

示例2: GivenPageWithPropertyValue_CreateAndPopulateTypedInstance_ReturnsTypedInstanceWithPropertyValue

        public void GivenPageWithPropertyValue_CreateAndPopulateTypedInstance_ReturnsTypedInstanceWithPropertyValue()
        {
            PageData sourcePage = new PageData();
            string propertyName = TestValueUtility.CreateRandomString();
            sourcePage.Property.Add(propertyName, new PropertyString());
            string propertyValue = TestValueUtility.CreateRandomString();
            sourcePage.SetValue(propertyName, propertyValue);
            TypedPageActivator activator = new TypedPageActivator();

            TestPageType page = (TestPageType)activator.CreateAndPopulateTypedInstance(sourcePage, typeof(TestPageType));

            Assert.Equal<string>(propertyValue, page.GetValue(propertyName) as string);
        }
开发者ID:stenis,项目名称:Page-Type-Builder,代码行数:13,代码来源:TypedPageActivatorTests.cs


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