Class that abstracts library configuration - in CLR it is wrapper over XmlAttributeCollection.
        /// <summary>
        /// Called by the Core after the library is loaded.
        /// </summary>
        protected override void Loaded(PhpLibraryAttribute assemblyAttribute, LibraryConfigStore configStore)
        {
            base.Loaded(assemblyAttribute, configStore);
            singleton = this;

            PDOMySQLConfiguration.RegisterLegacyOptions();

            PDOLibraryDescriptor.RegisterProvider(new MySQLPDODriver());

            string fullname = typeof(PDO).Name;
            var tPDO = ApplicationContext.Default.GetType(new QualifiedName(new Name(typeof(PDO).FullName)), ref fullname);
            Core.Reflection.PhpMemberAttributes att = Core.Reflection.PhpMemberAttributes.Public | Core.Reflection.PhpMemberAttributes.Static;
            ApplicationContext.Default.AddConstantToType(tPDO.TypeDesc, att, "MYSQL_ATTR_USE_BUFFERED_QUERY", MySQLPDODriver.MYSQL_ATTR_USE_BUFFERED_QUERY);
            ApplicationContext.Default.AddConstantToType(tPDO.TypeDesc, att, "MYSQL_ATTR_INIT_COMMAND", MySQLPDODriver.MYSQL_ATTR_INIT_COMMAND);
            ApplicationContext.Default.AddConstantToType(tPDO.TypeDesc, att, "MYSQL_ATTR_READ_DEFAULT_FILE", MySQLPDODriver.MYSQL_ATTR_READ_DEFAULT_FILE);
            ApplicationContext.Default.AddConstantToType(tPDO.TypeDesc, att, "MYSQL_ATTR_READ_DEFAULT_GROUP", MySQLPDODriver.MYSQL_ATTR_READ_DEFAULT_GROUP);
            ApplicationContext.Default.AddConstantToType(tPDO.TypeDesc, att, "MYSQL_ATTR_MAX_BUFFER_SIZE", MySQLPDODriver.MYSQL_ATTR_MAX_BUFFER_SIZE);
            ApplicationContext.Default.AddConstantToType(tPDO.TypeDesc, att, "MYSQL_ATTR_DIRECT_QUERY", MySQLPDODriver.MYSQL_ATTR_DIRECT_QUERY);
            ApplicationContext.Default.AddConstantToType(tPDO.TypeDesc, att, "MYSQL_ATTR_FOUND_ROWS", MySQLPDODriver.MYSQL_ATTR_FOUND_ROWS);
            ApplicationContext.Default.AddConstantToType(tPDO.TypeDesc, att, "MYSQL_ATTR_IGNORE_SPACE", MySQLPDODriver.MYSQL_ATTR_IGNORE_SPACE);
            ApplicationContext.Default.AddConstantToType(tPDO.TypeDesc, att, "MYSQL_ATTR_COMPRESS", MySQLPDODriver.MYSQL_ATTR_COMPRESS);
            ApplicationContext.Default.AddConstantToType(tPDO.TypeDesc, att, "MYSQL_ATTR_SSL_CA", MySQLPDODriver.MYSQL_ATTR_SSL_CA);
            ApplicationContext.Default.AddConstantToType(tPDO.TypeDesc, att, "MYSQL_ATTR_SSL_CAPATH", MySQLPDODriver.MYSQL_ATTR_SSL_CAPATH);
            ApplicationContext.Default.AddConstantToType(tPDO.TypeDesc, att, "MYSQL_ATTR_SSL_CERT", MySQLPDODriver.MYSQL_ATTR_SSL_CERT);
            ApplicationContext.Default.AddConstantToType(tPDO.TypeDesc, att, "MYSQL_ATTR_CIPHER", MySQLPDODriver.MYSQL_ATTR_CIPHER);
            ApplicationContext.Default.AddConstantToType(tPDO.TypeDesc, att, "MYSQL_ATTR_KEY", MySQLPDODriver.MYSQL_ATTR_KEY);
        }
Beispiel #2
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 #3
0
        ///// <summary>
        ///// Gets a list of implemented extensions.
        ///// </summary>
        //public override string[] ImplementedExtensions
        //{
        //    get { return new string[] { ExtensionName }; }
        //}
        //internal const string ExtensionName = "zlib";

		/// <summary>
		/// Called by the Core after the library is loaded.
		/// </summary>
		protected override void Loaded(PhpLibraryAttribute assemblyAttribute, LibraryConfigStore configStore)
		{
			base.Loaded(assemblyAttribute, configStore);
			singleton = this;

            IconvConfiguration.RegisterLegacyOptions();
		}
        /// <summary>
        /// Called by the Core after the library is loaded.
        /// </summary>
        protected override void Loaded(PhpLibraryAttribute assemblyAttribute, LibraryConfigStore configStore)
        {
            base.Loaded(assemblyAttribute, configStore);
            singleton = this;
            ZipConfiguration.RegisterLegacyOptions();

            StreamWrapper.RegisterSystemWrapper(new ZipStreamWrapper());
        }
Beispiel #5
0
		/// <summary>
		/// Called by the Core after the library is loaded.
		/// </summary>
		protected override void Loaded(PhpLibraryAttribute assemblyAttribute, LibraryConfigStore configStore)
		{
			base.Loaded(assemblyAttribute, configStore);
			singleton = this;

            PhpFilter.AddSystemFilter(new ZlibFilterFactory());

            StreamWrapper.SystemStreamWrappers.Add(ZlibStreamWrapper.scheme, new ZlibStreamWrapper());

			ZlibConfiguration.RegisterLegacyOptions();
		}
        /// <summary>
        /// Called by the Core after the library is loaded.
        /// </summary>
        protected override void Loaded(PhpLibraryAttribute assemblyAttribute, LibraryConfigStore configStore)
        {
            base.Loaded(assemblyAttribute, configStore);
            singleton = this;

            PDOSQLiteConfiguration.RegisterLegacyOptions();

            PDOLibraryDescriptor.RegisterProvider(new SQLitePDODriver());

            var tPDO = Core.Reflection.DTypeDesc.Create(typeof(PDO));
            PhpMemberAttributes att = PhpMemberAttributes.Public | PhpMemberAttributes.Static;
            ApplicationContext.Default.AddMethodToType(tPDO, att, "sqliteCreateFunction", SQLitePDODriver.PDO_sqliteCreateFunction);
        }
        /// <summary>
        /// Called by the Core after the library is loaded.
        /// </summary>
        protected override void Loaded(PhpLibraryAttribute assemblyAttribute, LibraryConfigStore configStore)
        {
            base.Loaded(assemblyAttribute, configStore);
            singleton = this;

            PDOSQLiteConfiguration.RegisterLegacyOptions();

            PDOLibraryDescriptor.RegisterProvider(new SQLitePDODriver());

            string fullname = typeof(PDO).Name;
            DType tPDO = ApplicationContext.Default.GetType(new QualifiedName(new Name(typeof(PDO).FullName)), ref fullname);
            Core.Reflection.PhpMemberAttributes att = Core.Reflection.PhpMemberAttributes.Public | Core.Reflection.PhpMemberAttributes.Static;
            ApplicationContext.Default.AddMethodToType(tPDO.TypeDesc, att, "sqliteCreateFunction", SQLitePDODriver.PDO_sqliteCreateFunction);
        }
        /// <summary>
        /// Called by the Core after the library is loaded.
        /// </summary>
        protected override void Loaded(PhpLibraryAttribute assemblyAttribute, LibraryConfigStore configStore)
        {
            base.Loaded(assemblyAttribute, configStore);
            singleton = this;

            PDOMySQLConfiguration.RegisterLegacyOptions();

            PDOLibraryDescriptor.RegisterProvider(new MySQLPDODriver());

            //var pdoDType = DTypeDesc.Create(typeof(PDO));
            //Core.Reflection.PhpMemberAttributes att = Core.Reflection.PhpMemberAttributes.Public | Core.Reflection.PhpMemberAttributes.Static;
            ////ApplicationContext.Default.AddMethodToType(pdoDType, att, "sqliteCreateFunction", MySQLPDODriver.PDO_sqliteCreateFunction);
            ////ApplicationContext.Default.AddConstantToType(pdoDType, PhpMemberAttributes.Public | PhpMemberAttributes.Static, "MYSQL_ATTR_INIT_COMMAND", 1002);
            //ApplicationContext.Default.AddConstantToType(pdoDType, PhpMemberAttributes.Public | PhpMemberAttributes.Static, "MYSQL_ATTR_USE_BUFFERED_QUERY", 1000);
        }
Beispiel #9
0
        ///// <summary>
        ///// Gets a list of implemented extensions.
        ///// </summary>
        //public override string[] ImplementedExtensions
        //{
        //    get { return new string[] { ExtStandard, ExtCore,/* ExtCalendar,*/ ExtCType, ExtSession, ExtTokenizer, ExtDate, ExtPcre, ExtEreg, ExtJson, ExtHash, ExtSpl }; }
        //}

		/// <summary>
		/// Called by the Core after the library is loaded.
		/// </summary>
		protected override void Loaded(PhpLibraryAttribute assemblyAttribute, LibraryConfigStore config)
		{
			base.Loaded(assemblyAttribute, config);
			singleton = this;

#if !SILVERLIGHT
			LibraryConfiguration.RegisterLegacyOptions();

			// registers session handlers:
			SessionHandlers.RegisterHandler(PhpSessionHandler.Default);
			SessionHandlers.RegisterHandler(PhpUserSessionHandler.Default);

			// registers serializers:
			Serializers.RegisterSerializer(PhpSerializer.Default);
            //Serializers.RegisterSerializer(PhalangerSerializer.Default);
			Serializers.RegisterSerializer(new ContextualSerializer("dotnet", delegate(PHP.Core.Reflection.DTypeDesc caller/*ignored*/)
			{
				return new BinaryFormatter(
					null,
					new StreamingContext(StreamingContextStates.Persistence, new SerializationContext()));
			}));
#endif
		}
Beispiel #10
0
        /// <summary>
        /// Loads a library assembly given its name and configuration node.
        /// </summary>
        /// <param name="assemblyName">Long assembly name (see <see cref="Assembly.Load"/>) or a <B>null</B> reference.</param>
        /// <param name="assemblyUrl">Assembly file absolute URI or a <B>null</B> reference.</param>
        /// <param name="config">Configuration node describing the assembly to load (or a <B>null</B> reference).</param>
        /// <exception cref="ConfigurationErrorsException">An error occured while loading the library.</exception>
        public DAssembly /*!*/ Load(string assemblyName, Uri assemblyUrl, LibraryConfigStore config)
        {
            if (assemblyName == null && assemblyUrl == null)
            {
                throw new ArgumentNullException("assemblyName");
            }

            if (assemblyUrl != null && !assemblyUrl.IsAbsoluteUri)
            {
                throw new ArgumentException("Absolute URL expected", "assemblyUrl");
            }

            string target = null;

            try
            {
                if (assemblyName != null)
                {
                    // load assembly by full name:
                    target = assemblyName;

                    return(Load(LoadRealAssembly(target), config));
                }
                else
                {
                    // load by URI:
                    target = HttpUtility.UrlDecode(assemblyUrl.AbsoluteUri);

                    return(Load(LoadRealAssemblyFrom(target), config));
                }
            }
            catch (Exception e)
            {
                throw new ConfigurationErrorsException
                          (CoreResources.GetString("library_assembly_loading_failed", target) + " " + e.Message, e);
            }
        }
Beispiel #11
0
        ///// <summary>
        ///// Gets a list of implemented extensions.
        ///// </summary>
        //public override string[] ImplementedExtensions
        //{
        //    get { return new string[] { SimpleXmlExtensionName, DomExtensionName, XslExtensionName }; }
        //}

        //internal const string SimpleXmlExtensionName = "SimpleXML";
        //internal const string DomExtensionName = "dom";
        //internal const string XslExtensionName = "xsl";

		/// <summary>
		/// Called by the Core after the library is loaded.
		/// </summary>
		protected override void Loaded(PhpLibraryAttribute assemblyAttribute, LibraryConfigStore configStore)
		{
			base.Loaded(assemblyAttribute, configStore);
			singleton = this;
		}
Beispiel #12
0
        /// <summary>
        /// Called when library loading is finished and descriptor is initialized.
        /// </summary>
        /// <param name="assemblyAttribute">
        /// A metadata attribute defined on library assembly or a <B>null</B> reference.
        /// </param>
        /// <param name="configStore">
        /// A collection of XML attributes used in configuration file to add the assembly to the Class Library
        /// or a <B>null</B> reference.
        /// </param>
        /// <remarks>
        /// Library is load when configuration reader finds out a node defining the library.
        /// After library is loaded the reader continues with configuration reading and calls <see cref="ParseConfig"/>
        /// when it reaches the section belonging to the library.
        /// </remarks>
        internal protected virtual void Loaded(PhpLibraryAttribute assemblyAttribute, LibraryConfigStore configStore)
        {
            Debug.WriteLine("CONFIG", "Library loaded: idx={0}, assembly={1}", UniqueIndex, RealAssembly.FullName);

            this.assemblyAttribute = assemblyAttribute;
        }
Beispiel #13
0
		/// <summary>
		/// Called when library loading is finished and descriptor is initialized.
		/// </summary>
		/// <param name="assemblyAttribute">
		/// A metadata attribute defined on library assembly or a <B>null</B> reference.
		/// </param>
		/// <param name="configAttributes">
		/// A collection of XML attributes used in configuration file to add the assembly to the Class Library
		/// or a <B>null</B> reference.
		/// </param>
		/// <remarks>
		/// Library is load when configuration reader finds out a node defining the library.
		/// After library is loaded the reader continues with configuration reading and calls <see cref="ParseConfig"/>
		/// when it reaches the section belonging to the library.
		/// </remarks>
		internal protected virtual void Loaded(PhpLibraryAttribute assemblyAttribute, LibraryConfigStore configStore)
		{
			Debug.WriteLine("CONFIG", "Library loaded: idx={0}, assembly={1}", UniqueIndex, RealAssembly.FullName);
		}
Beispiel #14
0
		/// <summary>
		/// Called when library loading is finished and descriptor is initialized.
		/// </summary>
		/// <exception cref="InvalidOperationException">Extension already loaded.</exception>
        /// <exception cref="NotSupportedException">An attempt to load the extension in isolated mode, which is not supported anymore.</exception>
		internal protected override void Loaded(PhpLibraryAttribute/*!*/ assemblyAttribute,
			LibraryConfigStore configStore)
		{
			base.Loaded(assemblyAttribute, configStore);

			//this.assemblyAttribute = (ExtensionDescriptorAttribute)assemblyAttribute;
			this.extensionPath = Configuration.GetPathsNoLoad().ExtNatives;

            if (configStore != null && configStore.Attributes != null)
            {
                var attr = configStore.Attributes["isolated"];
                if (attr != null && attr.Value == "true")
                {
                    // this.isolated = true;
                    throw new NotSupportedException(CoreResources.isolated_extensions_unsupported);
                }
            }

			if (!ServerMode)
			{
				string file_name = FileName.ToLower();

				try
				{
                    //if (Isolated)
                    //{
                    //    isolatedExtensions.Add(file_name, this);
                    //}
                    //else
					{
						collocatedExtensions.Add(file_name, this);
                        collocatedExtensionsByName.Add(assemblyAttribute.Name, true);
					}
				}
				catch (ArgumentException)
				{
					throw new InvalidOperationException(
						CoreResources.GetString("extension_already_loaded", assemblyAttribute.Name, FileName));
				}
			}
		}