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


C# System.Collections.GetType方法代码示例

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


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

示例1: CanAddSimpleProperty

		public void CanAddSimpleProperty()
		{
			var mapdoc = new HbmMapping();
			var component = new HbmDynamicComponent();
			var mapper = new DynamicComponentMapper(component, For<Person>.Property(p => p.Info), mapdoc);
			var dynObject = new { Pizza = 5 };
			mapper.Property(dynObject.GetType().GetProperty("Pizza"), x => { });

			Assert.That(component.Properties.Single(), Is.TypeOf<HbmProperty>().And.Property("Name").EqualTo("Pizza"));
		}
开发者ID:marchlud,项目名称:nhibernate-core,代码行数:10,代码来源:DynCompAttributesSettingTest.cs

示例2: CanAddSimpleProperty

		public void CanAddSimpleProperty()
		{
			var mapdoc = new HbmMapping();
			var component = new HbmDynamicComponent();
			var mapper = new DynamicComponentMapper(component, For<Person>.Property(p => p.Info), mapdoc);
			var dynObject = new { Pizza = 5 };
			mapper.Property(dynObject.GetType().GetProperty("Pizza"), x => { });

			component.Properties.Single().Should().Be.OfType<HbmProperty>().And.ValueOf.Name.Should().Be.EqualTo("Pizza");
		}
开发者ID:owerkop,项目名称:nhibernate-core,代码行数:10,代码来源:DynCompAttributesSettingTest.cs

示例3: WebGridDataSourceWithNestedPropertySortsCorrectly

        public void WebGridDataSourceWithNestedPropertySortsCorrectly() {
            // Arrange
            var element1 = new { Foo = new { Bar = "val2" } };
            var element2 = new { Foo = new { Bar = "val1" } };
            var element3 = new { Foo = new { Bar = "val3" } };
            IEnumerable<dynamic> values = new[] { element1, element2, element3 };

            var dataSource = new WebGridDataSource(new WebGrid(GetContext()), values: values, elementType: element1.GetType(), canSort: true, canPage: false);

            // Act 
            var rows = dataSource.GetRows(new SortInfo { SortColumn = "Foo.Bar", SortDirection = SortDirection.Descending }, 0);

            // Assert
            Assert.AreEqual(rows.ElementAt(0).Value.Foo.Bar, "val3");
            Assert.AreEqual(rows.ElementAt(1).Value.Foo.Bar, "val2");
            Assert.AreEqual(rows.ElementAt(2).Value.Foo.Bar, "val1");
        }
开发者ID:adrianvallejo,项目名称:MVC3_Source,代码行数:17,代码来源:WebGridDataSourceTest.cs

示例4: ReturnsExistingModelMetadata

        public void ReturnsExistingModelMetadata()
        {
            // Arrange
            object model = new { foo = "fooValue", bar = "barValue" };
            ModelMetadata originalMetadata = ModelMetadataProviders.Current.GetMetadataForType(() => model, model.GetType());
            ViewDataDictionary vdd = new ViewDataDictionary(model) { ModelMetadata = originalMetadata };

            // Act
            ModelMetadata metadata = vdd.ModelMetadata;

            // Assert
            Assert.Same(originalMetadata, metadata);
        }
开发者ID:huangw-t,项目名称:aspnetwebstack,代码行数:13,代码来源:ViewDataDictionaryTest.cs

示例5: FabricatesModelMetadataFromModelWhenModelMetadataHasNotBeenSet

        public void FabricatesModelMetadataFromModelWhenModelMetadataHasNotBeenSet()
        {
            // Arrange
            object model = new { foo = "fooValue", bar = "barValue" };
            ViewDataDictionary vdd = new ViewDataDictionary(model);

            // Act
            ModelMetadata metadata = vdd.ModelMetadata;

            // Assert
            Assert.NotNull(metadata);
            Assert.Equal(model.GetType(), metadata.ModelType);
        }
开发者ID:huangw-t,项目名称:aspnetwebstack,代码行数:13,代码来源:ViewDataDictionaryTest.cs


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