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

推荐订阅源

V
V2EX
量子位
博客园 - 司徒正美
IT之家
IT之家
V
Visual Studio Blog
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
Google DeepMind News
Google DeepMind News
Last Week in AI
Last Week in AI
Microsoft Security Blog
Microsoft Security Blog
T
Tailwind CSS Blog
aimingoo的专栏
aimingoo的专栏
GbyAI
GbyAI
Vercel News
Vercel News
B
Blog
大猫的无限游戏
大猫的无限游戏
D
DataBreaches.Net
小众软件
小众软件
罗磊的独立博客
博客园 - 叶小钗
雷峰网
雷峰网
Martin Fowler
Martin Fowler
Hugging Face - Blog
Hugging Face - Blog
WordPress大学
WordPress大学

博客园 - 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