Skip to main content

Definition

Assembly: CloudNimble.EasyAF.Core.dll Namespace: CloudNimble.EasyAF.Core Inheritance: System.Object

Syntax

CloudNimble.EasyAF.Core.Interval<T>

Summary

Describes an interval of time to be used in time-based calculations. Provides methods to calculate rates and frequencies based on the interval value and type.

Type Parameters

Examples

// Create an interval representing something that happens every 3 hours
var interval = new Interval&lt;int&gt;(3, IntervalType.Hours);

// Calculate how many times per day this would occur
decimal timesPerDay = interval.PerDay(); // Returns 8.0

// Calculate how many minutes between occurrences
decimal minutesBetween = interval.PerMinute(); // Returns 0.0556 (1/18)

Constructors

.ctor

Creates a new instance of the Interval1` class.

Syntax

public Interval()

.ctor

Creates a new instance of the Interval1` class.

Syntax

public Interval(T value, CloudNimble.EasyAF.Core.IntervalType type)

Parameters

NameTypeDescription
valueTThe duration of the interval.
typeCloudNimble.EasyAF.Core.IntervalTypeThe base unit that describes what the quantity of this Interval references.

.ctor Inherited

Inherited from object

Syntax

public Object()

Properties

Type

The base unit that describes what the quantity of this Interval references.

Syntax

public CloudNimble.EasyAF.Core.IntervalType Type { get; set; }

Property Value

Type: CloudNimble.EasyAF.Core.IntervalType

Value

The duration of the Interval.

Syntax

public T Value { get; set; }

Property Value

Type: T

Methods

Equals Inherited Virtual

Inherited from object

Syntax

public virtual bool Equals(object obj)

Parameters

NameTypeDescription
objobject?-

Returns

Type: bool

Equals Inherited

Inherited from object

Syntax

public static bool Equals(object objA, object objB)

Parameters

NameTypeDescription
objAobject?-
objBobject?-

Returns

Type: bool

GetHashCode Inherited Virtual

Inherited from object

Syntax

public virtual int GetHashCode()

Returns

Type: int

GetType Inherited

Inherited from object

Syntax

public System.Type GetType()

Returns

Type: System.Type

MemberwiseClone Inherited

Inherited from object

Syntax

protected internal object MemberwiseClone()

Returns

Type: object

PerDay Virtual

Given this Interval1` instance, calculates how many occurrences will happen per day.

Syntax

public virtual System.Decimal PerDay()

Returns

Type: System.Decimal The number of occurrences per day as a decimal value.

Exceptions

ExceptionDescription
InvalidCastExceptionThrown if T is not convertible to a Decimal.

PerDay Virtual

Given this Interval1` instance and a quantity, calculates the total output per day.

Syntax

public virtual System.Decimal PerDay(System.Decimal quantity)

Parameters

NameTypeDescription
quantitySystem.DecimalThe quantity to multiply by the interval frequency.

Returns

Type: System.Decimal The total output per day as a decimal value.

Exceptions

ExceptionDescription
InvalidCastExceptionThrown if T is not convertible to a Decimal.

Examples

// Widget production: 1 widget every 1.5 hours, total from 100 units of material per day
var production = new Interval&lt;double&gt;(1.5, IntervalType.Hours);
decimal totalPerDay = production.PerDay(100); // 1600 widgets per day (16 * 100)

PerHour Virtual

Given this Interval1` instance, calculates how many occurrences will happen per hour.

Syntax

public virtual System.Decimal PerHour()

Returns

Type: System.Decimal The number of occurrences per hour as a decimal value.

Exceptions

ExceptionDescription
InvalidCastExceptionThrown if T is not convertible to a Decimal.

PerHour Virtual

Given this Interval1` instance and a quantity, calculates the total output per hour.

Syntax

public virtual System.Decimal PerHour(System.Decimal quantity)

Parameters

NameTypeDescription
quantitySystem.DecimalThe quantity to multiply by the interval frequency.

Returns

Type: System.Decimal The total output per hour as a decimal value.

Exceptions

ExceptionDescription
InvalidCastExceptionThrown if T is not convertible to a Decimal.

Examples

// Widget production: 1 widget every 1.5 hours, total from 100 units of material per hour
var production = new Interval&lt;double&gt;(1.5, IntervalType.Hours);
decimal totalPerHour = production.PerHour(100); // 66.67 widgets per hour (1/1.5 * 100)

PerMinute Virtual

Given this Interval1` instance, calculates how many occurrences will happen per minute.

Syntax

public virtual System.Decimal PerMinute()

Returns

Type: System.Decimal The number of occurrences per minute as a decimal value.

Exceptions

ExceptionDescription
InvalidCastExceptionThrown if T is not convertible to a Decimal.

Remarks

If you need this as a whole number, wrap the result in Decimal).

PerMinute Virtual

Given this Interval1` instance and a quantity, calculates the total output per minute.

Syntax

public virtual System.Decimal PerMinute(System.Decimal quantity)

Parameters

NameTypeDescription
quantitySystem.DecimalThe quantity to multiply by the interval frequency.

Returns

Type: System.Decimal The total output per minute as a decimal value.

Exceptions

ExceptionDescription
InvalidCastExceptionThrown if T is not convertible to a Decimal.

Examples

// Widget production: 1 widget every 90 minutes, total from 100 units of material per minute
var production = new Interval&lt;int&gt;(90, IntervalType.Minutes);
decimal totalPerMinute = production.PerMinute(100); // 1.11 widgets per minute (1/90 * 100)

PerMonth Virtual

Given this Interval1` instance, calculates how many occurrences will happen per month.

Syntax

public virtual System.Decimal PerMonth()

Returns

Type: System.Decimal The number of occurrences per month as a decimal value.

Exceptions

ExceptionDescription
InvalidCastExceptionThrown if T is not convertible to a Decimal.

PerMonth Virtual

Given this Interval1` instance and a quantity, calculates the total output per month.

Syntax

public virtual System.Decimal PerMonth(System.Decimal quantity)

Parameters

NameTypeDescription
quantitySystem.DecimalThe quantity to multiply by the interval frequency.

Returns

Type: System.Decimal The total output per month as a decimal value.

Exceptions

ExceptionDescription
InvalidCastExceptionThrown if T is not convertible to a Decimal.

Examples

// Widget production: 1 widget every 3 days, total from 200 units of material per month
var production = new Interval&lt;int&gt;(3, IntervalType.Days);
decimal totalPerMonth = production.PerMonth(200); // 2000 widgets per month (10 * 200)

PerWeek Virtual

Given this Interval1` instance, calculates how many occurrences will happen per week.

Syntax

public virtual System.Decimal PerWeek()

Returns

Type: System.Decimal The number of occurrences per week as a decimal value.

Exceptions

ExceptionDescription
InvalidCastExceptionThrown if T is not convertible to a Decimal.

PerWeek Virtual

Given this Interval1` instance and a quantity, calculates the total output per week.

Syntax

public virtual System.Decimal PerWeek(System.Decimal quantity)

Parameters

NameTypeDescription
quantitySystem.DecimalThe quantity to multiply by the interval frequency.

Returns

Type: System.Decimal The total output per week as a decimal value.

Exceptions

ExceptionDescription
InvalidCastExceptionThrown if T is not convertible to a Decimal.

Examples

// Widget production: 1 widget every 2 days, total from 50 units of material per week
var production = new Interval&lt;int&gt;(2, IntervalType.Days);
decimal totalPerWeek = production.PerWeek(50); // 175 widgets per week (3.5 * 50)

PerYear Virtual

Given this Interval1` instance, calculates how many occurrences will happen per year.

Syntax

public virtual System.Decimal PerYear()

Returns

Type: System.Decimal The number of occurrences per year as a decimal value.

Exceptions

ExceptionDescription
InvalidCastExceptionThrown if T is not convertible to a Decimal.

PerYear Virtual

Given this Interval1` instance and a quantity, calculates the total output per year.

Syntax

public virtual System.Decimal PerYear(System.Decimal quantity)

Parameters

NameTypeDescription
quantitySystem.DecimalThe quantity to multiply by the interval frequency.

Returns

Type: System.Decimal The total output per year as a decimal value.

Exceptions

ExceptionDescription
InvalidCastExceptionThrown if T is not convertible to a Decimal.

Examples

// Widget production: 1 widget every 1 week, total from 500 units of material per year
var production = new Interval&lt;int&gt;(1, IntervalType.Weeks);
decimal totalPerYear = production.PerYear(500); // 26071 widgets per year (52.14 * 500)

ReferenceEquals Inherited

Inherited from object

Syntax

public static bool ReferenceEquals(object objA, object objB)

Parameters

NameTypeDescription
objAobject?-
objBobject?-

Returns

Type: bool

ToString Override

Syntax

public override string ToString()

Returns

Type: string

ToString Inherited Virtual

Inherited from object

Syntax

public virtual string ToString()

Returns

Type: string?