`
zaf727hc
  • 浏览: 11867 次
最近访客 更多访客>>
社区版块
存档分类
最新评论

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咋想的,简单做成一个指针不就得了……
分享到:
评论

相关推荐

    AppDomain编程

    关于AppDomain编程的全面资料,适合中高级技术人员阅读

    AS3.0模块基础知识

    context.applicationDomain = new ApplicationDomain(ApplicationDomain.currentDomain); context.applicationDomain = ApplicationDomain.currentDomain; context.applicationDomain = new ApplicationDomain(); ...

    C# Winform 获取当前路径.txt

    System.AppDomain.CurrentDomain.BaseDirectory // 获取模块的完整路径。 System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName // 获取和设置当前目录(该进程从中启动的目录)的完全限定目录。 ...

    C#的path.GetFullPath 获取上级目录实现方法

    获取当前目录可以使用 代码如下: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

    将DLL嵌入到EXE大众

    AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);//添加代码 InitializeComponent(); JObject obj = new JObject(); } //添加代码 System.Reflection....

    TopshelfDemo.rar

    log4net.Config.XmlConfigurator.ConfigureAndWatch(new FileInfo(AppDomain.CurrentDomain.BaseDirectory + "log4net.config")); HostFactory.Run(x => { x.UseLog4Net(); x.Service(); x.SetDescription(...

    VB利用Socket和http和inet进行上传文件

    asp.net using System;... file.SaveAs(Path.Combine(AppDomain.CurrentDomain.BaseDirectory+@"ChatTemp\" , file.FileName)); } } public bool IsReusable { get { return true; } } }

    MVC+ICOAutoFac+EF+三层+VS2013

    MVC+ICOAutoFac+EF+三层+VS2013 ICOAutoFac+构造函数注入,单个类注入,一次所有类注入,接口注入 简单例子仅供学习,数据库DBscript.sql,... var assemblys = AppDomain.CurrentDomain.GetAssemblies().ToList();

    全局异常捕捉 c#WinForm异常处理

    这里建立了一个有关异常处理的对话框类,来实现异常的捕捉。通过使用ThreadException, App.CurrentDomain.UnhandledException捕捉程序里不可预知的异常,可以帮助开发者方便的找到发生异常的位置。

    OPC C#封装包 access和SQL数据源配制

    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....

    OPC C#封装包 access和SQL数据源配制 V1.0.0.8

    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...

    c# WinForm Excel考勤数据融合系统 Excel导入导出源代码

    源码概要描述 :2个Excel 作为主表,利用第三个Excel作为模板,生成新的...System.AppDomain.CurrentDomain.BaseDirectory.Replace(@"bin\Debug\", @"Template\excel模板.xlsx") 这句代码就是为了获得Excel模板所在路径

    使用ffmpeg.exe获取文件属性信息,视频音频时长

    pro.StartInfo.FileName = AppDomain.CurrentDomain.BaseDirectory + "ffmpeg.exe"; pro.StartInfo.Arguments = " -i " + fileName; pro.Start(); System.IO.StreamReader errorreader = pro.StandardError; ...

    OPC C#封装包 access和SQL数据源配制 V1.0.0.4

    inter.StartOPCSvr (System.AppDomain .CurrentDomain .BaseDirectory +"Test.exe"); //暂停当前服务 inter.Suspend (); //重新启动服务 inter.Resume (); //停止当前服务 inter.CloseOPCSvr(); //查看当前TAG...

    通过ftps操作文件

    , AppDomain.CurrentDomain.BaseDirectory + "Download\\" + filelist[i].Name.ToString()); } --上传文件方法体 string sourcePath = AppDomain.CurrentDomain.BaseDirectory + "ABC\\"; FTPSClient client = ...

Global site tag (gtag.js) - Google Analytics