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

推荐订阅源

W
WeLiveSecurity
T
The Exploit Database - CXSecurity.com
C
CXSECURITY Database RSS Feed - CXSecurity.com
S
Security @ Cisco Blogs
T
Threat Research - Cisco Blogs
TaoSecurity Blog
TaoSecurity Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
腾讯CDC
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
T
The Blog of Author Tim Ferriss
Microsoft Azure Blog
Microsoft Azure Blog
罗磊的独立博客
F
Full Disclosure
博客园 - 【当耐特】
C
CERT Recently Published Vulnerability Notes
Engineering at Meta
Engineering at Meta
Application and Cybersecurity Blog
Application and Cybersecurity Blog
T
Threatpost
I
Intezer
V2EX - 技术
V2EX - 技术
H
Hackread – Cybersecurity News, Data Breaches, AI and More
The Hacker News
The Hacker News
小众软件
小众软件
Google DeepMind News
Google DeepMind News
T
Tailwind CSS Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
B
Blog RSS Feed
Microsoft Security Blog
Microsoft Security Blog
N
News | PayPal Newsroom
MyScale Blog
MyScale Blog
AI
AI
Vercel News
Vercel News
Spread Privacy
Spread Privacy
美团技术团队
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
The GitHub Blog
The GitHub Blog
V
Vulnerabilities – Threatpost
Schneier on Security
Schneier on Security
Cyberwarzone
Cyberwarzone
G
GRAHAM CLULEY
Help Net Security
Help Net Security
Hacker News: Ask HN
Hacker News: Ask HN
Google DeepMind News
Google DeepMind News
MongoDB | Blog
MongoDB | Blog
L
LINUX DO - 热门话题
U
Unit 42
L
LangChain Blog
Recent Announcements
Recent Announcements

博客园 - 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 ,但其内容可为空,还是可以忽略不记的。