/// <summary>
        /// Gets the channel's keywords.
        /// </summary>
        /// <param name="channelElement">The channel element from the RSS feed.</param>
        private void GetKeywords(XmlNode channelElement)
        {
            string keywords       = GetStringFromChildElement("keywords", channelElement);
            string iTunesKeywords = GetStringFromChildElement("itunes:keywords", channelElement);
            string iTunesKeyword  = GetStringFromChildElement("itunes:keyword", channelElement);

            if (string.IsNullOrEmpty(keywords) && string.IsNullOrEmpty(iTunesKeywords) && string.IsNullOrEmpty(iTunesKeyword))
            {
                ParseErrors.Add("No keywords found");
                return;
            }

            // Merge and deduplicate each variable in turn
            _keywords = new Collection <string>();
            MergeAndDeduplicateKeywords(keywords);
            MergeAndDeduplicateKeywords(iTunesKeywords);
            MergeAndDeduplicateKeywords(iTunesKeyword);

            var sb = new StringBuilder();

            foreach (string keyword in _keywords)
            {
                sb.Append(keyword + ", ");
            }

            // remove final comma
            sb.Remove(sb.Length - 2, 2);

            _channel.Keywords = sb.ToString();
        }
Exemple #2
0
        private void UpdateRange()
        {
            FirstLine = Int32.MaxValue;
            LastLine  = 0;

            var enumerator = Expressions.GetEnumerator();

            while (enumerator.MoveNext())
            {
                if (enumerator.Current.Location.Start.Line < FirstLine)
                {
                    FirstLine = enumerator.Current.Location.Start.Line;
                }
                if (enumerator.Current.Location.End.Line > LastLine)
                {
                    LastLine = enumerator.Current.Location.End.Line;
                }
            }

            enumerator = ParseErrors.GetEnumerator();
            while (enumerator.MoveNext())
            {
                if (enumerator.Current.Location.Start.Line < FirstLine)
                {
                    FirstLine = enumerator.Current.Location.Start.Line;
                }
                if (enumerator.Current.Location.End.Line > LastLine)
                {
                    LastLine = enumerator.Current.Location.End.Line;
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// Records that the value of the element with the supplied name could not be
        /// converted to the supplied data type.
        /// </summary>
        /// <param name="dataType">Name of the data type.</param>
        /// <param name="elementName">Name of the element.</param>
        /// <param name="elementValue">Value of the element.</param>
        private void LogInvalidElementValue(string dataType, string elementName, string elementValue)
        {
            string error = "Invalid value for data type '" + dataType
                           + "'. Element name '" + elementName + "'. Element value '" + elementValue + "'.";

            ParseErrors.Add(error);
        }
        public IReference GetReferencedObject(OpenApiReference reference)
        {
            IReference returnValue = null;

            referenceStore.TryGetValue(reference.ToString(), out returnValue);

            if (returnValue == null)
            {
                if (previousPointers.Contains(reference.ToString()))
                {
                    return(null); // Return reference object?
                }
                previousPointers.Push(reference.ToString());
                returnValue = this.referenceService.LoadReference(reference);
                previousPointers.Pop();
                if (returnValue != null)
                {
                    returnValue.Pointer = reference;
                    referenceStore.Add(reference.ToString(), returnValue);
                }
                else
                {
                    ParseErrors.Add(new OpenApiError(this.GetLocation(), $"Cannot resolve $ref {reference.ToString()}"));
                }
            }

            return(returnValue);
        }
 public ParseTree()
     : base(new Token(), "ParseTree")
 {
     Token.Type = TokenType.Start;
     Token.Text = "Root";
     Errors     = new ParseErrors();
 }
Exemple #6
0
 public ParseTree() : base(new Token(), "ParseTree")
 {
     base.Token.Type = OpenExcel.Common.FormulaParser.TokenType.Start;
     base.Token.Text = "Root";
     this.Skipped    = new List <Token>();
     this.Errors     = new ParseErrors();
 }
        /// <summary>
        /// Gets the channel's RSS URL.
        /// </summary>
        /// <param name="channelElement">The channel element from the RSS feed.</param>
        private void GetRssUrl(XmlNode channelElement)
        {
            _channel.RssUrl = GetStringFromChildElementAttribute("atom:link", "href", channelElement);
            if (string.IsNullOrEmpty(_channel.Link))
            {
                ParseErrors.Add("No RSS URL found");
            }

            if (RemoveParsedContent)
            {
                // We don't use the values of the rel or type attributes but if they're the only remaining
                // attributes them remove the atom:link element because we've used all its useful content.
                XmlNode atomLink            = channelElement.SelectSingleNode("atom:link", NamespaceManager);
                XmlAttributeCollection atts = atomLink.Attributes;
                if (atts.Count == 2)
                {
                    if (atts[0].Name == "rel" || atts[1].Name == "rel")
                    {
                        if (atts[0].Name == "type" || atts[1].Name == "type")
                        {
                            channelElement.RemoveChild(atomLink);
                            SaveUnparsedContent();
                        }
                    }
                }
            }
        }
Exemple #8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="str"></param>
        /// <param name="parseErrors"></param>
        /// <returns></returns>
        private object evaluateExpr(string str, out ParseErrors parseErrors)
        {
            var tree = parser.Parse(str);

            parseErrors = tree.Errors;
            return(tree.Eval(null));
        }
        private void ParseSingleWarehouse(string materialId, string materialName, string warehouse)
        {
            var stock = warehouse.Split(',');

            if (stock.Length != 2)
            {
                ParseErrors.Add($"ParseError line {_lineNumber} malformed warehouse stock (not in format [Name,Quantity]");
                return;
            }

            var warehouseId = stock[0];
            int quantity;

            if (!int.TryParse(stock[1], out quantity))
            {
                ParseErrors.Add($"ParseError line {_lineNumber} quantity is not a number");
                return;
            }

            if (quantity < 1)
            {
                ParseErrors.Add($"ParseError line {_lineNumber} quantity cannot be zero");
                return;
            }

            AddStock(warehouseId, materialId, materialName, quantity);
        }
 /// <summary>
 /// Gets the channel's title.
 /// </summary>
 /// <param name="channelElement">The channel element from the RSS feed.</param>
 private void GetTitle(XmlNode channelElement)
 {
     _channel.Title = GetStringFromChildElement("title", channelElement);
     if (string.IsNullOrEmpty(_channel.Title))
     {
         ParseErrors.Add("No title found");
     }
 }
 /// <summary>
 /// Gets the channel's language.
 /// </summary>
 /// <param name="channelElement">The channel element from the RSS feed.</param>
 private void GetLanguage(XmlNode channelElement)
 {
     _channel.Language = GetStringFromChildElement("language", channelElement);
     if (string.IsNullOrEmpty(_channel.Language))
     {
         ParseErrors.Add("No language found");
     }
 }
 /// <summary>
 /// Gets the channel's copyright statement.
 /// </summary>
 /// <param name="channelElement">The channel element from the RSS feed.</param>
 private void GetCopyright(XmlNode channelElement)
 {
     _channel.Copyright = GetStringFromChildElement("copyright", channelElement);
     if (string.IsNullOrEmpty(_channel.Copyright))
     {
         ParseErrors.Add("No copyright found");
     }
 }
 /// <summary>
 /// Gets the date the RSS feed was last built.
 /// </summary>
 /// <param name="channelElement">The channel element from the RSS feed.</param>
 private void GetLastBuildDate(XmlNode channelElement)
 {
     _channel.LastBuildDate = GetDateTimeFromChildElement("lastBuildDate", channelElement);
     if (_channel.LastBuildDate == DateTime.MinValue)
     {
         ParseErrors.Add("No last build date found");
     }
 }
Exemple #14
0
 private void Reset()
 {
     ParseErrors.Clear();
     Parameters.Clear();
     ScriptName  = "";
     Description = "";
     JSON        = "";
 }
 /// <summary>
 /// Gets the channel's author.
 /// </summary>
 /// <param name="channelElement">The channel element from the RSS feed.</param>
 private void GetAuthor(XmlNode channelElement)
 {
     _channel.Author = GetStringFromChildElement("itunes:author", channelElement);
     if (string.IsNullOrEmpty(_channel.Author))
     {
         ParseErrors.Add("No author found");
     }
 }
 public ParseTree(Solver solver) : base(new Token(), "ParseTree")
 {
     Solver     = solver;
     Token.Type = TokenType.Start;
     Token.Text = "Root";
     Skipped    = new List <Token>();
     Errors     = new ParseErrors();
 }
 /// <summary>
 /// Gets the channel's link.
 /// </summary>
 /// <param name="channelElement">The channel element from the RSS feed.</param>
 private void GetLink(XmlNode channelElement)
 {
     _channel.Link = GetStringFromChildElement("link", channelElement);
     if (string.IsNullOrEmpty(_channel.Link))
     {
         ParseErrors.Add("No link found");
     }
 }
        public void When_given_a_positional_argument_then_TryParse_should_return_argument()
        {
            var parser      = new ServiceAnnotationArgumentParser();
            var parseErrors = new ParseErrors();

            // Act
            parser.TryParse("service-name", out var result, ref parseErrors);

            // Assert
            result !["0"].Should().Be("service-name");
Exemple #19
0
 private void ClearParseErrors()
 {
     for (int i = ParseErrors.Count - 1; i >= 0; i--)
     {
         var errInfo = ParseErrors[i];
         if (errInfo.ErrorLevel != ErrorLevel.Validation)
         {
             ParseErrors.RemoveAt(i);
         }
     }
 }
Exemple #20
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public InterpreterAction checkUnidStashItem(ACDItem item)
        {
            fillDic(item);

            InterpreterAction action = InterpreterAction.NULL;

            string validRule = "";

            ArrayList rules;

            rules = unidKeepRuleSet;

            foreach (string str in rules)
            {
                ParseErrors parseErrors = null;

                // default configuration for positive rules is pickup and keep
                InterpreterAction tempAction = InterpreterAction.KEEP;


                string[] strings = str.Split(new string[] { assign }, StringSplitOptions.None);
                if (strings.Count() > 1)
                {
                    tempAction = getInterpreterAction(strings[1]);
                }

                try
                {
                    if (evaluate(strings[0], out parseErrors))
                    {
                        validRule = str;
                        action    = tempAction;
                        if (parseErrors.Count > 0)
                        {
                            logOut("Have errors with out a catch!"
                                   + SEP + "last use rule: " + str
                                   + SEP + getParseErrors(parseErrors)
                                   + SEP + getFullItem(), tempAction, LogType.DEBUG);
                        }
                        break;
                    }
                } catch (Exception e)
                {
                    logOut(e.Message
                           + SEP + "last use rule: " + str
                           + SEP + getParseErrors(parseErrors)
                           + SEP + getFullItem(), tempAction, LogType.ERROR);
                }
            }

            //logOut(ItemEvaluationType.Salvage, validRule, action);

            return(action);
        }
        /// <summary>
        /// Gets the channel's description.
        /// </summary>
        /// <param name="channelElement">The channel element from the RSS feed.</param>
        private void GetDescription(XmlNode channelElement)
        {
            string description   = GetStringFromChildElement("description", channelElement);
            string iTunesSummary = GetStringFromChildElement("itunes:summary", channelElement);

            _channel.Description = description.Length > iTunesSummary.Length ? description : iTunesSummary;
            if (string.IsNullOrEmpty(description) && string.IsNullOrEmpty(iTunesSummary))
            {
                ParseErrors.Add("No description found");
            }
        }
        public void When_parsing_a_invalid_string_then_TryParse_should_return_true()
        {
            var parser      = new ServiceAnnotationArgumentParser();
            var parseErrors = new ParseErrors();

            // Act
            var result = parser.TryParse("'service-name", out _, ref parseErrors);

            // Assert
            result.Should().BeFalse();
        }
        private static bool TryGetServiceName(IReadOnlyDictionary <string, string> arguments,
                                              [NotNullWhen(true)] out string?serviceName,
                                              ref ParseErrors parseErrors)
        {
            if (!TryGetByNameOrPosition(0, "name", arguments, out serviceName))
            {
                parseErrors.Add("Required argument 'service name' defined by the position '0' or the name 'name' is invalid. "
                                + $"Got '{serviceName ?? "<null>"}'.");
            }

            return(!string.IsNullOrWhiteSpace(serviceName));
        }
Exemple #24
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="parseErrors"></param>
        /// <returns></returns>
        private string getParseErrors(ParseErrors parseErrors)
        {
            if (parseErrors == null)
            {
                return(null);
            }
            string result = "tree.Errors = " + parseErrors.Count() + SEP;

            foreach (ParseError parseError in parseErrors)
            {
                result += "ParseError( " + parseError.Code + "): " + parseError.Message + SEP;
            }
            return(result);
        }
        /// <summary>
        /// Gets the image for the episode.
        /// </summary>
        /// <param name="episode">The episode being parsed.</param>
        private void GetImage(PodcastEpisode episode)
        {
            string imageUrl = GetStringFromChildElementAttribute("itunes:image", "href", NodeToParse);

            episode.Image = new CachedImage();
            if (string.IsNullOrEmpty(imageUrl))
            {
                ParseErrors.Add("No image found");
            }
            else
            {
                episode.Image.RemoteUrl = imageUrl;
            }
        }
 private void plotDataSet(object sender, DataSetSelectedEventArgs e)
 {
     try
     {
         var dataRepository = _dataRepositoryMapper.ConvertImportDataSet(_dataSource.ImportedDataSetAt(e.Index));
         _confirmationPresenter.PlotDataRepository(dataRepository.DataRepository);
     }
     catch (TimeNotStrictlyMonotoneException timeNonMonotoneException)
     {
         var errors = new ParseErrors();
         errors.Add(_dataSource.DataSetAt(e.Index), new NonMonotonicalTimeParseErrorDescription(Error.ErrorWhenPlottingDataRepository(e.Index, timeNonMonotoneException.Message)));
         _importerDataPresenter.SetTabMarks(errors);
         _confirmationPresenter.SetViewingStateToError(timeNonMonotoneException.Message);
     }
 }
Exemple #27
0
		// ----------------------------------------------------------------------------------------

		/// <summary>
		/// validates that the specified int has a valid value (not 0)
		/// </summary>
		/// <param name="value">the value to be validated against 0</param>
		/// <param name="expression">a lambda expression of the type s => s.PropertyName</param>
		protected void Validate_Int32(int value, Expression<Func<TStepRow, int>> expression)
		{
			if (0 != value) return;

			var sPropertyName = string.Empty;
			var memberExpression = expression.Body as MemberExpression;

			if (memberExpression != null &&
				memberExpression.Member.MemberType == MemberTypes.Property)
			{
				sPropertyName = memberExpression.Member.Name;
			}
			var sParseError = string.Format(Resources.StepRow_ValidationFieldNotSet, sPropertyName, typeof(int));
			ParseErrors.Add(sParseError);
		}
Exemple #28
0
		/// <summary>
		/// validates that the specified Date has a valid value (not DateTime.MinValue)
		/// </summary>
		/// <param name="value">the value to be validated against DateTime.MinValue</param>
		/// <param name="expression">a lambda expression of the type s => s.PropertyName</param>
		protected void Validate_DateTime(DateTime value, Expression<Func<TStepRow, DateTime>> expression)
		{
			if (DateTime.MinValue != value) return;

			var sPropertyName = string.Empty;
			var memberExpression = expression.Body as MemberExpression;

			if (memberExpression != null &&
				memberExpression.Member.MemberType == MemberTypes.Property)
			{
				sPropertyName = memberExpression.Member.Name;
			}
			var sParseError = string.Format("The {1} for '{0}' was not set.", sPropertyName, typeof(DateTime));
			ParseErrors.Add(sParseError);
		}
Exemple #29
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="str"></param>
        /// <param name="item"></param>
        /// <param name="parseErrors"></param>
        /// <returns></returns>
        private bool evaluate(string str, out ParseErrors parseErrors)
        {
            bool result = false;

            ItemRules.Core.ParseTree tree = parser.Parse(str);
            parseErrors = tree.Errors;
            object obj = tree.Eval(null);

            if (!Boolean.TryParse(obj.ToString(), out result))
            {
                tree.Errors.Add(new ParseError("TryParse Boolean failed!", 101, 0, 0, 0, 0));
            }

            return(result);
        }
Exemple #30
0
		/// <summary>
		/// validates that the specified Date has a valid value (not DateTime.MinValue)
		/// </summary>
		/// <param name="value">the value to be validated against DateTime.MinValue</param>
		/// <param name="expression">a lambda expression of the type s => s.PropertyName</param>
		protected void Validate_String(string value, Expression<Func<TStepRow, string>> expression)
		{
			if (!string.IsNullOrWhiteSpace(value)) return;

			var sPropertyName = string.Empty;
			var memberExpression = expression.Body as MemberExpression;

			if (memberExpression != null &&
				memberExpression.Member.MemberType == MemberTypes.Property)
			{
				sPropertyName = memberExpression.Member.Name;
			}
			var sParseError = string.Format("The {1} for '{0}' was not set.", sPropertyName, typeof(string));
			ParseErrors.Add(sParseError);
		}
Exemple #31
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="str"></param>
        /// <param name="item"></param>
        /// <param name="parseErrors"></param>
        /// <returns></returns>
        private bool evaluate(string str, out ParseErrors parseErrors)
        {
            bool result = false;
            ItemRules.Core.ParseTree tree = parser.Parse(str);
            parseErrors = tree.Errors;
            object obj = tree.Eval(null);

            if (!Boolean.TryParse(obj.ToString(), out result))
                tree.Errors.Add(new ParseError("TryParse Boolean failed!", 101, 0, 0, 0, 0));

            return result;
        }
		public CommentFailedToParseException(ParseErrors errors, string description)
		{
			_errors = errors;
			_description = description;
		}
Exemple #33
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="str"></param>
 /// <param name="parseErrors"></param>
 /// <returns></returns>
 private object evaluateExpr(string str, out ParseErrors parseErrors)
 {
     var tree=parser.Parse(str);
         parseErrors=tree.Errors;
         return tree.Eval(null);
 }
Exemple #34
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="str"></param>
 /// <param name="parseErrors"></param>
 /// <returns></returns>
 private object evaluateExpr(string str, out ParseErrors parseErrors)
 {
     ItemRules.Core.ParseTree tree = parser.Parse(str);
     parseErrors = tree.Errors;
     return tree.Eval(null);
 }
Exemple #35
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="parseErrors"></param>
 /// <returns></returns>
 private string getParseErrors(ParseErrors parseErrors)
 {
     if (parseErrors == null) return null;
     string result = "tree.Errors = " + parseErrors.Count() + SEP;
     foreach (ParseError parseError in parseErrors)
         result += "ParseError( " + parseError.Code + "): " + parseError.Message + SEP;
     return result;
 }