2021-12-06 02:49:27 +03:00
using Microsoft.AspNetCore.Hosting ;
using Microsoft.Extensions.Configuration ;
using Microsoft.Extensions.Hosting ;
using Microsoft.Extensions.Logging ;
using System ;
using System.Collections.Generic ;
2022-08-13 20:15:43 +03:00
using System.IO ;
2021-12-06 02:49:27 +03:00
using System.Linq ;
using System.Threading.Tasks ;
using BlueWest.Core ;
using BlueWest.Tools ;
namespace BlueWest.WebApi
{
public class Program
{
public static readonly EventManager EventManager =
2022-08-13 08:34:20 +03:00
new EventManager ( new Dictionary < Type , List < EventListenerBase > > ( 10000 ) ) ;
2021-12-06 02:49:27 +03:00
private static ThreadServer _threadServer ;
2021-12-08 02:57:27 +03:00
/ * private static CSharpCompilation GenerateCode ( string sourceCode )
{
var codeString = SourceText . From ( sourceCode ) ;
var parsedSyntaxTree = SyntaxFactory . ParseSyntaxTree ( codeString , CSharpParseOptions . Default ) ;
2021-12-06 02:49:27 +03:00
2021-12-08 02:57:27 +03:00
return CSharpCompilation . Create ( "Hello.dll" ,
new [ ] { parsedSyntaxTree } ,
references : ReferenceAssemblies . Net50 , // install jared's Basic.Reference.Assemblies for this, otherwise, you are going to manually add the DLLs you want
options : new CSharpCompilationOptions ( OutputKind . ConsoleApplication ,
optimizationLevel : OptimizationLevel . Release ) ) ;
} * /
2021-12-06 02:49:27 +03:00
public static IHost Host1 { get ; private set ; }
public static void Main ( string [ ] args )
{
2022-08-13 20:15:43 +03:00
Host1 = CreateHostBuilder ( args )
. UseContentRoot ( Directory . GetCurrentDirectory ( ) )
. Build ( ) ;
2021-12-06 02:49:27 +03:00
Host1 . RunAsync ( ) ;
System . Threading . Thread . Sleep ( 2500 ) ;
_threadServer = new ThreadServer ( EventManager ) ;
_threadServer . Init ( ) ;
}
public static IHostBuilder CreateHostBuilder ( string [ ] args ) = >
Host . CreateDefaultBuilder ( args )
2022-08-13 18:21:23 +03:00
2021-12-06 02:49:27 +03:00
. ConfigureWebHostDefaults ( webBuilder = >
{
webBuilder . UseStartup < Startup > ( ) ;
} ) ;
}
}