本文整理汇总了C#中System.Foo.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Foo.GetType方法的具体用法?C# Foo.GetType怎么用?C# Foo.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Foo
的用法示例。
在下文中一共展示了Foo.GetType方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReturnsWhatTheSerializeToByteArrayExtensionMethodOnTheDefaultBinarySerializerReturns
public void ReturnsWhatTheSerializeToByteArrayExtensionMethodOnTheDefaultBinarySerializerReturns()
{
var foo = new Foo { Bar = "abc123" };
var result = foo.ToBinary();
var expectedResult = DefaultBinarySerializer.Current.SerializeToByteArray(foo, foo.GetType());
Assert.That(result, Is.EqualTo(expectedResult));
}
示例2: ExpressionPropertyInvoker_GetPropertyValue_Test
public void ExpressionPropertyInvoker_GetPropertyValue_Test()
{
var foo = new Foo();
var propertyInfo = foo.GetType().GetProperty("Bar");
foo.Bar = "Hello";
var result = ExpressionPropertyInvoker.Instance
.GetPropertyValue(propertyInfo, foo);
Assert.That(result, Is.EqualTo(foo.Bar));
}
示例3: ExpressionPropertyInvoker_SetPropertyValue_Test
public void ExpressionPropertyInvoker_SetPropertyValue_Test()
{
var foo = new Foo();
var propertyInfo = foo.GetType().GetProperty("Bar");
ExpressionPropertyInvoker.Instance.ConvertValueFn
= new SqliteOrmLiteDialectProvider().ConvertDbValue;
ExpressionPropertyInvoker.Instance
.SetPropertyValue(propertyInfo, typeof(string), foo, "Hello");
Assert.That(foo.Bar, Is.EqualTo(foo.Bar));
}
示例4: Test_structs_with_double_quotes
public void Test_structs_with_double_quotes()
{
var dto = new Foo { Content1 = "My \"quoted\" content", Name = "My \"quoted\" name" };
JsConfig<Text>.SerializeFn = text => text.ToString();
JsConfig<Text>.DeSerializeFn = v => new Text(v);
var json = JsonSerializer.SerializeToString(dto, dto.GetType());
Assert.That(json, Is.EqualTo("{\"Name\":\"My \\\"quoted\\\" name\",\"Content1\":\"My \\\"quoted\\\" content\"}"));
var foo = JsonSerializer.DeserializeFromString<Foo>(json);
Assert.That(foo.Name, Is.EqualTo(dto.Name));
Assert.That(foo.Content1, Is.EqualTo(dto.Content1));
}
示例5: Test_structs
public void Test_structs()
{
JsConfig<Text>.SerializeFn = text => text.ToString();
var dto = new Foo { Content1 = "My content", Name = "My name" };
var json = JsonSerializer.SerializeToString(dto, dto.GetType());
Assert.That(json, Is.EqualTo("{\"Name\":\"My name\",\"Content1\":\"My content\"}"));
}
示例6: CompareFoo
private static void CompareFoo(Foo original, Foo clone, string message)
{
Assert.IsNotNull(clone, message);
Assert.AreNotSame(original, clone);
Assert.AreEqual(original.Id, clone.Id, message + ": Id");
Assert.AreEqual(original.Name, clone.Name, message + ": Name");
Assert.AreEqual(typeof(Foo), clone.GetType(), message);
}