惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

P
Palo Alto Networks Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
C
CERT Recently Published Vulnerability Notes
C
Cybersecurity and Infrastructure Security Agency CISA
S
Schneier on Security
S
Securelist
酷 壳 – CoolShell
酷 壳 – CoolShell
C
CXSECURITY Database RSS Feed - CXSecurity.com
Cyberwarzone
Cyberwarzone
Apple Machine Learning Research
Apple Machine Learning Research
S
SegmentFault 最新的问题
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
GbyAI
GbyAI
Security Latest
Security Latest
Last Week in AI
Last Week in AI
Microsoft Security Blog
Microsoft Security Blog
云风的 BLOG
云风的 BLOG
Recorded Future
Recorded Future
Webroot Blog
Webroot Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
TaoSecurity Blog
TaoSecurity Blog
C
Cisco Blogs
博客园 - 【当耐特】
Blog — PlanetScale
Blog — PlanetScale
Hugging Face - Blog
Hugging Face - Blog
B
Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Attack and Defense Labs
Attack and Defense Labs
The Last Watchdog
The Last Watchdog
U
Unit 42
阮一峰的网络日志
阮一峰的网络日志
Project Zero
Project Zero
WordPress大学
WordPress大学
L
LINUX DO - 最新话题
F
Fortinet All Blogs
L
LINUX DO - 热门话题
PCI Perspectives
PCI Perspectives
Simon Willison's Weblog
Simon Willison's Weblog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
MongoDB | Blog
MongoDB | Blog
Latest news
Latest news
P
Proofpoint News Feed
T
Threat Research - Cisco Blogs
The Hacker News
The Hacker News
爱范儿
爱范儿
O
OpenAI News
J
Java Code Geeks
T
The Exploit Database - CXSecurity.com
H
Hackread – Cybersecurity News, Data Breaches, AI and More

博客园 - sh37

Newtonsoft中的几个妙用 Mvc中ViewData与TempData的区别 Silverlight中利用ListBox特性实现单选按钮组RadioButtonList和复选按钮组CheckBoxList的功能 cookie操作 - sh37 - 博客园 C# 利用net 命令获取域用户列表 - sh37 利用MessageQueue收发消息 - sh37 - 博客园 C# xmlhttp - sh37 - 博客园 使用ASP获得AD帐号 “域\用户名” - sh37 - 博客园 使用ASP.NET获得AD帐号 - sh37 - 博客园 根據xml文檔數據 給DataTable增加行 JS获取剪贴板内容的代码 - sh37 - 博客园 分页时使当前页码变色 C#生成缩略图 自動生成帶文字的圖片 常用pl/sql vb.net後台抓取網頁內容 ServerVariables集合内容列表 如何动态创建一个按纽 并给这个按纽绑上一个Onclick事件 17种常用正则表达式
SilverLight中Page也可使用泛型基类
sh37 · 2011-10-18 · via 博客园 - sh37

最近在用SilverLight+MVC做项目时碰到问题,以往用Asp.net中WebForm做项目时都会在项目框架中使用继承自Page的泛型基类来实现增、删、查、改等基础方法。

但在SilverLight却无法使用,如以下代码无法成功编译

 public partial class CodeClassManage: SysPageBase<CodeClass>

{

//.......

}

//其基类SysPageBase实现了增、删、查、改等基础方法

public partial class SysPageBase<T> : Page
        where T:Entity,new()

{

//实现增、删、查、改等基础方法的过程略过

//...

}

因为CodeClassManage页面文件如下

<Bis:SysPageBase  x:Class="SLApp.CodeClassManage" 

Bis="clr-namespace:SLApp;assembly=SLApp"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d" >

 </Bis:SysPageBase>

红色代码部分无法使用泛型。

 在网上找了很久也未找到解决办法。于是想到了使用中间类来转一下,以上代码变为

public partial class CodeClassManage : TCodeClassManage
 {

//.....

}

//以下为多出来的中间类,其内容可为空

 public partial class TCodeClassManage: SysPageBase<CodeClass>

{

}

//其基类SysPageBase实现了增、删、查、改等基础方法

public partial class SysPageBase<T> : Page
        where T:Entity,new()

{

//实现增、删、查、改等基础方法的过程略过

//...

}

CodeClassManage页面文件如下

<Bis:TCodeClassManage x:Class="SLApp.CodeClassManage" 

Bis="clr-namespace:SLApp;assembly=SLApp"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d" >

 </Bis:TCodeClassManage >

 以上达到使用泛型基类的目的,虽然多出了个中间类TCodeClassManage ,但其内容可为空,还是可以忽略不记的。