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

推荐订阅源

Simon Willison's Weblog
Simon Willison's Weblog
G
Google Developers Blog
Spread Privacy
Spread Privacy
I
InfoQ
V
V2EX
S
Schneier on Security
小众软件
小众软件
C
CERT Recently Published Vulnerability Notes
博客园 - 聂微东
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Stack Overflow Blog
Stack Overflow Blog
T
Threat Research - Cisco Blogs
L
Lohrmann on Cybersecurity
Recent Announcements
Recent Announcements
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Attack and Defense Labs
Attack and Defense Labs
云风的 BLOG
云风的 BLOG
The Hacker News
The Hacker News
S
SegmentFault 最新的问题
C
Cybersecurity and Infrastructure Security Agency CISA
NISL@THU
NISL@THU
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
GbyAI
GbyAI
Latest news
Latest news
S
Secure Thoughts
Project Zero
Project Zero
MongoDB | Blog
MongoDB | Blog
I
Intezer
Security Latest
Security Latest
Apple Machine Learning Research
Apple Machine Learning Research
Vercel News
Vercel News
N
Netflix TechBlog - Medium
V2EX - 技术
V2EX - 技术
量子位
T
Threatpost
T
The Blog of Author Tim Ferriss
Y
Y Combinator Blog
T
Tor Project blog
A
Arctic Wolf
Microsoft Security Blog
Microsoft Security Blog
T
The Exploit Database - CXSecurity.com
大猫的无限游戏
大猫的无限游戏
T
Tailwind CSS Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
C
Check Point Blog
博客园 - Franky
Google DeepMind News
Google DeepMind News
The Register - Security
The Register - Security
The GitHub Blog
The GitHub Blog
L
LINUX DO - 热门话题

博客园 - Alen在西安

(转)关于教育些微的几个想法 寻找完美的 URL 验证正则表达式 【转发】 解决VS2012 Find and Replace (Ctrl+Shift+F) 不能正常工作的问题 会让你人生失败的31种原因(图 VS2012 DesignTime 笔记 DTE(vs2012) 编程相关笔记 免费用电信的wifi 简单反编译 chm 文件 如何减少silverlight XAP包的尺寸 读书笔记 - .net2.0 异步编程模型: 使用 IAsyncResult 调用异步方法 测试绑定新浪微博 (转)Debug Silverlight in FireFox [转]CLR 全面透彻解析 - 将 APTCA 程序集迁移到 .NET Framework 4 在VS2010 "Choose Toolbox Item" Dialog 中显示自定义控件 笑话一则 Assembly 的 Shadow-Copy 所在的folder 安装完vS2010Beta2后请重置IDE设置 设置保护眼睛的背景色 又到五一了
Silverlight 控件开发记录之 "extern alias” 关键字
Alen在西安 · 2010-07-13 · via 博客园 - Alen在西安

早在.net2.0, 微软就发布了"extern alias" C#关键字,目的就是为了解决在参照不同的Assembly类型全名相同的问题

以前还没觉得有多大的用处,但在做Silverlight DesignTime开发时,深刻感觉到它的必要了。原因很简单,SilverlightDesignTimeIDE/Blend)都是WPF程序,有很多类型都是同时存在于SLWPF assembly 中,比如System.Windows.FrameworkElement 。所以我们需要用这个关键字来明确指出代码中的类型到底属于SL或者WPF

System.Windows.FrameworkElement 就在PresentationFramework.dll(WPF)System.Windows.dll(SL)中都有定义,当我们在DesignTime代码里需要使用FrameworkElement 时,可以如此调用:

代码

 1 // sl 就是System.Windows.dll的别名,在IDE里你可以用PropertyWindow去定义此Assembly的Aliases属性
 2 //
 3 extern alias sl;
 4 
 5 using System;
 6 using System.Windows;
 7 internal class SampleDesignTimeClass
 8 {
 9 private void SampleMethod(Type myControlType)
10 {
11 // 现在使用的FrameworkElement就是定义在SL中的Type了
12 //
13 if (typeof(sl::System.Windows.FrameworkElement).IsAssignableFrom(myControlType))
14 {
15 ……
16 }
17 }
18  
19 }
20