Table of Contents

Class CounterApi

Namespace: Casewhere.Runtime.DSL.Api
Assembly: Casewhere.Runtime.dll

public class CounterApi : ICounterApi, IDslApi

Inheritance

objectCounterApi

Implements

ICounterApi, IDslApi

Inherited Members

object.ToString(), object.Equals(object), object.Equals(object, object), object.ReferenceEquals(object, object), object.GetHashCode(), object.GetType(), object.MemberwiseClone()

Extension Methods

ObjectExtension.ConvertToBsonValue(object), EnumExtensions.DeepClone<CounterApi>(CounterApi)

Constructors

CounterApi(ICounterService)

public CounterApi(ICounterService counterService)

Parameters

counterService ICounterService

Methods

Next(string)

Generate an auto-incremented integer for a given sequence.

public int Next(string name)

Parameters

name string

Name of the counter.

Returns

int

The generated number.

Examples

var counterApi = ctx.Use<ICounterApi>();
// This example generates a new Order Number for the current year
var orderNo1 = counterApi.Next($"OrderNo_{DateTime.Now.Year}"); // return 1
var orderNo2 = counterApi.Next($"OrderNo_{DateTime.Now.Year}"); // return 2
var receiptNo = counterApi.Next($"ReceiptNo_{DateTime.Now.Year}"); // return 1

Next(string, int)

Generate an integer for a given sequence.

public int Next(string name, int step)

Parameters

name string

Name of the counter.

step int

Increase number.

Returns

int

The generated number.

Examples

var counterApi = ctx.Use<ICounterApi>();
// This example generates a new Order Number for the current year
var orderNo1 = counterApi.Next($"OrderNo_{DateTime.Now.Year}", 5); // return 5
var orderNo2 = counterApi.Next($"OrderNo_{DateTime.Now.Year}", 5); // return 10
var receiptNo = counterApi.Next($"ReceiptNo_{DateTime.Now.Year}", 6); // return 6

Set(string, int)

Set the counter value.

public void Set(string name, int value)

Parameters

name string

Name of the counter.

value int

The value.

Examples

var counterApi = ctx.Use<ICounterApi>();
// This example generates a new Order Number for the current year
counterApi.Next($"OrderNo"); // return 1
counterApi.Next($"OrderNo"); // return 2
counterApi.Set($"OrderNo", 1000); // set the counter value to 1000
counterApi.Next($"OrderNo"); // return 1001