Add Syntax highlighting to code in Docs (#104)

This commit is contained in:
Eoin O'Brien 2019-08-20 12:00:23 +01:00 коммит произвёл Daniel Kanev
Родитель 3273e94236
Коммит 74e5c224c9
1 изменённых файлов: 47 добавлений и 41 удалений

Просмотреть файл

@ -17,14 +17,16 @@ Usually it will look like this:
_From the [Gating.Example](https://github.com/microsoft/Omex/tree/master/src/Gating.Example):_
Gates gates = new Gates(GateDataSetLoader);
```cs
Gates gates = new Gates(GateDataSetLoader);
IGatedRequest gatedRequest = new SampleGatedRequest();
IGateContext gateContext = new GateContext(gatedRequest, machineInformation, null);
gateContext.PerformAction(
IGatedRequest gatedRequest = new SampleGatedRequest();
IGateContext gateContext = new GateContext(gatedRequest, machineInformation, null);
gateContext.PerformAction(
new GatedAction(
gates.GetGate("sample_allowed_gate"),
() => Console.WriteLine("SampleAction has been called")));
```
## Usage scenarios
@ -36,8 +38,9 @@ Then you can use `GateExtensions.PerformAction(gate, Action)` on the context lik
`PerformAction` will perform at most one action - the first one whose gate is applicable.
By adding a `GatedAction` without a gate, you create a _default_ action, like an Else branch.
public class PointsAdder
{
```cs
public class PointsAdder
{
private readonly IGateContext m_gateContext;
private readonly User m_user;
@ -63,12 +66,14 @@ By adding a `GatedAction` without a gate, you create a _default_ action, like an
)
);
}
}
}
```
Another approach is to use the `PerformEachAction` method which will invoke code for every applicable `GateAction`, not just the first.
public List<Item> GetItems()
{
```cs
public List<Item> GetItems()
{
var items = new List<Item>();
m_gateContext.PerformEachAction(
new GatedAction(
@ -79,7 +84,8 @@ Another approach is to use the `PerformEachAction` method which will invoke code
() => AddGeneralItems(items)
)
);
}
}
```
Very similar will be the use of `PerformFunction` and `GatedFunc`, but with a return value.