C # a F # Convertir Dispositivo clase parcial pública: MarshalByRefObject

StackOverflow https://stackoverflow.com/questions/4376275

  •  09-10-2019
  •  | 
  •  

Pregunta

public partial class Device : MarshalByRefObject
{
    internal bool FindTagName(string name, OneTag tag)
    {
        foreach (FuncSect fs in listFuncSect)
        {
            foreach (OneTag ot in fs.listTags)
            {
                if (ot != tag && ot.Name == name) return true;
            }
        }
        return false;
    }

todavía no tienen idea de cómo convertir este "parcial" y "interno" a F #

gracias

¿Fue útil?

Solución

Como dice leppie, no hay soporte directo para partial, si bien se puede lograr un efecto similar con intrinsic . F # hace métodos apoyo internal, por lo que su ejemplo se vería así:

// primary definition somewhere
type Device() =
  inherit MarshalByRefObject()
  ...


// type extension (roughly equivalent to partial class)
type Device with
  member internal this.FindTagName(name:string, tag:OneTag) =
    listFuncSect
    |> Seq.exists 
         (fun fs -> 
            fs.listTags 
            |> Seq.exists (fun ot -> ot <> tag && ot.name = name))

Otros consejos

partial es una característica compilador de C #, no se va a trabajar en F #, que tendrá que todas las clases parciales combinados, o heredar de uno existente.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top