public async Task<List<AppInfo>> GetMatchingApps(CommandLineArgs args)
        {
            Configuration configuration = Configuration.Instance;
            this._args=args;
            if (!String.IsNullOrWhiteSpace(args.Accountname))
            {
                ActiveUserConfiguration = configuration.UserConfigurations.FirstOrDefault(p => p.ConfigurationName.ToUpper().Equals(args.Accountname.ToUpper()));
            }
            else
            {
                ActiveUserConfiguration = configuration.DefaultUserConfiguration;
            }
            if (ActiveUserConfiguration == null)
            {
                throw new Exception("Wrong AccountName or no default account configured!");
            }

            this._envelope = await AppInfoEnvelope.Load(ActiveUserConfiguration);

            switch (args.Platform)
            {
                case AppInfoPlatforms.None:
                    throw new Exception("Platform not supported!");

                case AppInfoPlatforms.Android:
                    MatchAndroid();
                    break;
                case AppInfoPlatforms.Windows:
                    MatchWindows();
                    break;
                case AppInfoPlatforms.Custom:
                    MatchCustom();
                    break;
                case AppInfoPlatforms.WindowsPhone:
                    MatchWindowsPhone();
                    break;
            }

            if (_matchingApps.Count == 0)
            {
                this._matchingApps.AddRange(this._envelope.Apps.Where(p => p.Platform == args.Platform));
            }

            return _matchingApps;
        }
        static void Main(string[] args)
        {
            new CrashHandler();

            string exeFile = System.Reflection.Assembly.GetEntryAssembly().Location;
            string exePath = Path.GetDirectoryName(exeFile);
            var tmp = System.Configuration.ConfigurationManager.OpenExeConfiguration(exePath + @"\HockeyUpload.exe");
            System.Configuration.KeyValueConfigurationCollection col = tmp.AppSettings.Settings;

            HockeyApp.AppLoader.Model.Configuration c = HockeyApp.AppLoader.Model.Configuration.Instance;
            if (Environment.CommandLine.ToUpper().Contains("/HELP"))
            {
                HockeyApp.AppLoader.Model.CommandLineArgs.WriteHelp(Console.Out, "HOCH");
            }
            else if(Environment.GetCommandLineArgs().Count() > 1)
            {
                try
                {
                    _args = Args.Configuration.Configure<HockeyApp.AppLoader.Model.CommandLineArgs>().CreateAndBind(Environment.GetCommandLineArgs());
                }
                catch
                {
                    HockeyApp.AppLoader.Model.CommandLineArgs.WriteHelp(Console.Out, "HOCH");
                    return;
                }

                string errMsg = "";
                if (!_args.IsValid(out errMsg))
                {
                    LogToConsole("Wrong parameter: " + errMsg);
                    return;
                }
                try
                {
                    AppInfoMatcher matcher = new AppInfoMatcher();
                    Task<List<AppInfo>> t = matcher.GetMatchingApps(_args);
                    t.Wait();

                    List<AppInfo> list = t.Result;
                    if (list.Count == 0)
                    {
                        LogToConsole("No matching application found. Please check the configuration information!");
                        return;
                    }
                    else if (list.Count > 1)
                    {
                        LogToConsole("More than one apps are matching. Please change parameter!");
                        LogToConsole("Matching apps: " + list.Select(p => p.Title).Aggregate((a, b) => a + "," + b));
                        return;
                    }

                    UploadStrategy uploader = UploadStrategy.GetStrategy(list.First());
                    LogToConsole("");
                    DateTime start = DateTime.Now;
                    Task task = uploader.Upload(_args.Package, matcher.ActiveUserConfiguration, ProgressHandler, CancellationToken.None);
                    task.Wait();
                    DateTime end = DateTime.Now;
                    TimeSpan sp = end.Subtract(start);
                    FileInfo fi = new FileInfo(_args.Package);
                    long length =  fi.Length;
                    length = length / 8;
                    LogToConsole("");
                    LogToConsole(string.Format("Uploaded {0}KB in {1}sec", length.ToString("###,###,###"), sp.Seconds.ToString("d")));
                }
                catch (Exception ex)
                {
                    LogToConsole("Error: " + ex.Message);
                }
            }
            else
            {
                HockeyApp.AppLoader.Model.CommandLineArgs.WriteHelp(Console.Out, "HOCH");
            }
        }