public Assembly GetAssembly()
        {
            if (File.Exists(mainscript + ".dll") && !SourceChanged)
                return Assembly.LoadFile(mainscript + ".dll");

            Console.WriteLine("Source changed, recompiling");

            Match match = GetMetaMatch();
            List<string> sources = GetSources(match);
            List<string> refs = GetReferences(match);
            string lang = GetLanguage(match);

            // add commonly used references
            if (!sources.Contains(program.FileName())) sources.Add(program.FileName());
            if (!refs.Contains("qt-dotnet")) refs.Add("qt-dotnet");
            if (!refs.Contains("kde-dotnet")) refs.Add("kde-dotnet");
            if (!refs.Contains("plasma-dll")) refs.Add("plasma-dll");

            // relative paths -> absolute paths
            QFileInfo info = new QFileInfo();
            for (int i = 0; i < sources.Count; i++) {
                info.SetFile(program.AbsoluteDir(), sources[i]);
                sources[i] = info.AbsoluteFilePath();
            }

            CodeDomProvider provider = GetCodeDomProvider(lang);
            CompilerParameters param = new CompilerParameters();
            param.GenerateExecutable = false;
            param.GenerateInMemory = false;
            param.OutputAssembly = mainscript + ".dll";
            param.ReferencedAssemblies.AddRange(refs.ToArray());
            param.CompilerOptions = String.Empty;
            CompilerResults result = provider.CompileAssemblyFromFile(param, sources.ToArray());
            bool error = false;
            foreach (CompilerError err in result.Errors) {
                if (err.IsWarning == false) error = true;
                Console.WriteLine(err);
            }
            if (!error) {
                Console.WriteLine("Compilation successful!");
                WriteHash();
            } else {
                throw new Exception("An error occurred during compilation");
                return null;
            }
            return Assembly.LoadFile(mainscript + ".dll");
        }
 public string GetSourceHash()
 {
     StringBuilder hash = new StringBuilder();
     QFileInfo info = new QFileInfo();
     foreach (string file in GetSources()) {
         info.SetFile(program.AbsoluteDir(), file);
         Stream stream = new FileStream(info.AbsoluteFilePath(), FileMode.Open, FileAccess.Read);
         byte[] bytes = md5.ComputeHash(stream);
         stream.Close();
         hash.Append(Convert.ToBase64String(bytes));
     }
     return hash.ToString();
 }