ASP.NET MVC Bootstrap極速開發架構

來源:互聯網
上載者:User

標籤:blog   http   strong   資料   os   2014   

前言

每次新開發項目都要從頭開始設計?有木有一個通用的快速開發架構?並且得是ASP.NET MVC  And Bootstrap?資料庫不要手工建立?架構對未來業務支援的擴充性好?這麼簡單的功能還需要一天搭建基礎環境?能不能只關心我所需要的業務?

有這樣的一個項目,基於ASP.NET MVC、EntityFramework、Memcached、Bootstrap的快速項目開發架構,只需3秒鐘即可建立一個帶有簡單使用者管理的項目。

一鍵安裝

懶人一鍵安裝包,雙擊“install.bat”批處理,即可將模板項目加入到VS項目模板列表。

極速建立

只需單擊一個“確定”按鈕即可建立一個帶有簡單使用者管理、登陸功能的背景程式,如所示:

 運行效果登陸介面

管理後台主介面

使用者管理

自動建立的資料庫

匯出自己的項目模板

匯出項目模板樣本:

源碼亮點服務介面層,徹底拒絕BLL的垃圾冗餘代碼

服務抽象基類
public abstract class ServiceContext : IDisposable    {        /// <summary>        /// 資料庫操作上下文        /// </summary>        public readonly DefaultDbContext DbContext = new DefaultDbContext();        /// <summary>        /// 緩衝組件        /// </summary>        public CacheContext CacheContext { get; private set; }        /// <summary>        /// 動態設定緩衝對象的新執行個體        /// </summary>        /// <param name="cacheContext">緩衝執行個體對象</param>        public void SetCacheInstance(CacheContext cacheContext)        {            //先釋放現有的緩衝組件            if (CacheContext != null)            {                CacheContext.Dispose();                CacheContext = null;            }            //初始化緩衝組件新的執行個體            CacheContext = cacheContext;        }        public void SetCacheInstance(Type cacheContextType)        {            if (cacheContextType == null)            {                throw new ArgumentNullException("cacheContextType");            }            if (!typeof(CacheContext).IsAssignableFrom(cacheContextType))            {                throw new ArgumentException(                    string.Format(CultureInfo.CurrentCulture, "該類型 {0} 必須繼承自抽象類別CacheContext", cacheContextType),                    "cacheContextType");            }            try            {                CacheContext = Activator.CreateInstance(cacheContextType) as CacheContext;            }            catch (Exception ex)           {                throw new InvalidOperationException(                        String.Format(                            CultureInfo.CurrentCulture,                            "建立抽象類別 CacheContext 的執行個體 {0} 失敗",                            cacheContextType),                        ex);            }        }        public void Dispose()        {            if (DbContext != null)            {                DbContext.Dispose();            }            if (CacheContext != null)            {                CacheContext.Dispose();            }        }    }

 

運行過程中可以動態切換的緩衝組件

服務介面層的具體業務實現

對new關鍵字有潔癖?深痛惡絕?

 一切介面實現實行配置化

 

任何異常休想逃脫 

守株待兔

總結

項目的基本架構給你提供了快速的入門,更NB的設計還需要你的進一步想象發揮。

源碼地址:https://github.com/smartbooks/QuickBootstrap

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.