學習使用C#語言背景去理解、思考各設計模式的意義、作法,陸陸續續理解完之後在來貼相關的文章:

Creational Patterns  【創建型(生成)模式】:

文章標籤

Jimmy 發表在 痞客邦 留言(1) 人氣()

想學習一下LINQ語法,發現不錯的文章,翻譯成繁中做個記錄。

本系列文章導航

文章標籤

Jimmy 發表在 痞客邦 留言(1) 人氣()

讓enum變成view來使用好像滿頻繁的,記錄一下擴充dropdownlist

public static MvcHtmlString DropDownEnumList<T>(this HtmlHelper htmlHelper, string name, string selectValue)
            where T : struct, IConvertible
        {
            return htmlHelper.DropDownList(name, GetSelectEnumListItems<T>(selectValue));
        }

        public static MvcHtmlString DropDownEnumList<T>(this HtmlHelper htmlHelper, string name,string selectValue, object htmlAttributes)
            where T : struct, IConvertible 
        {
            return htmlHelper.DropDownList(name, GetSelectEnumListItems<T>(selectValue), htmlAttributes);
        }

        public static MvcHtmlString DropDownEnumList<T>(this HtmlHelper htmlHelper, string name,string selectValue, IDictionary<string, object> htmlAttributes)
            where T : struct, IConvertible 
        {
            return htmlHelper.DropDownList(name, GetSelectEnumListItems<T>(selectValue), htmlAttributes);
        }

        public static MvcHtmlString DropDownEnumList<T>(this HtmlHelper htmlHelper, string name,string selectValue, string optionLabel)
            where T : struct, IConvertible 
        {
            return htmlHelper.DropDownList(name, GetSelectEnumListItems<T>(selectValue), optionLabel);
        }

        public static MvcHtmlString DropDownEnumList<T>(this HtmlHelper htmlHelper, string name, string selectValue, string optionLabel, object htmlAttributes)
            where T : struct, IConvertible 
        {
            return htmlHelper.DropDownList(name, GetSelectEnumListItems<T>(selectValue), optionLabel, htmlAttributes);
        }

        public static MvcHtmlString DropDownEnumList<T>(this HtmlHelper htmlHelper, string name,string selectValue, string optionLabel, IDictionary<string, object> htmlAttributes)
            where T : struct, IConvertible 
        {
            return htmlHelper.DropDownList(name, GetSelectEnumListItems<T>(selectValue), optionLabel, htmlAttributes);
        }

        public static IEnumerable<SelectListItem> GetSelectEnumListItems<T>(string selectValue)
            where T : struct, IConvertible
        {
            List<SelectListItem> items = new List<SelectListItem>();
            foreach (var e in Enum.GetNames(typeof(T)))
            {
                string val = ((int)Enum.Parse(typeof(T), e)).ToString();
                var selectlistItem = new SelectListItem() { Text = e, Value = val };
                if (!string.IsNullOrWhiteSpace(selectValue) && (val == selectValue))
                {
                    selectlistItem.Selected = true;
                }
                items.Add(selectlistItem);
            }
            return items;
        }

Jimmy 發表在 痞客邦 留言(0) 人氣()

abstractvirtualoverridenew是在類別的繼承關係中常用的四個修飾方法的關鍵字,在此略作總結。

1. 常用的中文名稱:

文章標籤

Jimmy 發表在 痞客邦 留言(12) 人氣()

最近寫前端的js比寫後端的c#程式還要多。用了滿多的plugin,記錄一下@@。

像在做「進階搜尋」UI時滿常看到的:

文章標籤

Jimmy 發表在 痞客邦 留言(0) 人氣()

23種模式趣味解釋

創建型模式 

文章標籤

Jimmy 發表在 痞客邦 留言(1) 人氣()

Deriving from Multiple Base Interfaces 從多個基接口派生

與類不同,接口可以有不止一個基接口。清單12-8含有一個例子。

文章標籤

Jimmy 發表在 痞客邦 留言(0) 人氣()

本文摘自"Introducing Visual C# 2010"(Adam Freeman, Apress, 2010)一書第12章關於介面的內容。

使用介面

文章標籤

Jimmy 發表在 痞客邦 留言(0) 人氣()

結構定義

CREATE TABLE

文章標籤

Jimmy 發表在 痞客邦 留言(0) 人氣()

一、NHibernate簡介

什麼是NHibernate?

文章標籤

Jimmy 發表在 痞客邦 留言(1) 人氣()