示例#1
0
        public void Init(SDBApplication mm)
        {
            Log.Logger = new LoggerConfiguration()
                         .MinimumLevel.Debug()
                         //.WriteTo.Seq("http://localhost:5341")
                         .WriteTo.Console()
                         .CreateLogger();
            Log.Debug("Console initialization...");
            AllocConsole();
            var stdHandle      = GetStdHandle(STD_OUTPUT_HANDLE);
            var safeFileHandle = new SafeFileHandle(stdHandle, true);
            var fileStream     = new FileStream(safeFileHandle, FileAccess.Write);
            var encoding       = Encoding.GetEncoding(MY_CODE_PAGE);
            var standardOutput = new StreamWriter(fileStream, encoding);

            standardOutput.AutoFlush = true;
            Console.SetOut(standardOutput);
            Log.Information("Console initialized");


            Log.Debug("Inicializacije Akke");

            var assembly     = Assembly.GetExecutingAssembly();
            var resourceName = "Ripp.Sng.MediaMonkey.Akka.Agent.akka.hocon";

            Config config;

            using (var stream = assembly.GetManifestResourceStream(resourceName))
            {
                using (var reader = new StreamReader(stream))
                {
                    var result = reader.ReadToEnd();
                    config = ConfigurationFactory.ParseString(result);
                }
            }

            if (config.IsEmpty)
            {
                throw new Exception("Configuration not found");
            }


            this.MmApp = new MediaMonkeyApp(mm);
            // Setup Autofac
            var builder = new ContainerBuilder();

            builder.RegisterInstance(this.MmApp);
            var container = builder.Build();

            this.Akka         = SngAkkaApp.CreateAkkaSystem(config);
            this.AkkaResolver = new AutoFacDependencyResolver(container, this.Akka);

            Log.Information("Akka initialized");

            this.AkkaCluster = Cluster.Get(this.Akka);

            this.MmApp.Com.set_Objects(Assembly.GetExecutingAssembly().GetName().Name, this);
        }
示例#2
0
 public Task Close()
 {
     application = null;
     return(Task.CompletedTask);
 }
示例#3
0
 public MediaMonkeyApp(SDBApplication com) => this.Com = com ?? throw new ArgumentNullException(nameof(com));