public static PhpArray GetExtensionFunctions(string extension) { if (extension == "zend") // since PHP 5.0 { PhpException.ArgumentValueNotSupported("extension", extension); // TODO: functions in the module zend (php functions in PhpNetCore ?) // ... } ApplicationContext app_context = ScriptContext.CurrentContext.ApplicationContext; PhpLibraryDescriptor desc = app_context.GetExtensionImplementor(extension); if (desc == null) { return(null); } PhpArray result = new PhpArray(); foreach (KeyValuePair <string, DRoutineDesc> function in app_context.Functions) { if (function.Value.DeclaringType.DeclaringModule == desc.Module) { result.Add(function.Key); } } return(result); }
private void ExtensionOptionsToXml(XmlTextWriter writer) { foreach (DictionaryEntry entry in Extensions) { PhpLibraryDescriptor descriptor = (PhpLibraryDescriptor)entry.Key; Hashtable options = (Hashtable)entry.Value; if (options.Count > 0) { // TODO: writer.WriteStartElement("x" /*descriptor.Name*/); foreach (DictionaryEntry opt_entry in options) { writer.WriteStartElement("set"); writer.WriteAttributeString("name", (string)opt_entry.Key); writer.WriteAttributeString("value", (string)opt_entry.Value); writer.WriteEndElement(); } writer.WriteEndElement(); } } }
public void WriteAll(string fileName) { XmlTextWriter writer = new XmlTextWriter(fileName, Encoding.UTF8); writer.WriteStartDocument(); writer.Formatting = Formatting.Indented; writer.Indentation = 1; writer.IndentChar = '\t'; writer.WriteStartElement("configuration"); writer.WriteStartElement(PHP.Core.Configuration.SectionName); // write libraries: if (Extensions.Count > 0) { writer.WriteStartElement("classLibrary"); foreach (DictionaryEntry entry in Extensions) { PhpLibraryDescriptor descriptor = (PhpLibraryDescriptor)entry.Key; writer.WriteStartElement("add"); writer.WriteAttributeString("assembly", descriptor.RealAssembly.FullName); // TODO: writer.WriteAttributeString("section", descriptor.Name); writer.WriteEndElement(); } writer.WriteEndElement(); } // writes Core options and removes them from hashtable: PhpIni.CoreOptionsToXml(writer, Options, phpNames); // writes BCL options and removes them from hashtable: writer.WriteStartElement("bcl"); LibraryConfiguration.LegacyOptionsToXml(writer, Options, phpNames); writer.WriteEndElement(); // distributes remaining options to extensions buckets: DistributeExtensionOptions(); // write extension options: ExtensionOptionsToXml(writer); writer.WriteEndElement(); writer.WriteEndDocument(); writer.Close(); if (Options.Count > 0) { string[] opt_names = new string[Options.Count]; Options.Keys.CopyTo(opt_names, 0); Array.Sort(opt_names); Console.Error.WriteLine("Following options has been skipped. They are either not supported or the declaring extension is not loaded by the .ini file."); foreach (string option in opt_names) { Console.Error.WriteLine(option); } } }
public void ProcessOption(object key, string value) { string option = key.ToString(); switch (option) { case "extension": { PhpLibraryDescriptor descriptor = LoadExtension(value); Extensions.Add(descriptor, new Hashtable()); break; } default: Options[option] = value; break; } }
private void DistributeExtensionOptions() { string[] opt_names = new string[Options.Count]; Options.Keys.CopyTo(opt_names, 0); foreach (string option in opt_names) { foreach (DictionaryEntry ext_entry in Extensions) { PhpLibraryDescriptor descriptor = (PhpLibraryDescriptor)ext_entry.Key; Hashtable ext_options = (Hashtable)ext_entry.Value; string ext_name = Path.ChangeExtension(descriptor.RealAssembly.GetName().Name, null); if (Externals.IniOptionExists(ext_name, option)) { ext_options.Add(option, Options[option]); Options.Remove(option); } } } }