Пример #1
0
        /// <summary>
        /// Called by the loader.
        /// </summary>
        internal static DAssembly /*!*/ CreateNoLock(ApplicationContext /*!*/ applicationContext,
                                                     Assembly /*!*/ realAssembly, LibraryConfigStore config)
        {
            // gets a name of the descriptor:
            DAssemblyAttribute attr = DAssemblyAttribute.Reflect(realAssembly);

            if (attr != null)
            {
                PhpLibraryAttribute      lib;
                PurePhpAssemblyAttribute pure;

                if ((lib = attr as PhpLibraryAttribute) != null)
                {
                    // PHP library or extension:
                    return(new PhpLibraryAssembly(applicationContext, realAssembly, lib, config));
                }
                else if ((pure = attr as PurePhpAssemblyAttribute) != null)
                {
#if SILVERLIGHT
                    throw new NotSupportedException("Loading of pre-compiled pure assemblies is not supported!");
#else
                    // compiled pure PHP assembly:
                    return(new PureAssembly(applicationContext, realAssembly, pure, config));
#endif
                }
                else
                {
#if SILVERLIGHT
                    throw new NotSupportedException("Loading of pre-compiled script assemblies is not supported!");
#else
                    // compiled PHP script assembly:
                    return(ScriptAssembly.Create(applicationContext, realAssembly, (ScriptAssemblyAttribute)attr));
#endif
                }
            }
            else
            {
                // plugin assembly:
                var plugs = PluginAssemblyAttribute.Reflect(realAssembly);
                if (plugs != null)
                {
                    return(new PluginAssembly(applicationContext, realAssembly, config, plugs));
                }

                // CLR assembly:
                return(new ClrAssembly(applicationContext, realAssembly, config));
            }
        }
Пример #2
0
        public override void Reflect(bool full,
                                     Dictionary <string, DTypeDesc> /*!*/ types,
                                     Dictionary <string, DRoutineDesc> /*!*/ functions,
                                     DualDictionary <string, DConstantDesc> /*!*/ constants)
        {
            // PluginAssembly does not contain any declarations

            // Let the plugin to modify ApplicationContext
            var attrs = PluginAssemblyAttribute.Reflect(PluginAssembly.RealAssembly);

            if (attrs != null)
            {
                foreach (var plug in attrs)
                {
                    var method = plug.LoaderType.GetMethod(PluginAssembly.LoaderMethod, BindingFlags.Public | BindingFlags.Static, null, PluginAssembly.LoaderMethodParameters, null);
                    if (method != null)
                    {
                        method.Invoke(null, new object[] { PluginAssembly.ApplicationContext });
                    }
                }
            }
        }