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