2023 beta - APIs & Extensions (20%) Flashcards

1
Q

How do you add a new handler to a handler chain?

A
  • Implement the IHandler<TIn, TOut> interface
  • Be decorated with the DependencyName attribute
  • Return a result from the “Execute” method
  • Specify an order via the “Order” property
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How do you add a new pipe to an existing pipeline?

A
  • Implement the IPipe<TIn, TOut> interface
  • Return a result from the “Execute” method
  • Specify an order via the “Order” property
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do you break a handler chain?

A

return result;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How do you call the next handler of a handler chain?

A

return this.NextHandler.Execute(unitOfWork, parameter, result);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How do you return an error code, a subcode, a message, and exit a pipe?

A

result.ResultCode = ResultCode.Error;
result.SubCode = SubCode.NotFound;
result.Messages.Add(new ResultMessage { Message = “A customer is required to format the label.” });
return result;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What do you need to do to exit a pipe without specifying an error code?

A

result.ExitPipeline = true;
return result;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do you replace an existing pipe?

A

-Implement the IPipe<TIn, TOut> interface
- Return a result from the “Execute” method
- Specify an order via the “Order” property (The order does not necessarily need to be the same as the standard pipe)
- Be named the same as the pipe being replaced (this is a new requirement)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How do you stop the execution of a pipeline?

A

The pipe must either assign an error code to the result object or set the exit flag on the result object.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How do you use a pipeline in code?

A

Have an instance injected into the class constructor like most other objects.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

On what is a persona built on?

A

A persona is built on the user and customer characteristics that you add to a persona rule

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the RuleManager?

A

RuleManager is the container class that is attached to Entities to allow that Entity to have a RulesEngine

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the purpose of RuleClause?

A

RuleClause defines the actual rules to be run and the Condition, Grouping, and Order in which they run

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are the rule types?

A

Persona
Category
Shipping
Promotion
Page Variants
Restriction Groups

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the purpose of RuleTypeOption?

A

RuleTypeOption defines the rules that are available when adding a RuleClause. (These options define the “IF” statement of the rule).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Which class is the base class for all criteria types?

A

CriteriaTypeBase

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Which method is called to indicate whether a rule passes or fails?

A

The Validate method is called returning true to indicate whether the rule passes or false if the rule fails.

17
Q

What are the main actions of the ValidateRule method?

A

Validates one of the rule clauses by calling the appropriate CriteriaType’s implementation of the validate method.
Retrieves the valid ICriteriaType object using the CriteriaTyepFactory.
The enumerable context is then interrogated to find a context object with a type that matches the object type required for the current RuleClause.
If no context is found then the RuleClause is validated without any context.

18
Q

What are the 2 ways to break a handler chain?

A

Breaking the handler chain can be done one of two ways:

By returning the result instead of calling this.NextHandler.Execute()

By setting the next handler to be a NullHandler
For example, this.RegisterNext(new NullHandler(TParameter, TResult>())