ソースと同等のソースをDelphi Prismで書いてみた。
namespace WindowsApplication1;
interface
uses
System.Drawing,
System.Collections,
System.Collections.Generic,
System.Linq,
System.Windows.Forms,
System.ComponentModel,
System.Reflection;
type
///
/// Summary description for MainForm.
///
MainForm = partial class(System.Windows.Forms.Form)
private
method button1_Click(sender: System.Object; e: System.EventArgs);
protected
method Dispose(disposing: Boolean); override;
public
constructor;
method SakaSum(a, b : Integer) : Integer;
end;
implementation
{$REGION Construction and Disposition}
constructor MainForm;
begin
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
end;
method MainForm.Dispose(disposing: Boolean);
begin
if disposing then begin
if assigned(components) then
components.Dispose();
//
// TODO: Add custom disposition code here
//
end;
inherited Dispose(disposing);
end;
{$ENDREGION}
method MainForm.button1_Click(sender: System.Object; e: System.EventArgs);
var
rtm : System.Reflection.MethodInfo;
Args : Array of System.Object;
Rst : System.Object;
MyType : System.Type;
begin
MyType := System.Type.GetType('WindowsApplication1.' + Self.Name);
rtm := MyType.GetMethod('SakaSum');
if rtm <> nil Then
begin
Args := new System.Object[2];
Args[0] := Convert.ToInt32(textBox1.Text);
Args[1] := Convert.ToInt32(textBox2.Text);
Rst := rtm.Invoke(Self,Args);
label5.Text := Rst.ToString();
end;
end;
method MainForm.SakaSum(a, b : Integer) : Integer;
begin
Result := a + b;
end;
end.
0 件のコメント:
コメントを投稿