예제 #1
0
        public bool IsCompatible(IParseInfo info)
        {
            var urlOrFile = info.URI;

            if (!Uri.TryCreate(urlOrFile, UriKind.Absolute, out Uri url))
            {
                Log.Debug("Not compatible because not a url: {urlOrFile}", urlOrFile);
                return(IsCompatibleAsHOTCTextFile(info));
            }
            if (url.Authority != "heartofthecards.com" && url.Authority != "www.heartofthecards.com")
            {
                Log.Debug("Not compatible because {Authority} is not heartofthecards.com", url.Authority);
                return(false);
            }

            if (!url.AbsolutePath.StartsWith("/translations/"))
            {
                Log.Debug("Not compatible because {AbsolutePath} does not start with /translations.", url.AbsolutePath);
                return(false);
            }
            if (url.AbsolutePath == "/translations/")
            {
                Log.Debug("Not compatible because absolute path cannot be /translations/ itself; please provide a set html.");
                return(false);
            }
            Log.Information("Selected.");
            return(true);
        }
    private bool IsCompatibleAsURL(IParseInfo info)
    {
        var urlOrFile = info.URI;

        if (!Uri.TryCreate(urlOrFile, UriKind.Absolute, out Uri url))
        {
            Log.Debug("Not compatible because not a url: {urlOrFile}", urlOrFile);
            return(false);
        }
        if (!url.IsWellFormedOriginalString())
        {
            Log.Debug("Not a proper URL, will ignore: {urlOrFile}", urlOrFile);
            return(false);
        }
        if (url.Authority != "heartofthecards.com" && url.Authority != "www.heartofthecards.com")
        {
            Log.Debug("Not compatible because {Authority} is not heartofthecards.com", url.Authority);
            return(false);
        }

        if (!url.AbsolutePath.StartsWith("/translations/"))
        {
            Log.Debug("Not compatible because {AbsolutePath} does not start with /translations.", url.AbsolutePath);
            return(false);
        }
        if (url.AbsolutePath == "/translations/")
        {
            Log.Debug("Not compatible because absolute path cannot be /translations/ itself; please provide a set html.");
            return(false);
        }
        Log.Information("Compatible as a URL.");
        return(true);
    }
예제 #3
0
        private void DownloadUpdate(IParseInfo updateInfo)
        {
            // Show DownloadForm
            var form   = new DownloadForm(updateInfo, _applicationInfo.ApplicationIcon);
            var result = form.ShowDialog(_applicationInfo.Context);

            // Download update
            if (result == DialogResult.OK)
            {
                var updateFolderName = string.Format("{0}_update_{1}", _applicationInfo.ApplicationName,
                                                     Utilities.CleanFileName(updateInfo.Version.ToString()));

                var currentPath   = _applicationInfo.ApplicationAssembly.Location;
                var newFolderPath = Path.GetDirectoryName(currentPath);
                // string newPath = Path.GetDirectoryName(currentPath) + "\\" + updateFolderName;

                // Update
                UpdateApplication(updateInfo.Files, currentPath, newFolderPath, updateInfo.LaunchArgs);

                Application.Exit();
            }
            else if (result == DialogResult.Abort)
            {
                MessageBox.Show("The update download was cancelled.\nThis program has not been modified.",
                                "Update Download Cancelled", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("There was a problem downloading the update.\nPlease try again later.",
                                "Update Download Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
예제 #4
0
        //private JsonSerializer _jsonSerializer = new JsonSerializer();

        public bool IsCompatible(IParseInfo info)
        {
            if (Uri.TryCreate(info.URI, UriKind.Absolute, out var uri))
            {
                return(uri.LocalPath.EndsWith(".r4uset"));
            }
            else
            {
                return(Fluent.IO.Path.Get(info.URI).Extension == ".r4uset");
            }
        }
예제 #5
0
        private bool IsCompatibleAsHOTCTextFile(IParseInfo info)
        {
            if (!info.ParserHints.Select(s => s.ToLower()).Contains("hotc"))
            {
                return(false);
            }
            Log.Information("Checking if this is a local .txt file instead...");
            var possiblyPath = Path.Get(info.URI);

            return(possiblyPath.Exists && possiblyPath.Extension == ".txt");
        }
    private bool IsCompatibleAsHOTCTextFile(IParseInfo info)
    {
        if (!info.ParserHints.Select(s => s.ToLower()).Contains("hotc"))
        {
            return(false);
        }
        var possiblyPath = Path.Get(info.URI);
        var isCompatible = possiblyPath.Exists && possiblyPath.Extension == ".txt";

        if (isCompatible)
        {
            Log.Information("Compatible as a Local .txt file.");
        }
        return(isCompatible);
    }
예제 #7
0
        /// <summary>
        ///     Creates a new DownloadForm
        /// </summary>
        /// <summary>
        ///     Creates a new DownloadForm
        /// </summary>
        internal DownloadForm(IParseInfo updateInfo, Icon programIcon)
        {
            InitializeComponent();

            if (programIcon != null)
            {
                Icon = programIcon;
            }


            UpdateInfo = updateInfo;


            // Download files
            DownloadFiles();
        }
예제 #8
0
        /// <summary>
        ///     The update info display form
        /// </summary>
        /// <summary>
        ///     Creates a new SharpUpdateAcceptForm
        /// </summary>
        /// <param name="applicationInfo"></param>
        /// <param name="updateInfo"></param>
        public MainForm(IEUpdatable applicationInfo, IParseInfo updateInfo)
        {
            InitializeComponent();

            // Sets the icon if it's not null
            if (applicationInfo.ApplicationIcon != null)
            {
                Icon = applicationInfo.ApplicationIcon;
            }

            // Fill in the UI
            Text        = "Check for " + applicationInfo.ApplicationName + " updates...";
            label2.Text = string.Format("A new version is available:\nOld version: {0}\nNew version: {1}",
                                        applicationInfo.ApplicationAssembly.GetName().Version,
                                        updateInfo.Version);
            txtDescription.Text = updateInfo.Description;
        }
예제 #9
0
    public async Task <bool> IsIncluded(IParseInfo info)
    {
        await Task.CompletedTask;

        if (info.ParserHints.Select(s => s.ToLower()).Contains("skip:yyt"))
        {
            Log.Information("Skipping due to the parser hint [skip:yyt].");
            return(false);
        }
        else if (info.ParserHints.Select(s => s.ToLower()).Contains("noskip:yyt"))
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
예제 #10
0
        public bool IsCompatible(IParseInfo info)
        {
            var urlOrFile = info.URI;

            if (encoreDecksAPIMatcher.IsMatch(urlOrFile))
            {
                Log.Information("Compatibility Passed for: {urlOrFile}", urlOrFile);
                return(true);
            }
            else if (encoreDecksSiteSetMatcher.IsMatch(urlOrFile))
            {
                Log.Information("Compatibility Passed for: {urlOrFile}", urlOrFile);
                return(true);
            }
            else
            {
                Log.Debug("Compatibility Failed for: {urlOrFile}", urlOrFile);
                return(false);
            }
        }
예제 #11
0
    public async Task <bool> IsCompatible(IParseInfo info)
    {
        var urlOrFile = info.URI;

        if (encoreDecksAPIMatcher.IsMatch(urlOrFile))
        {
            Log.Information("Compatibility Passed for: {urlOrFile}", urlOrFile);

            return(await ValueTask.FromResult(true));
        }
        else if (encoreDecksSiteSetMatcher.IsMatch(urlOrFile))
        {
            Log.Information("Compatibility Passed for: {urlOrFile}", urlOrFile);
            return(await ValueTask.FromResult(true));
        }
        else
        {
            Log.Debug("Compatibility Failed for: {urlOrFile}", urlOrFile);
            return(await ValueTask.FromResult(false));
        }
    }
예제 #12
0
        /// <summary>
        ///     Parses the update file into ParseInfoObject object
        /// </summary>
        /// <param name="location">Uri of update file on server (ex. update.xml)</param>
        /// <param name="appId">The application's ID</param>
        /// <param name="parseType">Type of document to parse</param>
        /// <returns>The SharpUpdateXml object with the data, or null of any errors</returns>
        internal static async Task <IParseInfo> ParseAsync(Uri location, string appId)
        {
            IParseInfo parseInfo = null;
            var        parseType = GetDocType(location.AbsoluteUri);

            switch (parseType)
            {
            case ParseType.Xml:
                parseInfo = await ParseXml(location, appId);

                break;

            case ParseType.Json:
                parseInfo = await ParseJson(location, appId);

                break;
            }

            _parseInfo = parseInfo;

            return(parseInfo);
        }
예제 #13
0
 private bool AskAboutUpdate(IParseInfo updateInfo)
 {
     return(new MainForm(_applicationInfo, updateInfo).ShowDialog(_applicationInfo.Context) == DialogResult.Yes);
 }
예제 #14
0
 public bool IsCompatible(IParseInfo parseInfo)
 {
     return(fandomMatcher.IsMatch(parseInfo.URI));//.Contains("rebirth-for-you.fandom.com/wiki/");
 }
 public async Task <bool> IsCompatible(IParseInfo parseInfo)
 {
     return(await ValueTask.FromResult(IsCompatibleAsHOTCTextFile(parseInfo) || IsCompatibleAsURL(parseInfo)));
 }
예제 #16
0
//        private Func<Task<Dictionary<string, R4UReleaseSet>>> _sets;

        /*
         * public R4URenegadesSetParser()
         * {
         *  _sets = async () => new Dictionary<string, R4UReleaseSet>();
         * }
         *
         * public R4URenegadesSetParser (IContainer ioc)
         * {
         *  _sets = async () =>
         *  {
         *      using (var db = ioc.GetInstance<CardDatabaseContext>())
         *      {
         *          return await db.R4UReleaseSets.ToDictionaryAsync(s => s.ReleaseCode);
         *      }
         *  };
         * }
         *
         */

        public bool IsCompatible(IParseInfo parseInfo)
        {
            return(parseInfo.URI.StartsWith("https://rebirthforyourenegades.wordpress.com/"));
        }