Q:
You are developing a Dynamics 365 application. You need to extend a base class method but the method is marked as final.
You need to override the restriction and wrap the final method in an extension class.
What attribute should you use?
-
A
Hookable(false)
-
B
Hookable(true)
-
C
Wrappable(true)
-
D
Wrappable(false)
C
Answer:
C
Explanation:
Public and protected methods that are marked as final can't be wrapped in extension classes. You can override this restriction by using the Wrappable attribute and setting the attribute parameter to true ([Wrappable(true)]). Similarly, to override the default capability for (non-final) public or protected methods, you can mark those methods as non-wrappable ([Wrappable(false)]).
The Wrappable(true) attribute can be used to override the restriction and allow final methods to be wrapped in extension classes. Hookable(true) does not influence chain of command wrapping. Wrappable(false) marks methods as non-wrappable. Hookable(false) makes the method unable to be wrapped in an extension class.
Class extension - Method wrapping and Chain of Command - Finance & Operations | Dynamics 365 | Microsoft Learn
Implement Chain of Command - Training | Microsoft Learn
class AnyClass2
{
[Wrappable(false)]
public void doSomething(str message) {...}
[Wrappable(true)]
final public void doSomethingElse(str message) {...}
}
Related Topic:
Share Above MCQ