Unfortunately, if you want to use the interface and pass the value to the constructor, then nyinyithann's answer is correct. You can set public properties in a constructor call like this.
type TemplateService() =
let mutable templateDirectory = ""
member this.TemplateDirectory
with get() = templateDirectory
and set directory =
if directory = null then
raise (new System.ArgumentNullException "templateDirectory")
templateDirectory <- directory
let template = TemplateService(TemplateDirectory = "root")
, , .
type ITemplateService =
abstract TemplateDirectory : string with get, set
type TemplateService() =
let mutable templateDirectory = ""
interface ITemplateService with
member this.TemplateDirectory
with get() = templateDirectory
and set directory =
if directory = null then
raise (new System.ArgumentNullException "templateDirectory")
templateDirectory <- directory
let template = TemplateService(TemplateDirectory = "root") // error
.
let template = TemplateService()
(template :> ITemplateService).TemplateDirectory <- "root"