本文整理汇总了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"));
}
示例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");
}
示例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");
}
示例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);
}
示例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);
}