你的意思是这样的吗?
原始方法:-
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;