Пример #1
0
        private async Task DownloadChapterImpl(DownloadChapterRequest task, IProgress <string> progress, CancellationToken cancellationToken)
        {
            progress.Report("Starting...");
            var plugin = pluginManager.GetPlugin(task.Url);
            var images = await plugin.GetImages(task.Url, new Progress <string>(count =>
            {
                progress.Report(count.ToString());
            }), cancellationToken);

            var tempFolder = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());

            var index = 1;

            foreach (var image in images)
            {
                progress.Report($"Download: {index}/{images.Count()}");
                await downloader.GetFileAsync(image, tempFolder, cancellationToken);

                index++;
            }

            foreach (var format in task.Formats)
            {
                var factory = outputFactory.Create(format);
                factory.Save(tempFolder, task.SaveToFolder);
            }

            progress.Report("Done");
        }
Пример #2
0
 public void Execute(string query)
 {
     using var ownedInput = inputFactory.Create();
     using var tempOutput = new StringWriter();
     textTransformer.Transform(ownedInput.Value, tempOutput, query);
     using var ownedOutput = outputFactory.Create();
     ownedOutput.Value.Write(tempOutput);
 }
Пример #3
0
        public IOutput Calculate(IInput input)
        {
            var types    = _listService.GetList();
            var mappings = _filterService.Filter(types, input);

            var result = _factory.Create();

            foreach (var m in mappings)
            {
                result.AddOutputItem(m.X, m.Y, m.Name);
            }
            return(result);
        }
Пример #4
0
        /// <summary>
        /// Initialise this coordinator, specifying a collection of plugins to work with.
        /// </summary>
        /// <param name="plugins">The plugins which control this coordinator.</param>
        public Core(IOutputFactory outputFactory, params ISystemPlugin[] plugins)
        {
            try {
                mConfig = new CoreConfig();

                mPlugins            = new List <ISystemPlugin>(plugins);
                mOrientation        = new Rotation(mRotationLock, mConfig.Pitch, mConfig.Yaw);
                mOrientationDelta   = new Rotation(mRotationLock);
                mPosition           = mConfig.Position;
                mEyePosition        = mConfig.EyePosition;
                mCrashLogFile       = mConfig.CrashLogFile;
                mTickLength         = mConfig.TickLength;
                mDefaultHeight      = mConfig.HeightmapDefault;
                mHeightmap          = new float[mConfig.XRegions * 256, mConfig.YRegions * 256];
                mEnableInputUpdates = mConfig.EnableInputUpdates;

                for (int i = 0; i < mHeightmap.GetLength(0); i++)
                {
                    for (int j = 0; j < mHeightmap.GetLength(1); j++)
                    {
                        mHeightmap[i, j] = mDefaultHeight;
                    }
                }

                foreach (string frame in mConfig.Frames)
                {
                    if (outputFactory != null)
                    {
                        AddFrame(new Frame(frame, outputFactory.Create(frame)));
                    }
                    else
                    {
                        AddFrame(new Frame(frame));
                    }
                }

                foreach (var plugin in mPlugins)
                {
                    plugin.Init(this);
                    plugin.Enabled = mConfig.PluginEnabled(plugin);
                    Logger.Info("Loaded " + plugin.Name + ". " + (plugin.Enabled ? "Enabled" : "Disabled") + ".");
                }

                Thread tickThread = new Thread(TickMethod);

                tickThread.Name = "Tick Thread";
                //tickThread.Priority = ThreadPriority.Highest;
                tickThread.Start();
                mInitialised = true;
                if (InitialisationComplete != null)
                {
                    InitialisationComplete();
                }
            } catch (Exception e) {
                Logger.Warn("Unable to instantiate core. " + e.Message);
                Logger.Debug("Unable to instantiate core.", e);
            } finally {
                if (!mInitialised)
                {
                    Close();
                }
            }
        }