相关疑难解决方法(0)

签署F#程序集(强名称组件)

我在CodeProject上发现了这篇文章:http: //www.codeproject.com/Articles/512956/NET-Shell-Extensions-Shell-Context-Menus

并且认为尝试一下会很好,但在F#中.所以我想出了以下代码:

open System
open System.IO
open System.Text
open System.Runtime.InteropServices
open System.Windows.Forms
open SharpShell
open SharpShell.Attributes
open SharpShell.SharpContextMenu

[<ComVisible(true)>]
[<COMServerAssociation(AssociationType.ClassOfExtension, ".txt")>]
type CountLinesExtension() =
    inherit SharpContextMenu.SharpContextMenu()

    let countLines =
        let builder = new StringBuilder()
        do 
            base.SelectedItemPaths |> Seq.iter (fun x -> builder.AppendLine(sprintf "%s - %d Lines" (Path.GetFileName(x)) (File.ReadAllLines(x).Length)) |> ignore  )
            MessageBox.Show(builder.ToString()) |> ignore

    let createMenu =
        let menu = new ContextMenuStrip()
        let itemCountLines = new ToolStripMenuItem(Text = "Count Lines")
        do
            itemCountLines.Click.Add (fun _ -> countLines)
            menu.Items.Add(itemCountLines) …
Run Code Online (Sandbox Code Playgroud)

com f# strongname shell-extensions code-translation

9
推荐指数
1
解决办法
1272
查看次数

标签 统计

code-translation ×1

com ×1

f# ×1

shell-extensions ×1

strongname ×1