How to implement C # interface in F #?

I would like to implement the following C # interface in F #:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Mono.Addins;

[TypeExtensionPoint]
public interface ISparqlCommand
{
    string Name { get; }
    object Run(Dictionary<string, string> NamespacesDictionary,    org.openrdf.repository.Repository repository, params object[] argsRest);
}   

This is what I tried, but it gives me: "Incomplete structured construction at or to this point in the expression"

#light

module Module1

open System
open System.Collections.Generic;

type MyClass() =
    interface ISparqlCommand with
        member this.Name = 
            "Finding the path between two tops in the Graph"
        member this.Run(NamespacesDictionary, repository, argsRest) = 
            new System.Object

What am I doing wrong? Maybe the indentation is wrong?

+5
source share
2 answers

I confirmed @Mark's answer in the comments. Given the following C # code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace org.openrdf.repository {
    public class Repository {
    }
}

namespace CSLib
{

    [System.AttributeUsage(System.AttributeTargets.Interface)]
    public class TypeExtensionPoint : System.Attribute
    {
        public TypeExtensionPoint()
        {
        }
    }


    [TypeExtensionPoint]
    public interface ISparqlCommand
    {
        string Name { get; }
        object Run(Dictionary<string, string> NamespacesDictionary, org.openrdf.repository.Repository repository, params object[] argsRest);
    }

}

The following F # implementation (only a change adds ()to the design of the object) works "perfectly":

#light

module Module1

open System
open System.Collections.Generic;
open CSLib

type MyClass() =
    interface ISparqlCommand with
        member this.Name = 
            "Finding the path between two tops in the Graph"
        member this.Run(NamespacesDictionary, repository, argsRest) = 
            new System.Object()

#light ( ), NamespaceDictionary, , " ". , MyClass ISparqlCommand, ( , , , #): (MyClass() :> ISparqlCommand).Name

+3

! :

namespace MyNamespace

open System
open System.Collections.Generic;
open Mono.Addins

[<assembly:Addin>]
    do()
[<assembly:AddinDependency("TextEditor", "1.0")>]
    do()

[<Extension>]
type MyClass() =
    interface ISparqlCommand with
         member this.Name
             with get() = 
                 "Finding the path between two tops in a Graph"
         member this.Run(NamespacesDictionary, repository, argsRest) = 
             new System.Object()

Mono.Addins F #

+1

All Articles