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


C# Target.GetType方法代码示例

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


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

示例1: Main

 public static void Main()
 {
     Target t = new Target("foo", 18);
     show(t.Name, t.Age());
     show(
         ((string)t.GetType().GetField("Name").GetValue(t)),
         ((int)t.GetType().GetField("age", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(t))
     );
     t.Name = "bar";
     t.GetType().GetField("age", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(t, 30);
     show(t.Name, t.Age());
 }
开发者ID:hythof,项目名称:csharp,代码行数:12,代码来源:Field.cs

示例2: Main

 public static void Main()
 {
     Target t = new Target();
     int a = t.Add(1,2);
     int b = (int)t.GetType().GetMethod("Add").Invoke(t, new object[]{ 1, 2 });
     int c = (int)t.GetType().GetMethod("Sub", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(t, new object[]{ 4, 3 });
     int d = (int)typeof(Target).GetMethod("Mul", BindingFlags.Public | BindingFlags.Static).Invoke(null, new object[]{ 2, 5 });
     Console.WriteLine("1 + 2 = " + a);
     Console.WriteLine("1 + 2 = " + b);
     Console.WriteLine("4 - 3 = " + c);
     Console.WriteLine("2 * 5 = " + d);
 }
开发者ID:hythof,项目名称:csharp,代码行数:12,代码来源:Method.cs

示例3: AddTarget

 /// <summary>
 /// Registers the specified target object under a given name.
 /// </summary>
 /// <param name="name">Name of the target.</param>
 /// <param name="target">The target object.</param>
 public void AddTarget(string name, Target target)
 {
     if (name == null)
         throw new ArgumentException("name", "Target name cannot be null");
     InternalLogger.Debug("Registering target {0}: {1}", name, target.GetType().FullName);
     _targets[name.ToLower(CultureInfo.InvariantCulture)] = target;
 }
开发者ID:kisflying,项目名称:kion,代码行数:12,代码来源:LoggingConfiguration.cs

示例4: ProceedWithEmptyInterceptorChain

		public void ProceedWithEmptyInterceptorChain()
		{
			Target target = new Target();
            AbstractMethodInvocation join = CreateMethodInvocation(
                null, target, target.GetTargetMethodNoArgs(), null, null, target.GetType(), new ArrayList());
			string score = (string) join.Proceed();
			Assert.AreEqual(Target.DefaultScore + Target.Suffix, score);
		}
开发者ID:spring-projects,项目名称:spring-net,代码行数:8,代码来源:AbstractMethodInvocationTests.cs

示例5: ShouldStoreProperties

        public void ShouldStoreProperties()
        {
            var source = new Source();
            var target = new Target();
            var sourceProperty = source.GetType().GetProperty("Text");
            var targetProperty = target.GetType().GetProperty("MyText");

            var handler = new SyncValueToHandler<Source>(m => m.Text, source, target);

            handler.SourceProperty.ShouldBe(sourceProperty);
            handler.TargetProperty.ShouldBe(targetProperty);
            handler.TargetInstance.ShouldBe(target);
            handler.SourceInstance.ShouldBe(source);
        }
开发者ID:philcockfield,项目名称:Open.TestHarness.SL,代码行数:14,代码来源:SyncValueToHandlerTest.cs

示例6: ToStringWithArguments

		public void ToStringWithArguments()
		{
			Target target = new Target();
            AbstractMethodInvocation join = CreateMethodInvocation(
                null, target, target.GetTargetMethod(), null, new string[] { "Five" }, target.GetType(), new ArrayList());
			CheckToStringDoesntThrowAnException(join);
		}
开发者ID:spring-projects,项目名称:spring-net,代码行数:7,代码来源:AbstractMethodInvocationTests.cs

示例7: ValidInvocation

		public void ValidInvocation()
		{/*
			Target target = new Target();
            MockRepository repository = new MockRepository();
		    IMethodInterceptor interceptor = (IMethodInterceptor) repository.CreateMock(typeof (IMethodInterceptor));
            AbstractMethodInvocation join = CreateMethodInvocation(
               null, target, target.GetTargetMethodNoArgs(), null, null, target.GetType(), new object[] { interceptor });
		    Expect.Call(interceptor.Invoke(join)).Return(target.BullseyeMethod().ToLower(CultureInfo.InvariantCulture));
            repository.ReplayAll();
		    string score = (string) join.Proceed();
            Assert.AreEqual(target.BullseyeMethod().ToLower(CultureInfo.InvariantCulture) + Target.Suffix, score);
            repository.VerifyAll();
            */

            Target target = new Target();
            IMethodInterceptor mock = (IMethodInterceptor) mocks.CreateMock(typeof(IMethodInterceptor));
            AbstractMethodInvocation join = CreateMethodInvocation(
                null, target, target.GetTargetMethodNoArgs(), null, null, target.GetType(), new object[] { mock });
			
            Expect.Call(mock.Invoke(null)).IgnoreArguments().Return(target.BullseyeMethod().ToLower(CultureInfo.InvariantCulture));
            mocks.ReplayAll();

			string score = (string) join.Proceed();
			Assert.AreEqual(Target.DefaultScore.ToLower(CultureInfo.InvariantCulture) + Target.Suffix, score);
			
            mocks.VerifyAll();
            
		}
开发者ID:spring-projects,项目名称:spring-net,代码行数:28,代码来源:AbstractMethodInvocationTests.cs


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