2009-06-04 3 views
2

배경델파이 프리즘 러스 액세스 및 기능

이 질문 델파이 프리즘 관점 지향 프로그래밍을위한 새로운 Cirrus 인프라에 관한 결과를 설정.

나는 현재 클래스에 자동 주입 중이며 aMethod.SetBody 함수를 사용하여 대상 코드를 수정하려고 시도하고 있습니다. 지금까지 Cirrus Introduction 문서 위키에있는 로깅 예제 코드를 기초로 내 코드를 구조화했습니다.

질문

방법 I과 함께 원래의 기능 체없이 모두에 주입되는 함수의 결과를 액세스 할 수있는 실행중인?

한 코드 경로에서 OriginalBody 호출을 무시하고 다른 코드 경로로 OriginalBody를 호출하고 내 Aspect 코드에서 OriginalBody의 후속 결과를 사용하는 결과를 설정할 수 있기를 바랍니다. 원래이 코드는 Aspects.RequireResult 메서드의 의도 된 용도 일 수 있다고 생각했지만이 경우 OriginalBody를 강제 실행하여 코드 중복을 일으키는 것으로 보입니다.

답변

2

다음과 같은 것이 있습니까?

원본 방법 : -

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; 
+0

과 같을 것이다 Datavalue (대상 함수는 문자열을 반환합니다.) 내부 오류가 발생합니다. 문자열을 사용하는 경우이 코드를 업데이트해야합니까? – jamiei

+0

SomeMethod가 문자열을 반환하고 새 DataValue의 매개 변수도 문자열이어야합니다. – Mosh

+0

AssignmentStatement를 인용 부호로 묶을 때 문자열로 바꿀 때 RemObjects.Oxygene.targets에서 (CE7) 내부 오류 (D03)가 발생합니다. 정확히 DataValue()가 수행하는 작업은 무엇입니까? – jamiei