你的意思是這樣的嗎?
原始的方法: -
method Something.SomeMethod(a:Integer;b:Integer;c:Integer): Integer;
begin
result:=b+c;
end;
的新方法: -
begin
if (a > 0) then
begin
result := (b + c);
exit
end;
begin
result := 1000;
exit
end
該方法水平方面應該是這樣的
[AttributeUsage(AttributeTargets.Method)]
Class1Attribute = public class(System.Attribute,
IMethodImplementationDecorator)
private
protected
public
method HandleImplementation(Services: RemObjects.Oxygene.Cirrus.IServices; aMethod: RemObjects.Oxygene.Cirrus.IMethodDefinition);
end;
implementation
method Class1Attribute.HandleImplementation(Services: RemObjects.Oxygene.Cirrus.IServices; aMethod: RemObjects.Oxygene.Cirrus.IMethodDefinition);
begin
var newVersion:=new ResultValue();
var newAssignment:=new AssignmentStatement(newVersion,new DataValue(1001));
var p1:= new ParamValue(0);
aMethod.SetBody(Services,method
begin
if (unquote<Integer>(p1)>0) then
begin
Aspects.OriginalBody;
end
else
begin
unquote(newAssignment);
end;
end);
end;
如果我嘗試使用中的字符串Datavalue(目標函數返回一個字符串)我得到一個內部錯誤。如果我使用字符串,這個代碼是否需要更新? – jamiei 2009-06-10 17:10:15