Skip to content

Instantly share code, notes, and snippets.

@alieniasty
Created April 9, 2019 11:47
Show Gist options
  • Save alieniasty/ed6bdecc67aebf2ad7826ade969dd31a to your computer and use it in GitHub Desktop.
Save alieniasty/ed6bdecc67aebf2ad7826ade969dd31a to your computer and use it in GitHub Desktop.
How to perform DI in F#
namespace HelloWorld.Grains
{
/// <summary>
/// Orleans grain implementation class HelloGrain.
/// </summary>
public class HelloGrain : Orleans.Grain, IHello
{
private readonly ILogger logger;
public HelloGrain(ILogger<HelloGrain> logger)
{
this.logger = logger;
}
Task<string> IHello.SayHello(string greeting)
{
logger.LogInformation($"SayHello message received: greeting = '{greeting}'");
return Task.FromResult($"You said: '{greeting}', I say: Hello!");
}
}
}
turns into
type HelloGrain(log:ILogger<HelloGrain>) =
inherit Grain<SampleHolder>()
let logger = log
interface ISample with {..}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment