Пример #1
0
 private void CompileFromSource(RoslynCompiler compiler, ZipArchiveEntry entry)
 {
     if (AllowedZipPath(entry.FullName))
     {
         using (Stream entryStream = entry.Open())
         {
             compiler.Load(entryStream, entry.FullName);
         }
     }
 }
Пример #2
0
        /// <summary>
        /// Register extensions plugins/scripts
        /// </summary>
        /// <param name="mvcCoreBuilder"></param>
        /// <param name="configuration"></param>
        private static void RegisterExtensions(IMvcCoreBuilder mvcCoreBuilder, IConfiguration configuration)
        {
            var config = new AppConfig();

            configuration.GetSection("Application").Bind(config);

            //Load plugins
            PluginManager.Load(mvcCoreBuilder, config);

            //Load CTX sctipts
            RoslynCompiler.Load(mvcCoreBuilder.PartManager, config);
        }
Пример #3
0
        public override Assembly GetAssembly()
        {
            if (Directory.Exists(Id))
            {
                RoslynCompiler compiler = new RoslynCompiler(FolderSettings.DebugBuild);
                bool           hasFile  = false;
                StringBuilder  sb       = new StringBuilder();
                sb.Append("Compiling files from ").Append(Id).Append(":").AppendLine();
                foreach (var file in GetProjectFiles(Id))
                {
                    using (FileStream fileStream = File.OpenRead(file))
                    {
                        hasFile = true;
                        string name = file.Substring(Id.Length + 1, file.Length - (Id.Length + 1));
                        sb.Append(name).Append(", ");
                        compiler.Load(fileStream, file);
                    }
                }

                if (hasFile)
                {
                    sb.Length -= 2;
                    LogFile.WriteLine(sb.ToString());
                }
                else
                {
                    throw new IOException("No files were found in the directory specified.");
                }

                byte[]   data = compiler.Compile(FriendlyName + '_' + Path.GetRandomFileName(), out byte[] symbols);
                Assembly a    = Assembly.Load(data, symbols);
                Version = a.GetName().Version;
                return(a);
            }

            throw new DirectoryNotFoundException("Unable to find directory '" + Id + "'");
        }