Class TimeBasedObjectResultOptions<T>
- Namespace
- Cuemon.AspNetCore.Mvc
- Assembly
- Cuemon.AspNetCore.Mvc.dll
Specifies options that is related to the ICacheableObjectResult interface.
public class TimeBasedObjectResultOptions<T> : ITimeBasedObjectResultOptions<T>, IValidatableParameterObject, IParameterObject
Type Parameters
T
- Inheritance
-
TimeBasedObjectResultOptions<T>
- Implements
Examples
The following example demonstrates how to configure to provide timestamp providers for generating Last-Modified headers.
using System;
using Cuemon.AspNetCore.Mvc;
namespace MyApp.Examples;
public class TimeBasedObjectResultOptionsExample
{
public void Demonstrate()
{
var options = new TimeBasedObjectResultOptions<DateTime>
{
TimestampProvider = value => value,
ChangedTimestampProvider = value => value.AddHours(1)
};
// Validate that the required properties are configured
options.ValidateOptions();
var created = new DateTime(2026, 1, 1, 0, 0, 0, DateTimeKind.Utc);
Console.WriteLine($"Created: {options.TimestampProvider(created)}");
Console.WriteLine($"Modified: {options.ChangedTimestampProvider(created)}");
}
}
Constructors
TimeBasedObjectResultOptions()
Initializes a new instance of the TimeBasedObjectResultOptions<T> class.
public TimeBasedObjectResultOptions()
Properties
ChangedTimestampProvider
Gets or sets the function delegate that resolves a timestamp from when the specified T was last modified, expressed as the Coordinated Universal Time (UTC).
public Func<T, DateTime> ChangedTimestampProvider { get; set; }
Property Value
- Func<T, DateTime>
The function delegate that resolves a timestamp from when the specified
Twas last modified.
TimestampProvider
Gets or sets the function delegate that resolves a timestamp from when the specified T was first created, expressed as the Coordinated Universal Time (UTC).
public Func<T, DateTime> TimestampProvider { get; set; }
Property Value
- Func<T, DateTime>
The function delegate that resolves a timestamp from when the specified
Twas first created.
Methods
ValidateOptions()
Determines whether the public read-write properties of this instance are in a valid state.
public void ValidateOptions()
Remarks
This method is expected to throw exceptions when one or more conditions fails to be in a valid state.
Exceptions
- InvalidOperationException
TimestampProvider cannot be null.