<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      ASP.NET MVC三個重要的描述對象:ParameterDescriptor

      Model綁定是為作為目標Action的方法準備參數列表的過程,所以針對參數的描述才是Model綁定的核心。在ASP.NET MVC應用編程接口中,服務于Model綁定的參數元數據通過ParameterDescriptor類型來表示,而ActionDescriptor的GetParameters方法返回的就是一個ParameterDescriptor數組。

      如下面的代碼片斷所示,ParameterDescriptor同樣實現了ICustomAttributeProvider接口提供應用在相應參數上的特性。ParameterDescriptor的只讀屬性ActionDescriptor表示描述所在Action方法的ActionDescriptor對象。屬性ParameterName、ParameterType和DefaultValue分別表示參數的名稱、類型和默認值。

         1: public abstract class ParameterDescriptor : ICustomAttributeProvider
         2: {   
         3:     public virtual object[] GetCustomAttributes(bool inherit);
         4:     public virtual object[] GetCustomAttributes(Type attributeType, bool inherit);
         5:     public virtual bool IsDefined(Type attributeType, bool inherit);
         6:     
         7:     public abstract ActionDescriptor ActionDescriptor { get; }
         8:     public abstract string ParameterName { get; }
         9:     public abstract Type ParameterType { get; }
        10:     public virtual object DefaultValue { get; }
        11:  
        12:     public virtual ParameterBindingInfo BindingInfo { get; }
        13: }

      ParameterDescriptor的只讀屬性BindingInfo表示的System.Web.Mvc.ParameterBindingInfo對象封裝一些信息用于控制請求數據與參數的綁定行為。如下面的代碼片斷所示,抽象類ParameterBindingInfo具有四個屬性,其中類型為IModelBinder的Binder屬性返回的ModelBinder對象是整個Model綁定的核心,我們將在本章后續部分進行單獨介紹。

         1: public abstract class ParameterBindingInfo
         2: {
         3:     public virtual IModelBinder Binder { get; }
         4:     
         5:     public virtual ICollection<string> Include { get; }
         6:     public virtual ICollection<string> Exclude { get; }
         7:     public virtual string Prefix { get; }
         8: }

      如果參數類型是一個復雜類型,默認情況下會綁定其所有公共可讀寫屬性,而兩個ICollection<string>類型的屬性Include和Exclude表示顯示設置的參與/不參與綁定的屬性名稱列表。在默認情況下,請求數據與參數之間嚴格按照名稱進行綁定,但是有時候請求數據名稱具有相應的前綴,這個前綴體現在ParameterBindingInfo的Prefix屬性上。

      ReflectedParameterDescriptor

      原生的ParameterBindingInfo是通過針對表示參數的ParameterInfo進行反射獲得,這樣的ParameterBindingInfo通過ReflectedParameterDescriptor類型表示。如下面的代碼片斷所示,這個ParameterInfo對象通過只讀屬性ParameterInfo表示,并在構造函數中被初始化。

         1: public class ReflectedParameterDescriptor : ParameterDescriptor
         2: {   
         3:     public ReflectedParameterDescriptor(ParameterInfo parameterInfo, ActionDescriptor actionDescriptor);
         4:     public override object[] GetCustomAttributes(bool inherit);
         5:     public override object[] GetCustomAttributes(Type attributeType, bool inherit);
         6:     public override bool IsDefined(Type attributeType, bool inherit);
         7:     
         8:     public override ActionDescriptor ActionDescriptor { get; }
         9:     public override ParameterBindingInfo BindingInfo { get; }
        10:     public override object DefaultValue { get; }
        11:     public override string ParameterName { get; }
        12:     public override Type ParameterType { get; }
        13:     
        14:     public ParameterInfo ParameterInfo { get; }
        15: }

      ReflectedParameterDescriptor的BindingInfo屬性返回的是一個ReflectedParameterBindingInfo對象,這是一個內部類型。該BindingInfo的Include、Exclude和Prefix屬性來源于對應用在參數上的BindAttribute特性的解析。如下面的代碼片斷所示,BindAttribute中同樣定義了這三個屬性,其中Include和Exclude為通過逗號作為分隔符的屬性名稱列表。

         1: [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Class, AllowMultiple=false, Inherited=true)]
         2: public sealed class BindAttribute : Attribute
         3: {
         4:     public bool IsPropertyAllowed(string propertyName);   
         5:     
         6:     public string Include { get; set; }
         7:     public string Exclude { get; set; }
         8:     public string Prefix { get; set;}
         9: }

      布爾返回類型的IsPropertyAllowed方法用于判斷指定的屬性是否允許綁定,當指定在屬性名在Include列表中(或者Include列表為空)并且不在Exclude列表的情況下返回True,否則返回False。

      ASP.NET MVC三個重要的描述對象:ControllerDescriptor
      ASP.NET MVC三個重要的描述對象:ActionDescriptor
      ASP.NET MVC三個重要的描述對象:ControllerDescriptor與ActionDescriptor的創建機制
      ASP.NET MVC三個重要的描述對象:ParameterDescriptor

      posted @ 2012-05-13 18:37  Artech  閱讀(6873)  評論(7)    收藏  舉報
      主站蜘蛛池模板: 一区二区三区四区五区色| 91精品国产综合久蜜臀| 亚洲色大成网站www永久男同| 一区二区三区四区五区色| 亚洲国产超清无码专区| 好男人官网资源在线观看| 久久综合88熟人妻| 久久久久久久久久久免费精品| 18禁男女爽爽爽午夜网站免费 | 91国在线啪精品一区| 国产一卡2卡三卡4卡免费网站| 国产午夜精品无码一区二区| 欧美成人精品高清在线播放| 99热久久这里只有精品| 99精品免费久久久久久久久日本 | 好男人社区在线www| 亚洲三级香港三级久久| 办公室强奷漂亮少妇视频| 成人一区二区不卡国产| 亚洲男人的天堂在线观看| 无码人妻丝袜在线视频| 免费中文熟妇在线影片| 热久在线免费观看视频| 久久精品国产免费观看频道| 亚洲性猛交xxxx| 亚洲第一综合天堂另类专| 亚洲成A人片在线观看无码不卡| 精品国际久久久久999波多野| 成人乱码一区二区三区四区| 国产三级精品三级在线观看| 国产成人精品国内自产色| 中文字幕国产精品av| 性做久久久久久久久| 亚洲精品在线二区三区| 正蓝旗| 久久精品一偷一偷国产| 亚洲AV无码一区二区一二区色戒| 性色在线视频精品| 国产黄色三级三级看三级| 国产精品亚洲二区在线播放 | 亚洲av中文久久精品国内|