/// <summary>
        /// Processes the queried notification text parser.
        /// </summary>
        /// <param name="result">The result.</param>
        private static void OnDownloaded(DownloadResult <string> result)
        {
            if (result.Error != null)
            {
                // Reset query pending flag
                s_queryPending = false;

                EveMonClient.Trace(result.Error.Message);
                return;
            }

            string[] referenceAssemblies =
            {
                typeof(Enumerable).Assembly.Location,
                typeof(YamlNode).Assembly.Location,
            };

            // Revert to internal parser if the compilation fails for any reason
            s_parser = CodeCompiler.GenerateAssembly <EveNotificationTextParser>(
                referenceAssemblies, result.Result) ?? new InternalEveNotificationTextParser();

            // Reset query pending flag
            // after we compiled the parser
            s_queryPending = false;
            s_cachedUntil  = DateTime.UtcNow.AddHours(12);

            // Notify the subscribers
            NotificationTextParserUpdated?.ThreadSafeInvoke(null, EventArgs.Empty);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="EveNotificationText" /> class.
        /// </summary>
        /// <param name="notification">The notification.</param>
        /// <param name="src">The source.</param>
        /// <exception cref="System.ArgumentNullException">src</exception>
        public EveNotificationText(EveNotification notification, SerializableNotificationTextsListItem src)
        {
            src.ThrowIfNull(nameof(src));

            NotificationID = src.NotificationID;
            NotificationText = src.NotificationText;
            m_notification = notification;
            m_parser = EveNotificationTextParser.GetParser();
        }
        /// <summary>
        /// Gets the parser.
        /// </summary>
        /// <returns></returns>
        internal static EveNotificationTextParser GetParser()
        {
            if (s_parser != null && s_cachedUntil > DateTime.UtcNow)
            {
                return(s_parser);
            }

            // GetExternalParserAsync();
            // The external parser is very out of date
            return(s_parser = new InternalEveNotificationTextParser());
        }
Exemplo n.º 4
0
        /// <summary>
        /// Processes the queried notification text parser.
        /// </summary>
        /// <param name="result">The result.</param>
        private static void OnDownloaded(DownloadResult<String> result)
        {
            if (result.Error != null)
            {
                // Reset query pending flag
                s_queryPending = false;

                EveMonClient.Trace(result.Error.Message);
                return;
            }

            string[] referenceAssemblies =
            {
                typeof(Enumerable).Assembly.Location,
                typeof(YamlNode).Assembly.Location,
            };

            // Revert to internal parser if the compilation fails for any reason
            s_parser = CodeCompiler.GenerateAssembly<EveNotificationTextParser>(referenceAssemblies, result.Result) ??
                       new InternalEveNotificationTextParser();

            // Reset query pending flag
            // after we compiled the parser
            s_queryPending = false;

            s_cachedUntil = DateTime.UtcNow.AddHours(12);

            EveMonClient.Trace();

            // Notify the subscribers
            NotificationTextParserUpdated?.ThreadSafeInvoke(null, EventArgs.Empty);
        }