private void InitializeCommandLineOptions(string[] args, OrigoBootstrapper bootstrapper)
        {
            bool showHelp = false;

            var p = new OptionSet
            {
                { "u|username="******"spotify username", userName => bootstrapper.UserName = userName },
                { "p|password="******"spotify password", password => bootstrapper.Password = password },
                { "httpPort=", "the port the http wcf services will be hosted on", (int port) => bootstrapper.HttpPort = port },
                { "tcpPort=", "the port the tcp wcf services will be hosted on", (int port) => bootstrapper.TcpPort = port },
                { "h|help", "show this message and exit", v => showHelp = v != null }
            };

            try
            {
                p.Parse(args);
            }
            catch (OptionException e)
            {
                Console.Write("greet: ");
                Console.WriteLine(e.Message);
                Console.WriteLine("Try `greet --help' for more information.");
            }

            if (showHelp)
            {
                p.WriteOptionDescriptions(Console.Out);
            }
        }
        private void StartOrigo()
        {
            var assembly         = GetType().Assembly;
            var assemblyLocation = Path.GetDirectoryName(assembly.Location) ?? Environment.CurrentDirectory;

            AppDomainSetup setup = new AppDomainSetup();

            setup.ApplicationName     = "Spotify";
            setup.ApplicationBase     = assemblyLocation;
            setup.PrivateBinPath      = Path.Combine("Modules", "Spotify");
            setup.PrivateBinPathProbe = "true";

            _appDomain = AppDomain.CreateDomain("OrigoDomain", null, setup);
            AppDomain.CurrentDomain.AssemblyResolve += OrigoDomainOnAssemblyResolve;
            OrigoBootstrapper host = _appDomain.CreateInstanceAndUnwrap(
                typeof(OrigoBootstrapper).Assembly.FullName,
                "Torshify.Origo.OrigoBootstrapper") as OrigoBootstrapper;

            AppDomain.CurrentDomain.AssemblyResolve -= OrigoDomainOnAssemblyResolve;

            if (host != null)
            {
                InitializeCommandLineOptions(Environment.GetCommandLineArgs(), host);
                host.Run();
            }
            else
            {
                AppDomain.Unload(_appDomain);
                _appDomain = null;
            }
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            InitializeAssemblyResolve();

            Bootstrapper = new OrigoBootstrapper();

            InitializeCommandLineOptions(args);

            if (Bootstrapper.Run())
            {
                Console.ReadLine();
            }
        }
        private void InitializeCommandLineOptions(string[] args, OrigoBootstrapper bootstrapper)
        {
            bool showHelp = false;

            var p = new OptionSet
                    {
                        { "u|username="******"spotify username", userName => bootstrapper.UserName = userName },
                        { "p|password="******"spotify password", password => bootstrapper.Password = password },
                        { "httpPort=", "the port the http wcf services will be hosted on", (int port) => bootstrapper.HttpPort = port },
                        { "tcpPort=", "the port the tcp wcf services will be hosted on", (int port) => bootstrapper.TcpPort = port },
                        { "h|help",  "show this message and exit", v => showHelp = v != null }
                    };

            try
            {
                p.Parse(args);
            }
            catch (OptionException e)
            {
                Console.Write("greet: ");
                Console.WriteLine(e.Message);
                Console.WriteLine("Try `greet --help' for more information.");
            }

            if (showHelp)
            {
                p.WriteOptionDescriptions(Console.Out);
            }
        }