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


C# Example.GetType方法代码示例

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


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

示例1: GetFieldSetter_ValueTypeField_ReturnsFieldValue

		public void GetFieldSetter_ValueTypeField_ReturnsFieldValue()
		{
			var input = new Example();
			var expected = -1;

			var fieldInfo = input.GetType().GetField("one");
			Assert.NotNull(fieldInfo);

			SetterDelegate setter = DynamicMethodGenerator.GetFieldSetter(fieldInfo);
			Assert.NotNull(setter);
			setter(input, expected);

			Assert.Equal(expected, input.One);
		}
开发者ID:RocketChicken,项目名称:jsonfx,代码行数:14,代码来源:DynamicMethodGeneratorTests.cs

示例2: GetFieldSetter_PrivateField_ReturnsFieldValue

		public void GetFieldSetter_PrivateField_ReturnsFieldValue()
		{
			var input = new Example();
			var expected = -2;

			var fieldInfo = input.GetType().GetField("two", BindingFlags.NonPublic|BindingFlags.Instance|BindingFlags.FlattenHierarchy);
			Assert.NotNull(fieldInfo);

			SetterDelegate setter = DynamicMethodGenerator.GetFieldSetter(fieldInfo);
			Assert.NotNull(setter);
			setter(input, expected);

			Assert.Equal(expected, fieldInfo.GetValue(input));
		}
开发者ID:RocketChicken,项目名称:jsonfx,代码行数:14,代码来源:DynamicMethodGeneratorTests.cs

示例3: GetFieldGetter_ProtectedField_ReturnsFieldValue

		public void GetFieldGetter_ProtectedField_ReturnsFieldValue()
		{
			var input = new Example();

			var fieldInfo = input.GetType().GetField("c", BindingFlags.NonPublic|BindingFlags.Instance|BindingFlags.FlattenHierarchy);
			Assert.NotNull(fieldInfo);

			GetterDelegate getter = DynamicMethodGenerator.GetFieldGetter(fieldInfo);
			Assert.NotNull(getter);

			Assert.Equal("sea", getter(input));
		}
开发者ID:RocketChicken,项目名称:jsonfx,代码行数:12,代码来源:DynamicMethodGeneratorTests.cs

示例4: GetFieldGetter_ValueTypeField_ReturnsFieldValue

		public void GetFieldGetter_ValueTypeField_ReturnsFieldValue()
		{
			var input = new Example();

			var fieldInfo = input.GetType().GetField("one");
			Assert.NotNull(fieldInfo);

			GetterDelegate getter = DynamicMethodGenerator.GetFieldGetter(fieldInfo);
			Assert.NotNull(getter);

			Assert.Equal(1, getter(input));
		}
开发者ID:RocketChicken,项目名称:jsonfx,代码行数:12,代码来源:DynamicMethodGeneratorTests.cs

示例5: GetPropertySetter_PrivateSetterProperty_ReturnsPropertyValue

		public void GetPropertySetter_PrivateSetterProperty_ReturnsPropertyValue()
		{
			var input = new Example();
			var expected = "sun";

			var propertyInfo = input.GetType().GetProperty("Re");
			Assert.NotNull(propertyInfo);

			SetterDelegate setter = DynamicMethodGenerator.GetPropertySetter(propertyInfo);
			Assert.NotNull(setter);
			setter(input, expected);

			Assert.Equal(expected, input.Re);
		}
开发者ID:RocketChicken,项目名称:jsonfx,代码行数:14,代码来源:DynamicMethodGeneratorTests.cs

示例6: GetPropertySetter_PrivateGetterProperty_ReturnsPropertyValue

		public void GetPropertySetter_PrivateGetterProperty_ReturnsPropertyValue()
		{
			var input = new Example();
			var expected = "myself";

			var propertyInfo = input.GetType().GetProperty("Mi");
			Assert.NotNull(propertyInfo);

			SetterDelegate setter = DynamicMethodGenerator.GetPropertySetter(propertyInfo);
			Assert.NotNull(setter);
			setter(input, expected);

			MethodInfo getter = propertyInfo.GetGetMethod(true);
			Assert.NotNull(getter);

			Assert.Equal(expected, getter.Invoke(input, null));
		}
开发者ID:RocketChicken,项目名称:jsonfx,代码行数:17,代码来源:DynamicMethodGeneratorTests.cs

示例7: GetPropertySetter_SetterOnlyProperty_ReturnsPropertyValue

		public void GetPropertySetter_SetterOnlyProperty_ReturnsPropertyValue()
		{
			var input = new Example();
			var expected = -3;

			var propertyInfo = input.GetType().GetProperty("Three_Setter");
			Assert.NotNull(propertyInfo);

			SetterDelegate setter = DynamicMethodGenerator.GetPropertySetter(propertyInfo);
			Assert.NotNull(setter);
			setter(input, expected);

			Assert.Equal(expected, input.Three);
		}
开发者ID:RocketChicken,项目名称:jsonfx,代码行数:14,代码来源:DynamicMethodGeneratorTests.cs

示例8: GetPropertySetter_AutoImplementedProperty_ReturnsPropertyValue

		public void GetPropertySetter_AutoImplementedProperty_ReturnsPropertyValue()
		{
			var input = new Example();
			var expected = "deer";

			var propertyInfo = input.GetType().GetProperty("Do");
			Assert.NotNull(propertyInfo);

			SetterDelegate setter = DynamicMethodGenerator.GetPropertySetter(propertyInfo);
			Assert.NotNull(setter);
			setter(input, expected);

			Assert.Equal(expected, input.Do);
		}
开发者ID:RocketChicken,项目名称:jsonfx,代码行数:14,代码来源:DynamicMethodGeneratorTests.cs

示例9: GetPropertySetter_GetterOnlyProperty_ReturnsPropertyValue

		public void GetPropertySetter_GetterOnlyProperty_ReturnsPropertyValue()
		{
			var input = new Example();

			var propertyInfo = input.GetType().GetProperty("Three_Getter");
			Assert.NotNull(propertyInfo);

			SetterDelegate setter = DynamicMethodGenerator.GetPropertySetter(propertyInfo);
			Assert.Null(setter);
		}
开发者ID:RocketChicken,项目名称:jsonfx,代码行数:10,代码来源:DynamicMethodGeneratorTests.cs

示例10: GetPropertySetter_PrivateProperty_ReturnsPropertyValue

		public void GetPropertySetter_PrivateProperty_ReturnsPropertyValue()
		{
			var input = new Example();
			var expected = -2;

			var propertyInfo = input.GetType().GetProperty("Two", BindingFlags.NonPublic|BindingFlags.Instance|BindingFlags.FlattenHierarchy);
			Assert.NotNull(propertyInfo);

			SetterDelegate setter = DynamicMethodGenerator.GetPropertySetter(propertyInfo);
			Assert.NotNull(setter);
			setter(input, expected);

			MethodInfo getter = propertyInfo.GetGetMethod(true);
			Assert.NotNull(getter);

			Assert.Equal(expected, getter.Invoke(input, null));
		}
开发者ID:RocketChicken,项目名称:jsonfx,代码行数:17,代码来源:DynamicMethodGeneratorTests.cs

示例11: GetPropertySetter_PublicReferenceTypeProperty_ReturnsPropertyValue

		public void GetPropertySetter_PublicReferenceTypeProperty_ReturnsPropertyValue()
		{
			var input = new Example();
			var expected = "alpha";

			var propertyInfo = input.GetType().GetProperty("A");
			Assert.NotNull(propertyInfo);

			SetterDelegate setter = DynamicMethodGenerator.GetPropertySetter(propertyInfo);

			Assert.NotNull(setter);
			setter(input, expected);

			Assert.Equal(expected, input.A);
		}
开发者ID:RocketChicken,项目名称:jsonfx,代码行数:15,代码来源:DynamicMethodGeneratorTests.cs

示例12: GetPropertyGetter_PrivateGetterProperty_ReturnsPropertyValue

		public void GetPropertyGetter_PrivateGetterProperty_ReturnsPropertyValue()
		{
			var input = new Example();

			var propertyInfo = input.GetType().GetProperty("Mi");
			Assert.NotNull(propertyInfo);

			GetterDelegate getter = DynamicMethodGenerator.GetPropertyGetter(propertyInfo);

			Assert.NotNull(getter);
			Assert.Equal("me", getter(input));
		}
开发者ID:RocketChicken,项目名称:jsonfx,代码行数:12,代码来源:DynamicMethodGeneratorTests.cs

示例13: GetPropertyGetter_PrivateProperty_ReturnsPropertyValue

		public void GetPropertyGetter_PrivateProperty_ReturnsPropertyValue()
		{
			var input = new Example();

			var propertyInfo = input.GetType().GetProperty("Two", BindingFlags.NonPublic|BindingFlags.Instance|BindingFlags.FlattenHierarchy);
			Assert.NotNull(propertyInfo);

			GetterDelegate getter = DynamicMethodGenerator.GetPropertyGetter(propertyInfo);
			Assert.NotNull(getter);

			Assert.Equal(2, getter(input));
		}
开发者ID:RocketChicken,项目名称:jsonfx,代码行数:12,代码来源:DynamicMethodGeneratorTests.cs


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