Build() public method

public Build ( CancellationToken cancellationToken ) : Task
cancellationToken System.Threading.CancellationToken
return Task
示例#1
0
        public void PackageBuilderTest()
        {
            var penDirectory = TestFile("penDirectory");
            PathUtil.EnsureNotExists(penDirectory);
            PathUtil.EnsureDirectoryExists(penDirectory);
            var converter = new MediaFileConverter(TestFile("media-cache"));
            var albumReader = new AlbumReader();

            var package = Package.CreateFromInputPaths(new[] { TestFile("audio") });
            package.Albums.First().Tracks = Enumerable.Range(0, 20).Select(_ => package.Albums.First().Tracks.First()).ToArray();
            package.ProductId = 800;
                
            var structure = new PackageDirectoryStructure(penDirectory, package);
            var pb = new PackageBuilder(structure, converter);

            pb.Build(CancellationToken.None).Wait();

            Console.WriteLine(structure.GmeFile);
        }
示例#2
0
        static void Main(string[] args)
        {
            log4net.Config.BasicConfigurator.Configure();

            var pen = TipToiPen.GetAll().FirstOrDefault();
            if (pen == null)
            {
                pen = TipToiPen.Simulated;
                log.InfoFormat("Pen is not attached. Output will be written to {0}", pen.RootDirectory);
            }

            var package = Package.CreateFromInputPaths(args);
    
            var cacheDirectory = Path.Combine(About.LocalApplicationDataDirectory, "cache");
            var converter = new MediaFileConverter(cacheDirectory);

            var structure = new PackageDirectoryStructure(pen.RootDirectory, package);
            var packageBuilder = new PackageBuilder(structure, converter, Settings.Read().CreateOidSvgWriter());
            packageBuilder.Build(CancellationToken.None).Wait();
        }
示例#3
0
        static void Main(string[] args)
        {
            log4net.Config.BasicConfigurator.Configure();

            var pen = TipToiPen.GetAll().FirstOrDefault();

            if (pen == null)
            {
                pen = TipToiPen.Simulated;
                log.InfoFormat("Pen is not attached. Output will be written to {0}", pen.RootDirectory);
            }

            var package = Package.CreateFromInputPaths(args);

            var cacheDirectory = Path.Combine(About.LocalApplicationDataDirectory, "cache");
            var converter      = new MediaFileConverter(cacheDirectory);

            var structure      = new PackageDirectoryStructure(pen.RootDirectory, package);
            var packageBuilder = new PackageBuilder(structure, converter, Settings.Read().CreateOidSvgWriter());

            packageBuilder.Build(CancellationToken.None).Wait();
        }
示例#4
0
        public async Task Build(CancellationToken cancellationToken)
        {
            var p = packageDirectoryStructure.Package;

            PrepareInputFiles(cancellationToken);

            cancellationToken.ThrowIfCancellationRequested();

            // check if size > MaxGmeSize and split into parts if required
            var parts = Split(p);

            if (parts.Count > 1)
            {
                foreach (var i in parts)
                {
                    var structure = new PackageDirectoryStructure(Path.GetDirectoryName(this.packageDirectoryStructure.GmeFile), i);
                    var pb        = new PackageBuilder(structure, this.converter, OidSvgWriter);
                    await pb.Build(cancellationToken);
                }
                return;
            }

            // write yaml
            WriteYaml();

            // write html
            WriteHtml(cancellationToken);

            // open html
            Process.Start(packageDirectoryStructure.HtmlFile);

            cancellationToken.ThrowIfCancellationRequested();

            // create gme
            await Assemble(cancellationToken);

            log.InfoFormat("{0} was sucessfully built.", packageDirectoryStructure.GmeFile);
        }
示例#5
0
        public async Task Build(CancellationToken cancellationToken)
        {
            var p = packageDirectoryStructure.Package;

            PrepareInputFiles(cancellationToken);

            cancellationToken.ThrowIfCancellationRequested();

            // check if size > MaxGmeSize and split into parts if required
            var parts = Split(p);
            if (parts.Count > 1)
            {
                foreach (var i in parts)
                {
                    var structure = new PackageDirectoryStructure(Path.GetDirectoryName(this.packageDirectoryStructure.GmeFile), i);
                    var pb = new PackageBuilder(structure, this.converter, OidSvgWriter);
                    await pb.Build(cancellationToken);
                }
                return;
            }

            // write yaml
            WriteYaml();

            // write html
            WriteHtml(cancellationToken);

            // open html
            Process.Start(packageDirectoryStructure.HtmlFile);

            cancellationToken.ThrowIfCancellationRequested();

            // create gme
            await Assemble(cancellationToken);

            log.InfoFormat("{0} was sucessfully built.", packageDirectoryStructure.GmeFile);
        }
示例#6
0
        public async Task Build(string[] mp3FilesOrDirectories)
        {
            if (!mp3FilesOrDirectories.Any())
            {
                throw new ArgumentOutOfRangeException(nameof(mp3FilesOrDirectories), String.Empty, "You must specify at least one audio file.");
            }

            var pen = TipToiPen.GetAll().FirstOrDefault();

            if (pen == null)
            {
                pen = TipToiPen.Simulated;
                log.InfoFormat("Pen is not attached. Output will be written to {0}", pen.RootDirectory);
            }

            var package = Package.CreateFromInputPaths(mp3FilesOrDirectories);

            var cacheDirectory = Path.Combine(About.Get().LocalApplicationDataDirectory, "cache");
            var converter      = new MediaFileConverter(cacheDirectory);

            var structure      = new PackageDirectoryStructure(pen.RootDirectory, package);
            var packageBuilder = new PackageBuilder(structure, converter, Settings.Read().CreateOidSvgWriter());
            await packageBuilder.Build(CancellationToken.None);
        }
示例#7
0
        Task Convert(CancellationToken cancel, IList<string> files, string title, string productId)
        {
            return Task.Factory.StartNew(async () => 
            {
                try
                {
                    var package = Package.CreateFromInputPaths(files);
                    
                    if (!String.IsNullOrEmpty(title))
                    {
                        package.Title = title;
                    }
                    if (!String.IsNullOrEmpty(productId))
                    {
                        package.ProductId = UInt16.Parse(productId);
                    }

                    var converter = Context.GetDefaultMediaFileConverter();

                    var pen = TipToiPen.GetAll().First();
                    var packageBuilder = new PackageBuilder(
                        new PackageDirectoryStructure(pen.RootDirectory, package), converter);

                    await packageBuilder.Build(cancel);
                }
                catch (Exception ex)
                {
                    log.Error(ex);
                }
            }, cancel);
        }