Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on Predictably Random.
I created a 'Random' service that lives for the length of the execution of the application.
This service has an instance of Random that persists with the object, and exposes simple methods with min/max parameters.
I register the service in a unity container, and then immediately resolve it, causing the Random type inside of the random service to instantiate.
Then anywhere I want to generate a random number, I inject that service.
This works because, as long as you persist a single instance of 'Random', two calls to 'Next' or 'NextDouble' won't result in the same number.
There are no comments on this comment yet.
I created a 'Random' service that lives for the length of the execution of the application.
This service has an instance of Random that persists with the object, and exposes simple methods with min/max parameters.
I register the service in a unity container, and then immediately resolve it, causing the Random type inside of the random service to instantiate.
Then anywhere I want to generate a random number, I inject that service.
This works because, as long as you persist a single instance of 'Random', two calls to 'Next' or 'NextDouble' won't result in the same number.