ApplicationDomain.currentDomain的细节
- 博客分类:
- 技术杂绘
ApplicationDomain.currentDomain的细节
2010年12月24日
平时使用这个属性的时候,一般不会注意什么,直接无脑拿来用的。。。
今天作一些代码验证时,发现了一个问题:
trace(ApplicationDomain.currentDomain==ApplicationDomain.currentDomain)
直接这样判断居然是不相等的!
于是查找了下帮助,上面写着:
currentDomainpropertycurrentDomain:ApplicationDomain [read-only]
Language Version: ActionScript 3.0Runtime Versions: AIR 1.0 Flash Player 9, Flash Lite 4
Gets the current application domain in which your code is executing.
Implementation
public static function get currentDomain():ApplicationDomain
貌似看起来没啥帮助,直接理解基本上就是一个只读指针了,怎么会同样的东东不一致呢。
分析估计是一个工厂模式的实现,即每次会找到stage的所在,然后包装成一个新的ApplicationDomain返回。
这样用对于URLLoader使用loadercontext时略方便,以及在无法获得stage的情况下也能够正确得到applicationDomain。
但每次不一致有时还是很纠结
不过好在每个loaderinfo的applicationDomain是真正的只读指针,即下面这样用肯定是会相等的:
trace(stage.loaderInfo.applicationDomain==stage.loaderInfo.applicationDomain)
既然ApplicationDomain.currentDomain不能直接的得到stage的applicationDomain的直接引用,也不能判断多domain的情况的正确性对比,所以要用的话最好还是单独封装到一个另一个静态类中,如StageApplicationDomain.currentDomain,并且由stage初始化时简单赋值即可。。。
真不知道adobe咋想的,简单做成一个指针不就得了……
发表评论
-
读书笔记 《深度探索c++对象模型》 (4)
2012-01-20 01:47 518读书笔记 《深度探索c++对象模型》 (4) 2010年07 ... -
pv3d视频教程
2012-01-20 01:47 821pv3d视频教程 2010年08月06日 原址: 内容: ... -
Papervision3D Essentials 要点整理
2012-01-20 01:47 571Papervision3D Essentials 要点 ... -
Android Bitmap和Canvas
2012-01-20 01:47 726Android Bitmap和Canvas 2010年09月 ... -
VxWorks下编程的几个误区
2012-01-20 01:47 775VxWorks下编程的几个误区 ... -
小学生作文批改评语
2012-01-19 09:34 573小学生作文批改评语 2011年09月05日 作文开头: ... -
小学作文评语原则及思考
2012-01-19 09:34 543小学作文评语原则及思 ... -
服务器控件的三个ID
2012-01-19 09:34 775服务器控件的三个ID 2011年05月22日 在ASP. ... -
学习左向相平得体会
2012-01-19 09:34 573学习左向相平得体会 20 ... -
2011-12-22
2012-01-19 09:34 4962011-12-22 2011年12月22日 ... -
我的文件17/1
2012-01-17 02:09 511我的文件17/1 2010年07月26日 Protel技 ... -
2011年计算机三级考试PC技术知识要点(32)
2012-01-17 02:09 6502011年计算机三级考试PC ... -
FLTK简介
2012-01-17 02:09 552FLTK简介 2011年11月22日 ... -
J2SE简介与J2EE、J2ME的比较
2012-01-17 02:09 669J2SE简介与J2EE、J2ME的比较 2010年06月15 ... -
【顶】FLASH教程――目录
2012-01-15 21:41 618【顶】FLASH教程――目录 2009年09月15日 追 ... -
AS3容器的实现原理
2012-01-15 21:41 568AS3容器的实现原理 2010年07月09日 所谓 ... -
2009 - 2010 Flex 工作笔记
2012-01-15 21:40 6982009 - 2010 Flex 工作笔记 ... -
【顶】flash教程――目录
2012-01-15 21:40 616【顶】flash教程――目录 2009年09月15日 F ...
相关推荐
关于AppDomain编程的全面资料,适合中高级技术人员阅读
context.applicationDomain = new ApplicationDomain(ApplicationDomain.currentDomain); context.applicationDomain = ApplicationDomain.currentDomain; context.applicationDomain = new ApplicationDomain(); ...
System.AppDomain.CurrentDomain.BaseDirectory // 获取模块的完整路径。 System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName // 获取和设置当前目录(该进程从中启动的目录)的完全限定目录。 ...
获取当前目录可以使用 代码如下:appdomain.currentdomain.basedirectory 获取当前目录的上级目录 代码如下:path.getfullpath(“..”) 具体代码如下: 代码如下:using system; using system.collections.generic; ...
打开数据库连接 string dataDir = AppDomain.CurrentDomain.BaseDirectory; if (dataDir.EndsWith(@"\bin\Debug\") || dataDir.EndsWith(@"\bin\Release\")) { dataDir = System.IO.Directory.GetParent(dataDir...
//可获得当前执行的exe的文件名。 string str1 =Process.GetCurrentProcess().MainModule.FileName;// 获取和设置当前目录(即该进程从中启动...string str7=AppDomain.CurrentDomain.SetupInformation.ApplicationBase
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);//添加代码 InitializeComponent(); JObject obj = new JObject(); } //添加代码 System.Reflection....
log4net.Config.XmlConfigurator.ConfigureAndWatch(new FileInfo(AppDomain.CurrentDomain.BaseDirectory + "log4net.config")); HostFactory.Run(x => { x.UseLog4Net(); x.Service(); x.SetDescription(...
asp.net using System;... file.SaveAs(Path.Combine(AppDomain.CurrentDomain.BaseDirectory+@"ChatTemp\" , file.FileName)); } } public bool IsReusable { get { return true; } } }
MVC+ICOAutoFac+EF+三层+VS2013 ICOAutoFac+构造函数注入,单个类注入,一次所有类注入,接口注入 简单例子仅供学习,数据库DBscript.sql,... var assemblys = AppDomain.CurrentDomain.GetAssemblies().ToList();
这里建立了一个有关异常处理的对话框类,来实现异常的捕捉。通过使用ThreadException, App.CurrentDomain.UnhandledException捕捉程序里不可预知的异常,可以帮助开发者方便的找到发生异常的位置。
inter.StartOPCSvr (System.AppDomain .CurrentDomain .BaseDirectory +"Test.exe"); //暂停当前服务 inter.Suspend (); //重新启动服务 inter.Resume (); //停止当前服务 inter.CloseOPCSvr(); //查看当前TAG...
StreamReader objFile = new StreamReader(AppDomain.CurrentDomain.BaseDirectory + @"\PictureLog.txt"); txtLog.Text = objFile.ReadToEnd(); objFile.Close(); objFile.Dispose(); } catch { txtLog....
inter.StartOPCSvr (System.AppDomain .CurrentDomain .BaseDirectory +"Test.exe"); //暂停当前服务 inter.Suspend (); //重新启动服务 inter.Resume (); //停止当前服务 inter.CloseOPCSvr(); //查看当前TAG...
private FileAgileLogger logger = new FileAgileLogger(AppDomain.CurrentDomain.BaseDirectory "UpdateLog.txt"); private IRapidPassiveEngine rapidPassiveEngine; private UpdateConfiguration update...
源码概要描述 :2个Excel 作为主表,利用第三个Excel作为模板,生成新的...System.AppDomain.CurrentDomain.BaseDirectory.Replace(@"bin\Debug\", @"Template\excel模板.xlsx") 这句代码就是为了获得Excel模板所在路径
pro.StartInfo.FileName = AppDomain.CurrentDomain.BaseDirectory + "ffmpeg.exe"; pro.StartInfo.Arguments = " -i " + fileName; pro.Start(); System.IO.StreamReader errorreader = pro.StandardError; ...
inter.StartOPCSvr (System.AppDomain .CurrentDomain .BaseDirectory +"Test.exe"); //暂停当前服务 inter.Suspend (); //重新启动服务 inter.Resume (); //停止当前服务 inter.CloseOPCSvr(); //查看当前TAG...
, AppDomain.CurrentDomain.BaseDirectory + "Download\\" + filelist[i].Name.ToString()); } --上传文件方法体 string sourcePath = AppDomain.CurrentDomain.BaseDirectory + "ABC\\"; FTPSClient client = ...