C#
3
Вклад в тег
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
<Button Content="нажать" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="KeyDown">
<i:InvokeCommandAction Command="{Binding KeyDownCommand}" CommandParameter="param"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
public interface IMessage
{
void SendMessage(string msg);
}
public abstract class MessageBase : IMessage
{
public virtual void SendMessage(string msg) => Console.WriteLine($@"{Name}:parameter={msg}");
public abstract string Name { get; }
}
public class Bye : MessageBase {public override string Name => "Bye"; }
public class Hello : MessageBase {public override string Name => "Hello"; }
public class Welcome : MessageBase { public override string Name => "Welcome";}
class ReflectMethod
{
public static void InvokeMethod(string[] array)
{
List<IMessage> messages = new List<IMessage>()
{
new Bye(),
new Hello(),
new Welcome()
};
for (int counter = 0; counter < array.Length; counter++)
{
messages[counter].SendMessage(array[counter]);
}
}
}