当前位置: 首页>>代码示例>>C#>>正文


C# AppDomain.GetData方法代码示例

本文整理汇总了C#中System.AppDomain.GetData方法的典型用法代码示例。如果您正苦于以下问题:C# AppDomain.GetData方法的具体用法?C# AppDomain.GetData怎么用?C# AppDomain.GetData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.AppDomain的用法示例。


在下文中一共展示了AppDomain.GetData方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InitFromDomain

 /// <summary>
 /// Inits from domain.
 /// </summary>
 /// <param name="domain">The domain.</param>
 /// <returns></returns>
 public static BootstrapperParameters InitFromDomain(AppDomain domain)
 {
     return new BootstrapperParameters()
                {
                    BootstrapperFile = (string)domain.GetData(bootstrapperDataKey),
                    ConfigurationFile = (string)domain.GetData(bootstrapperConfigurationDataKey)
                };
 }
开发者ID:ayezutov,项目名称:NDistribUnit,代码行数:13,代码来源:BootstrapperParameters.cs

示例2: WriteUnhandledExceptionToEventLog

        internal static void WriteUnhandledExceptionToEventLog(AppDomain appDomain, Exception exception) {
            if (appDomain == null || exception == null) {
                return;
            }

            ProcessImpersonationContext imperContext = null;
            try {
                imperContext = new ProcessImpersonationContext();
                String appId = appDomain.GetData(".appId") as String;
                if (appId == null) {
                    appId = appDomain.FriendlyName;
                }
                string pid = SafeNativeMethods.GetCurrentProcessId().ToString(CultureInfo.InstalledUICulture);
                string description = SR.Resources.GetString(SR.Unhandled_Exception, CultureInfo.InstalledUICulture);
                Misc.ReportUnhandledException(exception, new string[5] {description, APPLICATION_ID, appId, PROCESS_ID, pid});
            }
            catch {
                // ignore exceptions so that WriteErrorToEventLog never throws
            }
            finally {
                if (imperContext != null) {
                    imperContext.Undo();
                }
            }
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:25,代码来源:Misc.cs

示例3: OnAppDomainUnload

        private static void OnAppDomainUnload(AppDomain appDomain)
        {
            ILogger logger = appDomain.GetData(Constants.LoggerKey) as ILogger;

            if (logger == null)
            {
                return;
            }

            logger.Fatal(
                "AppDomain with Id: '{0}' and BaseDirectory: '{1}' has been unloaded. Any in memory data stores have been lost. {2}",
                appDomain.Id,
                appDomain.BaseDirectory,
                HttpRuntimeShutdownMessageResolver.ResolveShutdownMessage());

            // NLog writes its logs asynchronously, which means that if we don't wait, chances are the log will not be written 
            // before the appdomain is actually shut down, so we sleep for 100ms and hopefully that is enough for NLog to do its thing
            Thread.Sleep(100);
        }
开发者ID:GitObjects,项目名称:Glimpse,代码行数:19,代码来源:HttpModule.cs

示例4: AppDomainOwner

 public static IContract AppDomainOwner(AppDomain domain)
 {
     if (domain == null)
         throw new ArgumentNullException("domain");
     System.Diagnostics.Contracts.Contract.EndContractBlock();
     return (IContract)domain.GetData(s_appDomainOwner);
 }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:7,代码来源:ContractHandle.cs

示例5: ContractOwnsAppDomain

 public static bool ContractOwnsAppDomain(IContract contract, AppDomain domain)
 {
     if (domain == null)
         throw new ArgumentNullException("domain");
     if (contract == null)
         throw new ArgumentNullException("contract");
     System.Diagnostics.Contracts.Contract.EndContractBlock();
     return domain.GetData(s_appDomainOwner) == contract;
 }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:9,代码来源:ContractHandle.cs

示例6: WriteUnhandledExceptionToEventLog

 internal static void WriteUnhandledExceptionToEventLog(AppDomain appDomain, Exception exception)
 {
     if ((appDomain != null) && (exception != null))
     {
         ProcessImpersonationContext context = null;
         try
         {
             context = new ProcessImpersonationContext();
             string data = appDomain.GetData(".appId") as string;
             if (data == null)
             {
                 data = appDomain.FriendlyName;
             }
             string str2 = System.Web.SafeNativeMethods.GetCurrentProcessId().ToString(CultureInfo.InstalledUICulture);
             string str3 = System.Web.SR.Resources.GetString("Unhandled_Exception", CultureInfo.InstalledUICulture);
             ReportUnhandledException(exception, new string[] { str3, "\r\n\r\nApplication ID: ", data, "\r\n\r\nProcess ID: ", str2 });
         }
         catch
         {
         }
         finally
         {
             if (context != null)
             {
                 context.Undo();
             }
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:29,代码来源:Misc.cs

示例7: Main

        public static int Main(string[] args)
        {
            AppDomainSetup setup = new AppDomainSetup();
            setup.ApplicationBase = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            _serverAppDomain = AppDomain.CreateDomain("Server", null, setup);
            _serverAppDomain.Load(typeof(ZyanConnection).Assembly.GetName());

            CrossAppDomainDelegate serverWork = new CrossAppDomainDelegate(() =>
            {
                var server = EventServer.Instance;
                if (server != null)
                {
                    Console.WriteLine("Event server started.");
                }
            });
            _serverAppDomain.DoCallBack(serverWork);

            // Test IPC Binary
            int ipcBinaryTestResult = IpcBinaryTest.RunTest();
            Console.WriteLine("Passed: {0}", ipcBinaryTestResult == 0);

            // Test TCP Binary
            int tcpBinaryTestResult = TcpBinaryTest.RunTest();
            Console.WriteLine("Passed: {0}", tcpBinaryTestResult == 0);

            // Test TCP Custom
            int tcpCustomTestResult = TcpCustomTest.RunTest();
            Console.WriteLine("Passed: {0}", tcpCustomTestResult == 0);

            // Test TCP Duplex
            int tcpDuplexTestResult = TcpDuplexTest.RunTest();
            Console.WriteLine("Passed: {0}", tcpDuplexTestResult == 0);

            // Test HTTP Custom
            int httpCustomTestResult = HttpCustomTest.RunTest();
            Console.WriteLine("Passed: {0}", httpCustomTestResult == 0);

            // Test NULL Channel
            const string nullChannelResultSlot = "NullChannelResult";
            _serverAppDomain.DoCallBack(new CrossAppDomainDelegate(() =>
            {
                int result = NullChannelTest.RunTest();
                AppDomain.CurrentDomain.SetData(nullChannelResultSlot, result);
            }));
            var nullChannelTestResult = Convert.ToInt32(_serverAppDomain.GetData(nullChannelResultSlot));
            Console.WriteLine("Passed: {0}", nullChannelTestResult == 0);

            // Stop the event server
            EventServerLocator locator = _serverAppDomain.CreateInstanceAndUnwrap(Assembly.GetExecutingAssembly().FullName, "IntegrationTest_DistributedEvents.EventServerLocator") as EventServerLocator;
            locator.GetEventServer().Dispose();
            Console.WriteLine("Event server stopped.");

            if (!MonoCheck.IsRunningOnMono || MonoCheck.IsUnixOS)
            {
                // Mono/Windows bug:
                // AppDomain.Unload freezes in Mono under Windows if tests for
                // System.Runtime.Remoting.Channels.Tcp.TcpChannel were executed.
                AppDomain.Unload(_serverAppDomain);
                Console.WriteLine("Server AppDomain unloaded.");
            }

            if (ipcBinaryTestResult + tcpBinaryTestResult + tcpCustomTestResult + tcpDuplexTestResult + httpCustomTestResult + nullChannelTestResult == 0)
            {
                Console.WriteLine("All tests passed.");
                return 0;
            }

            return 1;
        }
开发者ID:yallie,项目名称:zyan,代码行数:70,代码来源:Program.cs

示例8: GetAppDomainAssociated

 public static ScriptEnvironmentSetup GetAppDomainAssociated(AppDomain domain) {
     Contract.RequiresNotNull(domain, "domain");
     return domain.GetData(AppDomainDataKey) as ScriptEnvironmentSetup;
 }
开发者ID:JamesTryand,项目名称:IronScheme,代码行数:4,代码来源:ScriptEnvironmentSetup.cs

示例9: IsWebApp

 private static bool IsWebApp(AppDomain appDomain)
 {
     var configFile = (string) appDomain.GetData("APP_CONFIG_FILE");
     if (string.IsNullOrEmpty(configFile)) return false;
     return (
                Path.GetFileNameWithoutExtension(configFile) ?? string.Empty
            ).Equals(
                "WEB",
                StringComparison.OrdinalIgnoreCase);
 }
开发者ID:jsreport,项目名称:net,代码行数:10,代码来源:EmbeddedReportingServer.cs

示例10: RunInAppDomain

        public static object RunInAppDomain(Delegate delg, AppDomain targetDomain, params object[] args) {
            var runner = new domainDomainRunner(delg, args, delg.GetHashCode());
            targetDomain.DoCallBack(runner.Invoke);

            return targetDomain.GetData("appDomainResult" + delg.GetHashCode());
        }
开发者ID:aries544,项目名称:eXpand,代码行数:6,代码来源:DomainRunner.cs

示例11: GetCreator

        internal static IPluginCreator GetCreator(AppDomain domain, ILoggerFactory logfactory)
        {
            if (domain == null)
            throw new ArgumentNullException("domain");

              if (logfactory == null)
            throw new ArgumentNullException("logfactory");

              IPluginCreator creator = domain.GetData(PLUGINCREATORKEY) as IPluginCreator;
              if (creator == null)
              {
            domain.SetData(LOGGERFACTORYKEY, new ProxyLoggerFactory(logfactory));
            domain.DoCallBack(() =>
            {
              Logger.Singleton.LoggerFactory = AppDomain.CurrentDomain.GetData(LOGGERFACTORYKEY) as ILoggerFactory;
              AppDomain.CurrentDomain.SetData(PLUGINCREATORKEY, new PluginCreator());
            });
            domain.SetData(LOGGERFACTORYKEY, null);
            creator = domain.GetData(PLUGINCREATORKEY) as IPluginCreator;
              }
              return creator;
        }
开发者ID:CodeFork,项目名称:PluginFramework-1,代码行数:22,代码来源:PluginCreator.cs


注:本文中的System.AppDomain.GetData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。