⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 assemblygen.cs

📁 语音视频功能 里面实现了基本的QQ与语音对话
💻 CS
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Reflection;
using System.Security;
using System.Windows.Forms;
using System.Xml;
using System.Xml.XPath;
using System.CodeDom;
using System.CodeDom.Compiler;
namespace gowk.GXF
{
	/// <summary>
	/// AssemblyGen 的摘要说明。
	/// </summary>
	internal class AssemblyGen
	{
		public AssemblyGen()
		{
		}
		public Assembly CreateAssembly(Script script)
		{
			//create the language specific code compiler
			ICodeCompiler compiler = CreateCompiler(script);

			//add compiler parameters
			CompilerParameters compilerParams = new CompilerParameters();
			compilerParams.CompilerOptions = "/target:library /optimize";
			compilerParams.GenerateExecutable = false;
			compilerParams.GenerateInMemory = false;			
			compilerParams.IncludeDebugInformation = true;
			compilerParams.ReferencedAssemblies.Add("mscorlib.dll");
			compilerParams.ReferencedAssemblies.Add("System.dll");
			compilerParams.ReferencedAssemblies.Add("System.Windows.Forms.dll");	
			compilerParams.ReferencedAssemblies.Add("System.Xml.dll");	
			compilerParams.ReferencedAssemblies.Add("System.Data.dll");	
			foreach(string reference in script.References)
			{
				compilerParams.ReferencedAssemblies.Add(reference);
			}
			CompilerResults results = compiler.CompileAssemblyFromSource(compilerParams, script.SourceCode);
			if(results.Errors.Count>0)
			{
				string reason="";
				foreach(System.CodeDom.Compiler.CompilerError er in results.Errors)
				{
					reason+="ERROR:\n";
					reason+=er.ErrorText+"\n";
					reason+="@"+"line:"+er.Line.ToString()+",column:"+er.Column.ToString();
					reason+="\n";
				}
				throw new System.Exception(reason);return null;
			}
			return results.CompiledAssembly;
		}
		private ICodeCompiler CreateCompiler(Script script)
		{
			return new Microsoft.CSharp.CSharpCodeProvider().CreateCompiler();
		}
	}
	internal class Script
	{
		public string Language;
		public string SourceCode;
		public ArrayList References=new ArrayList();
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -