public ConditionMethodExpression(string name, ConditionExpressionCollection parameters) { _name = name; _parameters = parameters; _methodInfo = ConditionMethodFactory.CreateConditionMethod(_name); if (_methodInfo == null) { Internal.InternalLogger.Error("Condition method: '{0}' not found", name); throw new ArgumentException("Condition method not found: '" + name + "'"); } ParameterInfo[] formalParameters = _methodInfo.GetParameters(); if (formalParameters.Length >= 0) { _acceptsLogEvent = (formalParameters[0].ParameterType == typeof(LogEventInfo)); } else { _acceptsLogEvent = false; } int actualParameterCount = _parameters.Count; if (_acceptsLogEvent) { actualParameterCount++; } if (formalParameters.Length != actualParameterCount) { Internal.InternalLogger.Error("Condition method: '{0}' expects {1} parameters. Passed {2}", name, formalParameters.Length, actualParameterCount); throw new ConditionParseException(String.Format("Condition method: '{0}' expects {1} parameters. Passed {2}", name, formalParameters.Length, actualParameterCount)); } }
public ConditionMethodExpression(string name, ConditionExpressionCollection parameters) { _name = name; _parameters = parameters; _methodInfo = ConditionMethodFactory.CreateConditionMethod(_name); if (_methodInfo == null) { Internal.InternalLogger.Error("Condition method: '{0}' not found", name); throw new ArgumentException("Condition method not found: '" + name + "'"); } ParameterInfo[] formalParameters = _methodInfo.GetParameters(); if (formalParameters.Length >= 0) { _acceptsLogEvent = (formalParameters[0].ParameterType == typeof(LogEventInfo)); } else { _acceptsLogEvent = false; } int actualParameterCount = _parameters.Count; if (_acceptsLogEvent) actualParameterCount++; if (formalParameters.Length != actualParameterCount) { Internal.InternalLogger.Error("Condition method: '{0}' expects {1} parameters. Passed {2}", name, formalParameters.Length, actualParameterCount); throw new ConditionParseException(String.Format("Condition method: '{0}' expects {1} parameters. Passed {2}", name, formalParameters.Length, actualParameterCount)); } }
/// <summary> /// Adds the elements of another ConditionExpressionCollection to the end of this ConditionExpressionCollection. /// </summary> /// <param name="items"> /// The ConditionExpressionCollection whose elements are to be added to the end of this ConditionExpressionCollection. /// </param> public virtual void AddRange(ConditionExpressionCollection items) { foreach (ConditionExpression item in items) { this.List.Add(item); } }
private ConditionMethodExpression ParsePredicate(string functionName) { ConditionExpressionCollection par = new ConditionExpressionCollection(); while (!tokenizer.IsEOF() && tokenizer.TokenType != ConditionTokenType.RightParen) { par.Add(ParseExpression()); if (tokenizer.TokenType != ConditionTokenType.Comma) break; tokenizer.GetNextToken(); } tokenizer.Expect(ConditionTokenType.RightParen); return new ConditionMethodExpression(functionName, par); }
private ConditionMethodExpression ParsePredicate(string functionName) { ConditionExpressionCollection par = new ConditionExpressionCollection(); while (!tokenizer.IsEOF() && tokenizer.TokenType != ConditionTokenType.RightParen) { par.Add(ParseExpression()); if (tokenizer.TokenType != ConditionTokenType.Comma) { break; } tokenizer.GetNextToken(); } tokenizer.Expect(ConditionTokenType.RightParen); return(new ConditionMethodExpression(functionName, par)); }
/// <summary> /// Initializes a new instance of the ConditionExpressionCollection class, containing elements /// copied from another instance of ConditionExpressionCollection /// </summary> /// <param name="items"> /// The ConditionExpressionCollection whose elements are to be added to the new ConditionExpressionCollection. /// </param> public ConditionExpressionCollection(ConditionExpressionCollection items) { this.AddRange(items); }
/// <summary> /// /// </summary> /// <param name="collection"></param> public Enumerator(ConditionExpressionCollection collection) { this.wrapped = ((System.Collections.CollectionBase)collection).GetEnumerator(); }