Beispiel #1
0
        public DAssembly /*!*/ Load(Assembly /*!*/ realAssembly, LibraryConfigStore config)
        {
            Debug.Assert(realAssembly != null);

            DAssembly assembly;

            lock (this)
            {
                if (loadedAssemblies.TryGetValue(realAssembly, out assembly))
                {
                    return(assembly);
                }

                assembly = DAssembly.CreateNoLock(applicationContext, realAssembly, config);

                // load the members contained in the assembly to the global tables:
                applicationContext.LoadModuleEntries(assembly.ExportModule);

                // add the assembly into loaded assemblies list now, so if LoadModuleEntries throws, assembly is not skipped within the next request!
                loadedAssemblies.Add(realAssembly, assembly);
            }

            if (!reflectionOnly)
            {
                assembly.LoadCompileTimeReferencedAssemblies(this);
            }

            return(assembly);
        }
Beispiel #2
0
        /// <summary>
        /// Loads a library and adds a new section to the list of sections if available.
        /// </summary>
        internal static bool AddLibrary(string assemblyName, Uri assemblyUrl, string sectionName)
        {
            Debug.Assert(assemblyName != null ^ assemblyUrl != null);

            DAssembly assembly = ScriptContext.CurrentContext.ApplicationContext.
                                 AssemblyLoader.Load(assemblyName, assemblyUrl, new LibraryConfigStore());
            PhpLibraryAssembly lib_assembly = assembly as PhpLibraryAssembly;

            // not a PHP library or the library is loaded for reflection only:
            if (lib_assembly == null)
            {
                return(true);
            }

/*			PhpLibraryDescriptor descriptor = lib_assembly.Descriptor;
 *
 *                      // section name not stated or the descriptor is not available (reflected-only assembly):
 *                      if (sectionName == null || descriptor == null)
 *                              return true;
 *
 *                      if (descriptor.ConfigurationSectionName == sectionName)
 *                      {
 *                              // an assembly has already been assigned a section? => ok
 *                              if (sections.ContainsKey(sectionName)) return true;
 *
 *                              // TODO (TP): Consider whther this is correct behavior?
 *                              //       This occures under stress test, because ASP.NET calls
 *                              //       ConfigurationSectionHandler.Create even though we already loaded assemblies
 *                              Debug.WriteLine("CONFIG", "WARNING: Loading configuration for section '{0}'. " +
 *                                      "Library has been loaded, but the section is missing.", sectionName);
 *                      }
 *                      else if (descriptor.ConfigurationSectionName != null)
 *                      {
 *                              // an assembly has already been loaded with another section name => error:
 *                              throw new ConfigurationErrorsException(CoreResources.GetString("cannot_change_library_section",
 *                                      descriptor.RealAssembly.FullName, descriptor.ConfigurationSectionName), node);
 *                      }
 *
 *                      // checks whether the section has not been used yet:
 *                      LibrarySection existing_section;
 *                      if (sections.TryGetValue(sectionName, out existing_section))
 *                      {
 *                              Assembly conflicting_assembly = existing_section.Descriptor.RealAssembly;
 *                              throw new ConfigurationErrorsException(CoreResources.GetString("library_section_redeclared",
 *                                              sectionName, conflicting_assembly.FullName), node);
 *                      }
 *
 *                      // maps section name to the library descriptor:
 *                      descriptor.WriteConfigurationUp(sectionName);
 *                      sections.Add(sectionName, new LibrarySection(descriptor));
 */
            return(true);
        }
Beispiel #3
0
 /// <summary>
 /// Used by <see cref="UnknownModule"/>.
 /// </summary>
 protected DModule()
 {
     this.globalType = new GlobalType(this);
     this.assembly = UnknownAssembly.RuntimeAssembly;
 }
Beispiel #4
0
 /// <summary>
 /// Used by the loader.
 /// </summary>
 protected DModule(DAssembly/*!*/ assembly)
 {
     this.globalType = new GlobalType(this);
     this.assembly = assembly;
 }
Beispiel #5
0
 /// <summary>
 /// Used by the loader.
 /// </summary>
 protected PhpModule(DAssembly/*!*/ assembly)
     : base(assembly)
 {
     this._compilationUnit = null; // lazy init or unused
 }
Beispiel #6
0
		/// <summary>
		/// Called by the loader. The module can be loaded to <see cref="PureAssembly"/> or 
		/// <see cref="PhpLibraryAssembly"/>.
		/// </summary>
		internal PureModule(DAssembly/*!*/ assembly)
			: base(assembly)
		{
		}