Beispiel #1
0
        private static void Resize(ProgArgs progArgs)
        {
            Arguments args = ParameterHelper.Parse(progArgs);

            ServiceCollection services = new ServiceCollection();

            services.AddLogging(builder => builder.AddConsole());
            services.AddSingleton(GetCsProjUpdater(args.Platform, args.Csproj));
            services.AddSingleton <IImageRenamer, ImageRenamer>();
            services.AddSingleton <IImageResizer, ImageResizer>();
            services.AddSingleton <IArgumentsPrinter, ArgumentsPrinter>();
            services.AddSingleton <IIconResizeUtilityService, IconResizeUtitlityService>();
            AddResizeService(services, args.Platform);
            IServiceProvider serviceProvider = services.BuildServiceProvider();

            IArgumentsPrinter printer = serviceProvider.GetService <IArgumentsPrinter>();

            printer.PrintArguments(args);

            IImageResizer resizer = serviceProvider.GetService <IImageResizer>();

            resizer.UseCache = args.UseCache;

            IIconResizeUtilityService utilityService = serviceProvider.GetService <IIconResizeUtilityService>();
            ILogger <Program>         logger         = serviceProvider.GetService <ILogger <Program> >();

            logger.LogInformation("Starting resize...");
            Stopwatch watch = Stopwatch.StartNew();

            utilityService.Resize(args.SourceFolder, args.DestinationFolder, args.Csproj, args.PostfixSize, args.Prefix, args.Sizes, args.Colors, args.ResizeToValidIconName);
            watch.Stop();
            logger.LogInformation($"Resize done, duration={watch.ElapsedMilliseconds}ms");
        }
 public static Arguments Parse(ProgArgs progArgs)
 {
     return(new Arguments
     {
         Platform = GetPlatform(progArgs.Type),
         SourceFolder = progArgs.SrcFolder,
         DestinationFolder = progArgs.DstFolder,
         Prefix = progArgs.Prefix,
         PostfixSize = progArgs.PostfixSize,
         Csproj = progArgs.Csproj,
         Sizes = ParseSizes(progArgs.IconSize, GetPlatform(progArgs.Type)),
         Colors = ParseColors(progArgs.Color),
         ResizeToValidIconName = !progArgs.DoNotRename,
         UseCache = progArgs.UseCache
     });
 }