Skip to content

Instantly share code, notes, and snippets.

@pizycki
Created November 27, 2019 13:30
Show Gist options
  • Select an option

  • Save pizycki/33d0c9791356040cee970227a8d348ce to your computer and use it in GitHub Desktop.

Select an option

Save pizycki/33d0c9791356040cee970227a8d348ce to your computer and use it in GitHub Desktop.
Generic IOptions
public class GenericOptions<T> : IOptions<T> where T : class, new()
{
public GenericOptions(T value)
{
Value = value ?? throw new ArgumentNullException(nameof(value));
}
public T Value { get; }
}
type GenericOptions<'T when 'T : (new : unit -> 'T) and 'T : not struct>(value:'T) =
interface IOptions<'T> with
member x.Value = value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment