예제 #1
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);
        }
예제 #2
0
		/// <summary>
		/// Called by the loader thru <see cref="PhpLibraryAssembly"/>.
		/// </summary>
		internal PhpLibraryModule(PhpLibraryAssembly/*!*/ assembly)
			: base(assembly)
		{
			this.dynamicWrapper = null; // lazy load
		}