Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="assembly"></param>
        /// <param name="startupArgs"></param>
        public ApplicationInfo(Assembly assembly, string[] startupArgs, StartupArgumentFlagCollection flags)
        {
            if (startupArgs == null)
            {
                startupArgs = new string[0];
            }

            if (startupArgs.Length > 0)
            {
                StringBuilder sb = new StringBuilder();

                for (int i = 0; i < startupArgs.Length; i++)
                {
                    sb.AppendFormat("{0}{1}", startupArgs[i], i + 1 == startupArgs.Length ? "" : ",");
                }

                Tracer.Verbose("Application started with the following startup arguments: {0}", sb.ToString());
            }

            Asserter.AssertIsNotNull(assembly, "assembly");

            _assembly              = assembly;
            _startupArgs           = startupArgs;
            _startupArgumentParser = new StartupArgumentParser(StartupArgumentFormats.All, false, flags);
            _startupArgumentParser.Parse(startupArgs);
        }
Example #2
0
        /// <summary>
        /// Parses an array of arguments, typically obtained from Main method of console application.
        /// </summary>
        /// <param name="format">The valid format(s).</param>
        /// <param name="flags">Accepted flags (named or not) and their respective values.</param>
        /// <param name="ignoreCase">Indicates if parsing is case sensitive.</param>
        /// <param name="customPattern">An additional regular expression pattern to be used when parsing arguments. It will have priority over the standard pattern.</param>
        /// <remarks>In your pattern, use capture name constants made public by this class.</remarks>
        public StartupArgumentParser(StartupArgumentFormats format, bool ignoreCase, StartupArgumentFlagCollection flags, string customPattern)
        {
            _handled   = new StringDictionary();
            _unhandled = new StringDictionary();

            _allowedFormats = format;
            _ignoreCase     = ignoreCase;
            _flags          = flags;
            _customPattern  = customPattern;

            // default values

            _allowedPrefixes = new char[] { '-', '/' };
            _assignSymbols   = new char[] { '=', ':' };
        }
Example #3
0
 /// <summary>
 /// Parses an array of arguments, typically obtained from Main method of console application.
 /// </summary>
 /// <param name="format">The valid format(s).</param>
 /// <param name="ignoreCase">Indicates if parsing is case sensitive.</param>
 /// <param name="flags">Accepted flags (named or not) and their respective values.</param>
 public StartupArgumentParser(StartupArgumentFormats format, bool ignoreCase, StartupArgumentFlagCollection flags) : this(format, ignoreCase, flags, null)
 {
 }
Example #4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="startupArgs"></param>
 public ApplicationInfo(string[] startupArgs, StartupArgumentFlagCollection flags)
     : this(System.Reflection.Assembly.GetEntryAssembly(), startupArgs, flags)
 {
 }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="assembly"></param>
        /// <param name="startupArgs"></param>
        public ApplicationInfo(Assembly assembly, string[] startupArgs, StartupArgumentFlagCollection flags)
        {
            if (startupArgs == null)
                startupArgs = new string[0];

            if(startupArgs.Length > 0)
            {
                StringBuilder sb = new StringBuilder();

                for(int i = 0; i < startupArgs.Length; i++)
                    sb.AppendFormat("{0}{1}", startupArgs[i], i + 1 == startupArgs.Length ? "" : ",");

                Tracer.Verbose("Application started with the following startup arguments: {0}", sb.ToString());
            }

            Asserter.AssertIsNotNull(assembly, "assembly");

            _assembly = assembly;
            _startupArgs = startupArgs;
            _startupArgumentParser = new StartupArgumentParser(StartupArgumentFormats.All, false, flags);
            _startupArgumentParser.Parse(startupArgs);
        }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="startupArgs"></param>
 public ApplicationInfo(string[] startupArgs, StartupArgumentFlagCollection flags)
     : this(System.Reflection.Assembly.GetEntryAssembly(), startupArgs, flags)
 {
 }
        /// <summary>
        /// Parses an array of arguments, typically obtained from Main method of console application.
        /// </summary>
        /// <param name="format">The valid format(s).</param>
        /// <param name="flags">Accepted flags (named or not) and their respective values.</param>
        /// <param name="ignoreCase">Indicates if parsing is case sensitive.</param>
        /// <param name="customPattern">An additional regular expression pattern to be used when parsing arguments. It will have priority over the standard pattern.</param>
        /// <remarks>In your pattern, use capture name constants made public by this class.</remarks>
        public StartupArgumentParser(StartupArgumentFormats format, bool ignoreCase, StartupArgumentFlagCollection flags, string customPattern)
        {
            _handled = new StringDictionary();
            _unhandled = new StringDictionary();

            _allowedFormats = format;
            _ignoreCase = ignoreCase;
            _flags = flags;
            _customPattern = customPattern;

            // default values

            _allowedPrefixes = new char[] {'-', '/'};
            _assignSymbols = new char[] {'=', ':'};
        }
 /// <summary>
 /// Parses an array of arguments, typically obtained from Main method of console application.
 /// </summary>
 /// <param name="format">The valid format(s).</param>
 /// <param name="ignoreCase">Indicates if parsing is case sensitive.</param>
 /// <param name="flags">Accepted flags (named or not) and their respective values.</param>
 public StartupArgumentParser(StartupArgumentFormats format, bool ignoreCase, StartupArgumentFlagCollection flags)
     : this(format, ignoreCase, flags, null)
 {
 }
Example #9
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            _kernel.Load(AppDomain.CurrentDomain.GetAssemblies());

            StartupArgumentFlagCollection startupFlags = new StartupArgumentFlagCollection();
            IApplicationService applicationService = _kernel.Get<IApplicationService>();
            ApplicationInfo applicationInfo = new ApplicationInfo(Assembly.GetEntryAssembly(), args, startupFlags);

            Directory.SetCurrentDirectory(applicationInfo.BaseDirectory);

            applicationService.ApplicationInfo = applicationInfo;
            //applicationService.TraceListeners.Add(new CrashLogTraceListener());

            if (applicationService.Debug)
            {
                applicationService.TraceListeners.Add(new FileTraceListener(Path.Combine(applicationInfo.BaseDirectory, "debug.log")));
            }

            EnsureDotNet35SP1();

            CuoUri.Initialize(applicationService);

            if (ContainsCuoProtocol(args))
            {
                return;
            }

            using (Mutex mutex = new Mutex(false, MutexName))
            {
                Tracer.Verbose("Entering Mutex {0}", MutexName);

                if (!mutex.WaitOne(1, true))
                {
                    MessageBoxEx.Show(null, "ConnectUO is already running.");
                    return;
                }

                SplashScreen splashScreen = _kernel.Get<SplashScreen>();
                ShellForm mainForm = _kernel.Get<IShell>() as ShellForm;

                applicationService.MainForm = mainForm;

                Application.Run(splashScreen);
                Application.Run(mainForm);
            }
        }