Exemplo n.º 1
0
        /// <summary>
        /// Reflects the assembly and creates ScriptModules.
        /// </summary>
        private void ReflectAssemblyNoLock()
        {
            // TODO: this should be changed into ScriptAttribute resolution when all assemblies have this attribute correctly generated
            // (same as WebCompilerManager does that)
            this.modules = new Dictionary <PhpSourceFile, ScriptModule>();

            // go through all types in the assembly
            foreach (Type type in RealAssembly.GetTypes() /*GetExportedTypes()*/)
            {
                //bool isScript = false;

                ////check whether type implements IPhpScript interface
                //foreach (Type iface in type.GetInterfaces())
                //{
                //    if (iface == typeof(IPhpScript))
                //    {
                //        isScript = true;
                //        break;
                //    }
                //}

                //if (!isScript) continue;
                if (type.IsVisible && type.Name == ScriptModule.ScriptTypeName)
                {
                    //customary . is required
                    string subnamespace = type.Namespace + ".";

                    //get script's arbitrary path
                    string scriptPath = ScriptModule.GetPathFromSubnamespace(subnamespace).ToString();
                    if (libraryRoot != null)
                    {
                        scriptPath = System.IO.Path.Combine(libraryRoot, scriptPath);
                    }

                    modules.Add(new PhpSourceFile(Configuration.Application.Compiler.SourceRoot, new RelativePath(scriptPath)), new ScriptModule(scriptPath, type, this, subnamespace));
                }
            }
        }
Exemplo n.º 2
0
 public Entry(FullPath path, ScriptModule scriptModule, ScriptAssembly containingAssembly)
 {
     ScriptModule = scriptModule;
     ContainingAssembly = containingAssembly;
     Path = path;
 }
Exemplo n.º 3
0
		/// <summary>
		/// Adds a new script module. Used by builder.
		/// </summary>
		internal void AddScriptModule(PhpSourceFile/*!*/ sourceFile, ScriptModule/*!*/ module)
		{
			modules.Add(sourceFile, module);
		}
Exemplo n.º 4
0
		/// <summary>
		/// Used by the builder, written-up.
		/// </summary>
		internal SingleScriptAssembly(ApplicationContext/*!*/ applicationContext)
			: base(applicationContext)
		{
			this.module = null; // to be set by the builder
		}
Exemplo n.º 5
0
		/// <summary>
		/// Used by the loader.
		/// </summary>
        /// <param name="applicationContext">Current application context.</param>
        /// <param name="realAssembly">Underlying real assembly.</param>
        /// <param name="libraryRoot">Offset path for scripts.</param>
        internal SingleScriptAssembly(ApplicationContext/*!*/ applicationContext, Assembly/*!*/ realAssembly, string libraryRoot)
            : base(applicationContext, realAssembly)
        {
            var scriptType = this.GetScriptType();
            var subnamespace = string.IsNullOrEmpty(scriptType.Namespace) ? string.Empty : (scriptType.Namespace + ".");

            this.module = new ScriptModule(libraryRoot, scriptType, this, subnamespace);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Gets a full qualified name of a script type given a sub-namespace.
        /// </summary>
        /// <param name="sourceFile">Source file.</param>
        /// <returns>The qualified name.</returns>
        public string GetQualifiedScriptTypeName(PhpSourceFile /*!*/ sourceFile)
        {
            Debug.Assert(sourceFile != null);

            return(GetQualifiedScriptTypeName(ScriptModule.GetSubnamespace(sourceFile.RelativePath, true)));
        }
Exemplo n.º 7
0
 /// <summary>
 /// Adds a new script module. Used by builder.
 /// </summary>
 internal void AddScriptModule(PhpSourceFile /*!*/ sourceFile, ScriptModule /*!*/ module)
 {
     modules.Add(sourceFile, module);
 }
Exemplo n.º 8
0
 /// <summary>
 /// Used by the builder, written-up.
 /// </summary>
 internal SingleScriptAssembly(ApplicationContext /*!*/ applicationContext)
     : base(applicationContext)
 {
     this.module = null;             // to be set by the builder
 }