NuGet套件

TopShelf

開發Windows Service的時後,為了開發方便,之前都用一些小技巧切換在本機的Console模式和伺服器的Service模式,但在日後維護的時後或是偵錯的時後,總是不太方便,最近用了一個好用的套件叫TopShelf,是一個用來開發Windows Service的框架,實在太好用了,所以記錄一下筆記 首先新增一個Console專案 [![](http://2.bp.blogspot.com/-b-j_Dv8q9Y0/Vqg97bx32-I/AAAAAAAADkE/QVrxbWArdXg/s1600/01.%25E6%2596%25B0%25E5%25A2%259E%25E5%25B0%2588%25E6%25A1%2588.png)](http://2.bp.blogspot.com/-b-j_Dv8q9Y0/Vqg97bx32-I/AAAAAAAADkE/QVrxbWArdXg/s1600/01.%25E6%2596%25B0%25E5%25A2%259E%25E5%25B0%2588%25E6%25A1%2588.png) 透過NuGet安裝TopShelf套件 [![](http://4.bp.blogspot.com/-0rrhnPEnOBU/Vqg97v3I74I/AAAAAAAADkQ/3I4zfXvgEYg/s1600/02.%25E5%25AE%2589%25E8%25A3%259D%25E5%25A5%2597%25E4%25BB%25B6.png)](http://4.bp.blogspot.com/-0rrhnPEnOBU/Vqg97v3I74I/AAAAAAAADkQ/3I4zfXvgEYg/s1600/02.%25E5%25AE%2589%25E8%25A3%259D%25E5%25A5%2597%25E4%25BB%25B6.png) 簡單地寫一個類別,包含Start和Stop兩個函式 using System; namespace ConsoleApplication1 { class MyService { public void Start() { Console.WriteLine(“MyService Start”); } public void Stop() { Console.WriteLine("My Service Stop"); } } } 回到應用程式進入點開始配置服務 using Topshelf; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { Topshelf.HostFactory.Run(x=> { x.Service<MyService>(s => { s.ConstructUsing(() => new MyService()); s.WhenStarted(svc => svc.Start()); s.WhenStopped(svc => svc.Stop()); }); x.RunAsLocalSystem(); x.StartAutomatically(); x.SetServiceName("MyService"); x.


Ladda-Bootstrap 套件

ladda-bootstrap用將spin.js整合bootstrap,並加強功能的一個套件 官網上有很詳細的使用範例 透過NuGet就可以安裝 [![](http://1.bp.blogspot.com/-IughOK48vhE/VCuejPlOPuI/AAAAAAAABtE/x5bf4Vtf7PY/s1600/01.%E5%AE%89%E8%A3%9D%E5%A5%97%E4%BB%B6.png)](http://1.bp.blogspot.com/-IughOK48vhE/VCuejPlOPuI/AAAAAAAABtE/x5bf4Vtf7PY/s1600/01.%E5%AE%89%E8%A3%9D%E5%A5%97%E4%BB%B6.png) 可以看到套件相依於spin.js [![](http://2.bp.blogspot.com/-UqPTwSVmbmM/VCuenBELR-I/AAAAAAAABtM/iBFBfK9RyUo/s1600/02.%E5%A5%97%E4%BB%B6%E7%9B%B8%E4%BE%9D%E6%80%A7.png)](http://2.bp.blogspot.com/-UqPTwSVmbmM/VCuenBELR-I/AAAAAAAABtM/iBFBfK9RyUo/s1600/02.%E5%A5%97%E4%BB%B6%E7%9B%B8%E4%BE%9D%E6%80%A7.png) 使用方式是在button上,加上ladda-button的css類別,要顯示的文字加上ladda-label的css類別 <button id="btn1" class="btn btn-primary ladda-button" data-style="expand-left"> <span class="ladda-label">button</span> </button> 另外透過data-style來指定動畫效果 data-style="expand-left" data-style="expand-right" data-style="expand-up" data-style="expand-down" data-style="zoom-in" data-style="zoom-out" data-style="slide-left" data-style="slide-right" data-style="slide-up" data-style="slide-down" data-style="contract" 最後透過JavaScript來觸發,先用Ladda.create(element)來取得物件 呼叫物件的start來開始動畫 呼叫物件的stop來停止動畫 $(function () { $("#btn1").click(function () { var obj = Ladda.create(this); obj.start(); setTimeout(function () { obj.stop(); }, 1000); }); }); spin.js.2.0.1好像和ladda不太和,最好先降到spin.js 1.3版就好 相關資料 Bootstrap button loading text http://blog.developer.idv.tw/2014/10/bootstrap-button-loading-text.html spin.js 套件 http://blog.developer.idv.tw/2014/10/spinjs.html