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


C# Core.ApplicationContext类代码示例

本文整理汇总了C#中PHP.Core.ApplicationContext的典型用法代码示例。如果您正苦于以下问题:C# ApplicationContext类的具体用法?C# ApplicationContext怎么用?C# ApplicationContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ApplicationContext类属于PHP.Core命名空间,在下文中一共展示了ApplicationContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InitWebRequest

		/// <summary>
		/// Initializes the script context for a web request.
		/// </summary>
		/// <param name="appContext">Application context.</param>
		/// <param name="context">HTTP context of the request.</param>
		/// <returns>A instance of <see cref="ScriptContext"/> to be used by the request.</returns>
		/// <exception cref="System.Configuration.ConfigurationErrorsException">
		/// Web configuration is invalid. The context is not initialized then.
		/// </exception>
		internal static ScriptContext/*!*/ InitWebRequest(ApplicationContext/*!*/ appContext, HttpContext/*!*/ context)
		{
			Debug.Assert(appContext != null && context != null);

			// reloads configuration of the current thread from ASP.NET caches or web.config files;
			// cached configuration is reused;
			Configuration.Reload(appContext, false);

			// takes a writable copy of a global configuration (may throw ConfigurationErrorsException):
			LocalConfiguration config = (LocalConfiguration)Configuration.DefaultLocal.DeepCopy();

            // following initialization statements shouldn't throw an exception:    // can throw on Integrated Pipeline, events must be attached within HttpApplication.Init()

			ScriptContext result = new ScriptContext(appContext, config, context.Response.Output, context.Response.OutputStream);

			result.IsOutputBuffered = config.OutputControl.OutputBuffering;
			result.ThrowExceptionOnError = true;
			result.WorkingDirectory = Path.GetDirectoryName(context.Request.PhysicalPath);
            if (config.OutputControl.ContentType != null) context.Response.ContentType = config.OutputControl.ContentType;
            if (config.OutputControl.CharSet != null) context.Response.Charset = config.OutputControl.CharSet;

			result.AutoGlobals.Initialize(config, context);

			ScriptContext.CurrentContext = result;

			Externals.BeginRequest();

			return result;
		}
开发者ID:hansdude,项目名称:Phalanger,代码行数:38,代码来源:ScriptContext.CLR.cs

示例2: ApplicationCompilerManager

		/// <summary>
		/// Creates an instance of the manager.
		/// </summary>
		internal ApplicationCompilerManager(ApplicationContext applicationContext, PhpAssemblyBuilder/*!*/ assemblyBuilder)
		{
			Debug.Assert(assemblyBuilder != null);
            Debug.Assert(applicationContext != null);

			this.successful = true;
			this.assemblyBuilder = assemblyBuilder;
            this.applicationContext = applicationContext;
		}
开发者ID:dw4dev,项目名称:Phalanger,代码行数:12,代码来源:Managers.CLR.cs

示例3: InclusionResolutionContext

        /*
        /// <summary>
        /// Severity of inclusion-related errors. This is determined by type of inclusion being made and is needed by subsequent functions to report errors.
        /// </summary>
        public PhpError ErrorSeverity { get { return errorSeverity; } }
        private PhpError errorSeverity;
        */

        public InclusionResolutionContext(ApplicationContext applicationContext, string scriptDirectory, string workingDirectory, string searchPaths)
        {
            Debug.Assert(applicationContext != null && scriptDirectory != null && workingDirectory != null && searchPaths != null);

            this.applicationContext = applicationContext;
            this.scriptDirectory = scriptDirectory;
            this.workingDirectory = workingDirectory;
            this.searchPaths = searchPaths;
        }
开发者ID:dw4dev,项目名称:Phalanger,代码行数:17,代码来源:Script.cs

示例4: CompilationContext

		/// <summary>
		/// Creates a compilation context.
		/// </summary>
        /// <param name="applicationContext">Application context.</param>
		/// <param name="manager">Manager.</param>
		/// <param name="config">Configuration.</param>
		/// <param name="errorSink">Error sink.</param>
		/// <param name="workingDirectory">Working directory.</param>
        internal CompilationContext(ApplicationContext/*!*/ applicationContext, ICompilerManager manager, CompilerConfiguration/*!*/ config, ErrorSink/*!*/ errorSink,
			string/*!*/ workingDirectory)
		{
            Debug.Assert(applicationContext != null);
			Debug.Assert(config != null && workingDirectory != null);

            this.applicationContext = applicationContext;
			this.manager = manager;
			this.config = config;
			this.errors = errorSink;
			this.workingDirectory = workingDirectory;
		}
开发者ID:dw4dev,项目名称:Phalanger,代码行数:20,代码来源:Managers.cs

示例5: LoadFromFile

		/// <summary>
		/// Loads compiler configuration values from a specified .config file into a given record.
		/// </summary>
		/// <param name="appContext">Application context where to load libraries.</param>
		/// <param name="path">A full path to the .config file.</param>
		/// <returns>The new configuration record.</returns>
		/// <exception cref="ConfigurationErrorsException">An error in configuration.</exception>
        public void LoadFromFile(ApplicationContext/*!*/ appContext, FullPath path)
		{
			if (appContext == null)
				throw new ArgumentNullException("appContext");

			path.EnsureNonEmpty("path");

			ConfigXmlDocument doc = new ConfigXmlDocument();

			try
			{
				doc.Load(path);
			}
			catch (XmlException e)
			{
				throw new ConfigurationErrorsException(e.Message);
			}

			XmlNode root = doc.DocumentElement;
            if (root.Name == "configuration")
            {
                ProcessNodes(appContext, root, addedLibraries);
            }
		}
开发者ID:kripper,项目名称:Phalanger,代码行数:31,代码来源:Configuration.CLR.cs

示例6: LoadLibraries

 /// <summary>
 /// Load class libraries collected while parsing configuration files.
 /// </summary>
 /// <param name="appContext"></param>
 internal void LoadLibraries(ApplicationContext/*!*/ appContext)
 {
     addedLibraries.LoadLibrariesNoLock(
             (_assemblyName, _assemblyUrl, _sectionName, /*!*/ _node) =>
             {
                 appContext.AssemblyLoader.Load(_assemblyName, _assemblyUrl, new LibraryConfigStore(_node));
                 return true;
             },
             null // ignore class library sections
             );
 }
开发者ID:kripper,项目名称:Phalanger,代码行数:15,代码来源:Configuration.CLR.cs

示例7: Load

		/// <summary>
		/// Loads configuration and returns configuration record.
		/// </summary>
		/// <exception cref="ConfigurationErrorsException">Configuration is invalid or incomplete.</exception>
		public static void Load(ApplicationContext/*!*/ appContext)
		{
			if (current == null)
			{
				Debug.Assert(!isBeingLoadedToCurrentThread, "Configuration loader triggered next configuration load");
				isBeingLoadedToCurrentThread = true;

				try
				{
					PhpConfigurationContext context = ConfigurationSectionHandler.GetConfig(appContext, SectionName);

					if (context != null)
					{
						current = new Configuration(context.Global, context.Local);
					}
					else
					{
						// no configuration loaded from .config files:
						current = new Configuration(new GlobalConfiguration(), new LocalConfiguration());
					}
				}
				finally
				{
					isBeingLoadedToCurrentThread = false;
				}
			}
		}
开发者ID:kripper,项目名称:Phalanger,代码行数:31,代码来源:Configuration.CLR.cs

示例8: PhpConfigurationContext

		/// <summary>
		/// Makes a copy (child) of this instance (parent) deeply copying the confgiuration fields.
		/// </summary>
		internal PhpConfigurationContext(ApplicationContext/*!*/ applicationContext, string virtualPath, 
			PhpConfigurationContext parent)
		{
			Debug.Assert(applicationContext != null);
			this.virtualPath = virtualPath;
			this.applicationContext = applicationContext;

			// section tables are shared:
			this.sections = parent.sections;
			this.sealedSections = parent.sealedSections;
            this.librariesList = parent.librariesList;

			// configuration records are copied:
			this.local = (LocalConfiguration)parent.local.DeepCopy();
			this.global = (GlobalConfiguration)parent.global.DeepCopy();
		}
开发者ID:kripper,项目名称:Phalanger,代码行数:19,代码来源:Configuration.CLR.cs

示例9: MultiScriptAssemblyBuilder

		/// <summary>
		/// Creates an instance of of multi-script assembly builder.
		/// </summary>
		/// <param name="applicationContext">Application context.</param>
		/// <param name="assemblyName">Name of the assembly.</param>
		/// <param name="directory">Directory where assembly will be stored.</param>
		/// <param name="fileName">Name of the assembly file including an extension.</param>
        /// <param name="kind">Assembly file kind.</param>
		/// <param name="debug">Whether to include debug information.</param>
        /// <param name="force32bit">Whether to force 32bit execution of generated assembly.</param>
		/// <param name="entryPoint">Entry point.</param>
		/// <param name="icon">Icon.</param>
        /// <param name="resources">Resources to embed</param>
        public MultiScriptAssemblyBuilder(ApplicationContext/*!*/ applicationContext, AssemblyName assemblyName,
            string directory, string fileName, AssemblyKinds kind, ICollection<ResourceFileReference> resources,
                        bool debug, bool force32bit, Win32IconResource icon, PhpSourceFile entryPoint)
            : base(new MultiScriptAssembly(applicationContext), assemblyName, directory, fileName, kind, resources, debug, force32bit, false, icon)
        {
            this.entryPoint = entryPoint;
        }
开发者ID:hansdude,项目名称:Phalanger,代码行数:20,代码来源:AssemblyBuilders.CLR.cs

示例10: WebServerCompilerManager

		/// <summary>
		/// Creates a new instance of the manager. 
		/// Manager can be instantiated either in dedicated domain or in web AppDomain.
		/// </summary>
		/// <param name="appContext">Application context.</param>
		public WebServerCompilerManager(ApplicationContext/*!*/ appContext)
		{
			Debug.Assert(appContext != null);

            bool isWebApp = HttpContext.Current != null;    // whether we are running web app or an executable app

            this.outDir = isWebApp ? HttpRuntime.CodegenDir : Path.GetTempPath();
			this.events = new Dictionary<PhpSourceFile, ManualResetEvent>();
			this.applicationContext = appContext;

            // On Windows it's case-insensitive, because same file can be accessed with various cases
            cache = new Dictionary<string, CacheEntry>(100, FullPath.StringComparer);

            // install file system watcher to invalidate cache of files that have been modified:
            if (isWebApp &&
                Configuration.Application.Compiler.WatchSourceChanges &&
                !Configuration.Application.Compiler.OnlyPrecompiledCode)
            {
                watcher = new FileSystemWatcher()
                {
                    // TODO: multiple paths (multiple watchers?):
                    Path = Configuration.Application.Compiler.SourceRoot.ToString(),
                    NotifyFilter = NotifyFilters.FileName | NotifyFilters.LastWrite,
                    IncludeSubdirectories = true,
                    EnableRaisingEvents = false,
                };

                watcher.Changed += OnFileChanged;
                watcher.Renamed += OnFileRenamed;
                watcher.Deleted += OnFileChanged;
            }
            else
            {
                watcher = null;
            }

            // look for "App_Code.compiled" file
            if (isWebApp)
                LoadAppCode(Path.Combine(HttpRuntime.CodegenDir, "App_Code.compiled"));
		}
开发者ID:hansdude,项目名称:Phalanger,代码行数:45,代码来源:WebServerManagers.CLR.cs

示例11: Load

		/// <summary>
		/// Loads configuration and returns configuration record.
		/// </summary>
		/// <exception cref="ConfigurationErrorsException">Configuration is invalid or incomplete.</exception>
		public static void Load(ApplicationContext/*!*/ appContext)
		{
			if (current == null)
			{
				// no configuration loaded from .config files:
				current = new Configuration(new GlobalConfiguration(), new LocalConfiguration());
			}
		}
开发者ID:dw4dev,项目名称:Phalanger,代码行数:12,代码来源:Configuration.CoreCLR.cs

示例12: Initialize

		/// <summary>
		/// Creates and initializes request and script contexts associated with the current thread.
		/// </summary>
		/// <param name="appContext">Application context.</param>
		/// <param name="context">Current HTTP context.</param>
		/// <returns>The initialized request context.</returns>
		/// <remarks>
		/// <para>
		/// Request context provides PHP with the web server environment.
		/// It should be initialized before any PHP code is invoked within web server and finalized (disposed)
		/// at the end of the request. This method can be called for multiple times, however it creates and 
		/// initializes a new request context only once per HTTP request.
		/// </para>
		/// <para>
		/// The following steps take place during the initialization (in this order):
		/// <list type="number">
		///   <term>Configuration is loaded (if not loaded yet).</term>
		///   <term>A new instance of <see cref="RequestContext"/> is created and bound to the current thread.</term>
		///   <term>A new instance of <see cref="ScriptContext"/> is created and initialized.</term>
		///   <term>Event <see cref="RequestBegin"/> is fired.</term>
		///   <term>Session is started if session auto-start confgiuration option is switched on.</term>
		/// </list>
		/// </para>
		/// <para>
		/// The request context can be accessed via the returned instance or via <see cref="CurrentContext"/>
		/// thread static field anytime between the initialization and disposal.
		/// </para>
		/// </remarks>
		public static RequestContext/*!*/ Initialize(ApplicationContext/*!*/ appContext, HttpContext/*!*/ context)
		{
			if (appContext == null)
				throw new ArgumentNullException("appContext");
			if (context == null)
				throw new ArgumentNullException("context");

			RequestContext req_context = currentContext;

			// already initialized within the current request:
			if (req_context != null && req_context.httpContext.Timestamp == context.Timestamp)
				return req_context;

			Debug.WriteLine("REQUEST", "-- started ----------------------");

			req_context = new RequestContext(context);
			currentContext = req_context;

			req_context.Initialize(appContext);

			return req_context;
		}
开发者ID:dw4dev,项目名称:Phalanger,代码行数:50,代码来源:RequestContext.CLR.cs

示例13: Create

		public static PhpAssemblyBuilder/*!*/ Create(ApplicationContext/*!*/ applicationContext, AssemblyKinds kind,
			bool pure, FullPath outPath, FullPath docPath, string duckPath, string duckNs, PhpSourceFile entryPoint, Version version,
			StrongNameKeyPair key, Win32IconResource icon, ICollection<ResourceFileReference> resources, bool debug)
		{
			string out_dir = Path.GetDirectoryName(outPath);
			string out_file = Path.GetFileName(outPath);

			AssemblyName assembly_name = new AssemblyName();
			assembly_name.Name = Path.GetFileNameWithoutExtension(outPath);
			assembly_name.Version = version;
			assembly_name.KeyPair = key;

			if (pure)
			{
				// This is primarilly supported for non-pure mode, but it could be extended..
				if (duckPath != null)
					throw new NotSupportedException("Generation of duck type interfaces isn't supported for pure assemblies!");
				return new PureAssemblyBuilder(applicationContext, assembly_name, out_dir, out_file, kind, resources, debug, icon);
			}
			else
				return new MultiScriptAssemblyBuilder(applicationContext, assembly_name, out_dir, out_file, 
										duckPath, duckNs, kind, resources, debug, icon, entryPoint);
		}
开发者ID:jafin,项目名称:Phalanger,代码行数:23,代码来源:AssemblyBuilders.CLR.cs

示例14: ScriptLibraryDatabase

 /// <summary>
 /// Creates new ScriptLibraryDatabase object.
 /// </summary>
 /// <param name="context">Owning application context.</param>
 public ScriptLibraryDatabase(ApplicationContext context)
 {
     applicationContext = context;
 }
开发者ID:hansdude,项目名称:Phalanger,代码行数:8,代码来源:ApplicationContext.CLR.cs

示例15: PureAssemblyBuilder

		public PureAssemblyBuilder(ApplicationContext/*!*/ applicationContext, AssemblyName assemblyName,
            string directory, string fileName, AssemblyKinds kind, ICollection<ResourceFileReference> resources, bool debug, bool force32bit, Win32IconResource icon)
			: base(new PureAssembly(applicationContext), assemblyName, PureAssembly.ModuleName, directory,
					fileName, kind, resources, debug, force32bit, false, icon)
		{
		}
开发者ID:hansdude,项目名称:Phalanger,代码行数:6,代码来源:AssemblyBuilders.CLR.cs


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