![]() |
#2 |
Участник
|
Wrapping a base method in an extension of a derived class
The following example shows how to wrap a base method in an extension of a derived class. For this example, the following class hierarchy is used. X++: class A { public void salute(str message) { info(message); } } class B extends A {} class C extends A {} X++: [ExtensionOf(classStr(B))] final class B_Extension { public void salute(str message) { next salute(message); info("B extension"); } } This behavior becomes clearer if we implement a method that uses these three classes. X++: class ProgramTest { public static void main(Args args) { var a = new A(); var b = new B(); var c = new C(); a.salute("Hi"); b.salute("Hi"); c.salute("Hi"); } } By using this mechanism, you can wrap the original method only for specific derived classes. https://docs.microsoft.com/en-us/dyn...d-wrapping-coc
__________________
Felix nihil admirari Последний раз редактировалось wojzeh; 07.11.2018 в 17:13. |
|
Теги |
chain of command, d365fo |
|
|