本文整理匯總了C#中System.Web.HttpContextBase.ModelList方法的典型用法代碼示例。如果您正苦於以下問題:C# HttpContextBase.ModelList方法的具體用法?C# HttpContextBase.ModelList怎麽用?C# HttpContextBase.ModelList使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Web.HttpContextBase
的用法示例。
在下文中一共展示了HttpContextBase.ModelList方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: GetData
/// <summary>
/// Gets the data the plugin should provide.
/// </summary>
/// <param name="context">The current context.</param>
/// <returns>The plugin data.</returns>
public object GetData(HttpContextBase context)
{
var imports = context.ModelList<ImportDescriptor>("MEF-Imports");
var data = new List<object[]> { new object[] { "Contract", "Cardinality", "Prerequisite", "Recomposable", "Matching Exports" } };
foreach (var import in imports)
{
var exports = new List<object[]> { new object[] { "Name", "Creation Policy", "Metadata" } };
exports.AddRange(import.Exports.Select(e => new object[] { e.DisplayName, e.CreationPolicy ?? "Shared", e.Metadata }));
var importData = new []
{
import.ContractName,
import.Cardinality,
(import.Prerequisite ? "_" + import.Prerequisite + "_" : import.Prerequisite.ToString()),
(import.Recomposable ? "_" + import.Recomposable + "_" : import.Recomposable.ToString()),
(exports.Count == 1) ? (object)"No matching exports." : exports
};
data.Add(importData);
}
return data;
}