Пример #1
0
 /// <summary>
 /// Creates an instance of of multi-script assembly builder.
 /// </summary>
 /// <param name="applicationContext">Application context.</param>
 /// <param name="assemblyName">Name of the assembly.</param>
 /// <param name="directory">Directory where assembly will be stored.</param>
 /// <param name="fileName">Name of the assembly file including an extension.</param>
 /// <param name="kind">Assembly file kind.</param>
 /// <param name="debug">Whether to include debug information.</param>
 /// <param name="force32bit">Whether to force 32bit execution of generated assembly.</param>
 /// <param name="entryPoint">Entry point.</param>
 /// <param name="icon">Icon.</param>
 /// <param name="resources">Resources to embed</param>
 public MultiScriptAssemblyBuilder(ApplicationContext /*!*/ applicationContext, AssemblyName assemblyName,
                                   string directory, string fileName, AssemblyKinds kind, ICollection <ResourceFileReference> resources,
                                   bool debug, bool force32bit, Win32IconResource icon, PhpSourceFile entryPoint)
     : base(new MultiScriptAssembly(applicationContext), assemblyName, directory, fileName, kind, resources, debug, force32bit, false, icon)
 {
     this.entryPoint = entryPoint;
 }
Пример #2
0
		/// <summary>
		/// Converts assembly kind to <see cref="PEFileKinds"/>.
		/// </summary>
		public static PEFileKinds ToPEFileKind(AssemblyKinds kind)
		{
			switch (kind)
			{
				case AssemblyKinds.ConsoleApplication: return PEFileKinds.ConsoleApplication;
				case AssemblyKinds.WindowApplication: return PEFileKinds.WindowApplication;
				default: return PEFileKinds.Dll;
			}
		}
Пример #3
0
        /// <summary>
        /// Converts assembly kind to <see cref="PEFileKinds"/>.
        /// </summary>
        public static PEFileKinds ToPEFileKind(AssemblyKinds kind)
        {
            switch (kind)
            {
            case AssemblyKinds.ConsoleApplication: return(PEFileKinds.ConsoleApplication);

            case AssemblyKinds.WindowApplication: return(PEFileKinds.WindowApplication);

            default: return(PEFileKinds.Dll);
            }
        }
Пример #4
0
        protected PhpAssemblyBuilder(PhpAssembly /*!*/ assembly, AssemblyName assemblyName, string moduleName,
                                     string directory, string fileName, AssemblyKinds kind, ICollection <ResourceFileReference> resources, bool debug,
                                     bool force32bit, bool saveOnlyAssembly, Win32IconResource icon)
            : base(assembly)
        {
            this.kind       = kind;
            this.debuggable = debug;
            this.Force32Bit = force32bit;
            this.fileName   = fileName;
            this.directory  = directory;
            this.icon       = icon;
            this.resources  = resources;

#if SILVERLIGHT
            AssemblyBuilder assembly_builder = AppDomain.CurrentDomain.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.Run);
            ModuleBuilder   module_builder   = (ModuleBuilder)assembly_builder.ManifestModule;         // SILVERLIGHT: hack? http://silverlight.org/forums/p/1444/3919.aspx#3919
#else
            AssemblyBuilder assembly_builder = AppDomain.CurrentDomain.DefineDynamicAssembly(assemblyName, saveOnlyAssembly ? AssemblyBuilderAccess.Save : AssemblyBuilderAccess.RunAndSave, directory);
            ModuleBuilder   module_builder   = assembly_builder.DefineDynamicModule(moduleName, fileName, debug);
#endif
            DefineGlobalType(module_builder);
            assembly.WriteUp(module_builder, Path.Combine(directory, fileName));             // TODO: Combine can be avoided (pass path instead of directory + fileName)
        }
Пример #5
0
		protected PhpAssemblyBuilder(PhpAssembly/*!*/ assembly, AssemblyName assemblyName, string moduleName,
            string directory, string fileName, AssemblyKinds kind, ICollection<ResourceFileReference> resources, bool debug,
            bool force32bit, bool saveOnlyAssembly, Win32IconResource icon)
			: base(assembly)
		{
			this.kind = kind;
			this.debuggable = debug;
            this.Force32Bit = force32bit;
			this.fileName = fileName;
			this.directory = directory;
			this.icon = icon;
            this.resources = resources;

#if SILVERLIGHT
			AssemblyBuilder assembly_builder = AppDomain.CurrentDomain.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.Run);
			ModuleBuilder module_builder = (ModuleBuilder)assembly_builder.ManifestModule; // SILVERLIGHT: hack? http://silverlight.org/forums/p/1444/3919.aspx#3919
#else

            AssemblyBuilder assembly_builder = AppDomain.CurrentDomain.DefineDynamicAssembly(assemblyName, saveOnlyAssembly ? AssemblyBuilderAccess.Save : AssemblyBuilderAccess.RunAndSave, directory);
			ModuleBuilder module_builder = assembly_builder.DefineDynamicModule(moduleName, fileName, debug);
#endif
			DefineGlobalType(module_builder);
			assembly.WriteUp(module_builder, Path.Combine(directory, fileName)); // TODO: Combine can be avoided (pass path instead of directory + fileName)
		}
Пример #6
0
		/// <summary>
		/// Creates an instance of of multi-script assembly builder.
		/// </summary>
		/// <param name="applicationContext">Application context.</param>
		/// <param name="assemblyName">Name of the assembly.</param>
		/// <param name="directory">Directory where assembly will be stored.</param>
		/// <param name="fileName">Name of the assembly file including an extension.</param>
        /// <param name="kind">Assembly file kind.</param>
		/// <param name="debug">Whether to include debug information.</param>
        /// <param name="force32bit">Whether to force 32bit execution of generated assembly.</param>
		/// <param name="entryPoint">Entry point.</param>
		/// <param name="icon">Icon.</param>
        /// <param name="resources">Resources to embed</param>
        public MultiScriptAssemblyBuilder(ApplicationContext/*!*/ applicationContext, AssemblyName assemblyName,
            string directory, string fileName, AssemblyKinds kind, ICollection<ResourceFileReference> resources,
                        bool debug, bool force32bit, Win32IconResource icon, PhpSourceFile entryPoint)
            : base(new MultiScriptAssembly(applicationContext), assemblyName, directory, fileName, kind, resources, debug, force32bit, false, icon)
        {
            this.entryPoint = entryPoint;
        }
Пример #7
0
 /// <summary>
 /// Creates an instance of of single-script assembly builder (without resources).
 /// </summary>
 /// <param name="applicationContext">Application context.</param>
 /// <param name="assemblyName">Name of the assembly.</param>
 /// <param name="directory">Directory where assembly will be stored.</param>
 /// <param name="fileName">Name of the assembly file including an extension.</param>
 /// <param name="kind">Assembly kind.</param>
 /// <param name="debug">Whether to include debug information.</param>
 /// <param name="force32bit">Whether to force 32bit execution of generated assembly.</param>
 /// <param name="saveOnlyAssembly">Whether to not load the assembly into memory.</param>
 /// <param name="icon">Icon resource or a <B>null</B> reference.</param>
 public SingleScriptAssemblyBuilder(ApplicationContext/*!*/ applicationContext, AssemblyName assemblyName, string directory, string fileName,
     AssemblyKinds kind, bool debug, bool force32bit, bool saveOnlyAssembly, Win32IconResource icon)
     : base(new SingleScriptAssembly(applicationContext), assemblyName, directory, fileName, kind, null, debug, force32bit, saveOnlyAssembly, icon)
 {
 }
Пример #8
0
		protected ScriptAssemblyBuilder(ScriptAssembly/*!*/ assembly, AssemblyName assemblyName, string directory,
            string fileName, AssemblyKinds kind, ICollection<ResourceFileReference> resources, bool debug,
            bool force32bit, bool saveOnlyAssembly, Win32IconResource icon)
			: base(assembly, assemblyName, ScriptAssembly.RealModuleName, directory, fileName, kind,resources, debug, force32bit, saveOnlyAssembly, icon)
		{

		}
Пример #9
0
		public PureAssemblyBuilder(ApplicationContext/*!*/ applicationContext, AssemblyName assemblyName,
            string directory, string fileName, AssemblyKinds kind, ICollection<ResourceFileReference> resources, bool debug, bool force32bit, Win32IconResource icon)
			: base(new PureAssembly(applicationContext), assemblyName, PureAssembly.ModuleName, directory,
					fileName, kind, resources, debug, force32bit, false, icon)
		{
		}
Пример #10
0
		public static PhpAssemblyBuilder/*!*/ Create(ApplicationContext/*!*/ applicationContext, AssemblyKinds kind,
			bool pure, FullPath outPath, FullPath docPath, PhpSourceFile entryPoint, Version version,
            StrongNameKeyPair key, Win32IconResource icon, ICollection<ResourceFileReference> resources, bool debug, bool force32bit)
		{
			string out_dir = Path.GetDirectoryName(outPath);
			string out_file = Path.GetFileName(outPath);

			AssemblyName assembly_name = new AssemblyName();
			assembly_name.Name = Path.GetFileNameWithoutExtension(outPath);
			assembly_name.Version = version;
			assembly_name.KeyPair = key;

            if (pure)
            {
                return new PureAssemblyBuilder(applicationContext, assembly_name, out_dir, out_file,
                    kind, resources, debug, force32bit, icon);
            }
            else
            {
                return new MultiScriptAssemblyBuilder(applicationContext, assembly_name, out_dir, out_file,
                    kind, resources, debug, force32bit, icon, entryPoint);
            }
		}
Пример #11
0
		/// <summary>
		/// Creates an instance of of single-script assembly builder.
		/// </summary>
		/// <param name="applicationContext">Application context.</param>
		/// <param name="assemblyName">Name of the assembly.</param>
		/// <param name="directory">Directory where assembly will be stored.</param>
		/// <param name="fileName">Name of the assembly file including an extension.</param>
		/// <param name="kind">Assembly kind.</param>
		/// <param name="debug">Whether to include debug information.</param>
        /// <param name="force32bit">Whether to force 32bit execution of generated assembly.</param>
        /// <param name="saveOnlyAssembly">Whether to not load the assembly into memory.</param>
        /// <param name="icon">Icon resource or a <B>null</B> reference.</param>
        /// <param name="resources">Resources to embed</param>
		public SingleScriptAssemblyBuilder(ApplicationContext/*!*/ applicationContext, AssemblyName assemblyName, string directory, string fileName,
            AssemblyKinds kind, ICollection<ResourceFileReference> resources, DebugMode debug, bool force32bit, bool saveOnlyAssembly, Win32IconResource icon)
            : base(new SingleScriptAssembly(applicationContext), assemblyName, directory, fileName, kind, resources, debug, force32bit, saveOnlyAssembly, icon)
		{
		}
Пример #12
0
 /// <summary>
 /// Creates an instance of of single-script assembly builder (without resources).
 /// </summary>
 /// <param name="applicationContext">Application context.</param>
 /// <param name="assemblyName">Name of the assembly.</param>
 /// <param name="directory">Directory where assembly will be stored.</param>
 /// <param name="fileName">Name of the assembly file including an extension.</param>
 /// <param name="kind">Assembly kind.</param>
 /// <param name="debug">Whether to include debug information.</param>
 /// <param name="force32bit">Whether to force 32bit execution of generated assembly.</param>
 /// <param name="saveOnlyAssembly">Whether to not load the assembly into memory.</param>
 /// <param name="icon">Icon resource or a <B>null</B> reference.</param>
 public SingleScriptAssemblyBuilder(ApplicationContext /*!*/ applicationContext, AssemblyName assemblyName, string directory, string fileName,
                                    AssemblyKinds kind, bool debug, bool force32bit, bool saveOnlyAssembly, Win32IconResource icon)
     : base(new SingleScriptAssembly(applicationContext), assemblyName, directory, fileName, kind, null, debug, force32bit, saveOnlyAssembly, icon)
 {
 }
Пример #13
0
 protected ScriptAssemblyBuilder(ScriptAssembly /*!*/ assembly, AssemblyName assemblyName, string directory,
                                 string fileName, AssemblyKinds kind, ICollection <ResourceFileReference> resources, bool debug,
                                 bool force32bit, bool saveOnlyAssembly, Win32IconResource icon)
     : base(assembly, assemblyName, ScriptAssembly.RealModuleName, directory, fileName, kind, resources, debug, force32bit, saveOnlyAssembly, icon)
 {
 }
Пример #14
0
 public PureAssemblyBuilder(ApplicationContext /*!*/ applicationContext, AssemblyName assemblyName,
                            string directory, string fileName, AssemblyKinds kind, ICollection <ResourceFileReference> resources, bool debug, bool force32bit, Win32IconResource icon)
     : base(new PureAssembly(applicationContext), assemblyName, PureAssembly.ModuleName, directory,
            fileName, kind, resources, debug, force32bit, false, icon)
 {
 }
Пример #15
0
        public static PhpAssemblyBuilder /*!*/ Create(ApplicationContext /*!*/ applicationContext, AssemblyKinds kind,
                                                      bool pure, FullPath outPath, FullPath docPath, PhpSourceFile entryPoint, Version version,
                                                      StrongNameKeyPair key, Win32IconResource icon, ICollection <ResourceFileReference> resources, bool debug, bool force32bit)
        {
            string out_dir  = Path.GetDirectoryName(outPath);
            string out_file = Path.GetFileName(outPath);

            AssemblyName assembly_name = new AssemblyName();

            assembly_name.Name    = Path.GetFileNameWithoutExtension(outPath);
            assembly_name.Version = version;
            assembly_name.KeyPair = key;

            if (pure)
            {
                return(new PureAssemblyBuilder(applicationContext, assembly_name, out_dir, out_file,
                                               kind, resources, debug, force32bit, icon));
            }
            else
            {
                return(new MultiScriptAssemblyBuilder(applicationContext, assembly_name, out_dir, out_file,
                                                      kind, resources, debug, force32bit, icon, entryPoint));
            }
        }
Пример #16
0
		public static PhpAssemblyBuilder/*!*/ Create(ApplicationContext/*!*/ applicationContext, AssemblyKinds kind,
			bool pure, FullPath outPath, FullPath docPath, string duckPath, string duckNs, PhpSourceFile entryPoint, Version version,
			StrongNameKeyPair key, Win32IconResource icon, ICollection<ResourceFileReference> resources, bool debug)
		{
			string out_dir = Path.GetDirectoryName(outPath);
			string out_file = Path.GetFileName(outPath);

			AssemblyName assembly_name = new AssemblyName();
			assembly_name.Name = Path.GetFileNameWithoutExtension(outPath);
			assembly_name.Version = version;
			assembly_name.KeyPair = key;

			if (pure)
			{
				// This is primarilly supported for non-pure mode, but it could be extended..
				if (duckPath != null)
					throw new NotSupportedException("Generation of duck type interfaces isn't supported for pure assemblies!");
				return new PureAssemblyBuilder(applicationContext, assembly_name, out_dir, out_file, kind, resources, debug, icon);
			}
			else
				return new MultiScriptAssemblyBuilder(applicationContext, assembly_name, out_dir, out_file, 
										duckPath, duckNs, kind, resources, debug, icon, entryPoint);
		}