當前位置: 首頁>>代碼示例>>C#>>正文


C# Foo.GetType方法代碼示例

本文整理匯總了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));
        }
開發者ID:RockFramework,項目名稱:Rock.Core,代碼行數:10,代碼來源:ToBinaryExtensionTests.cs

示例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));
		}
開發者ID:nuxleus,項目名稱:ServiceStack.OrmLite,代碼行數:11,代碼來源:TestScripts.cs

示例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));
		}
開發者ID:nuxleus,項目名稱:ServiceStack.OrmLite,代碼行數:13,代碼來源:TestScripts.cs

示例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));
        }
開發者ID:sami1971,項目名稱:NServiceKit.Text,代碼行數:14,代碼來源:StructTests.cs

示例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\"}"));
        }
開發者ID:sami1971,項目名稱:NServiceKit.Text,代碼行數:10,代碼來源:StructTests.cs

示例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);
 }
開發者ID:Erguotou,項目名稱:protobuf-net,代碼行數:8,代碼來源:NHibernateProxies.cs


注:本文中的System.Foo.GetType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。