Skip to content

Instantly share code, notes, and snippets.

@manoj-choudhari-git
Created April 27, 2021 17:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save manoj-choudhari-git/e95af39b67b0cc18c1cf890a5f3af4fa to your computer and use it in GitHub Desktop.
Save manoj-choudhari-git/e95af39b67b0cc18c1cf890a5f3af4fa to your computer and use it in GitHub Desktop.
The service for demonstrating delayed instantiation using .NET dependency injection mechanism
// ICreatedOnDateTimeService.cs
public interface ICreatedOnDateTimeService
{
public DateTime CreatedOn { get; set; }
}
// CreatedOnDateTimeService.cs
public class CreatedOnDateTimeService : ICreatedOnDateTimeService
{
private readonly DateTime createdOn;
public CreatedOnDateTimeService()
{
createdOn = DateTime.Now;
}
public DateTime CreatedOn { get => createdOn; set => throw new NotImplementedException(); }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment