Example #1
0
 internal ExpressionParser(ErrorContext errorContext)
 {
     m_errorContext = errorContext;
 }
Example #2
0
 internal virtual void Parse(string name, List <string> defaultValues, string type, string nullable, object prompt, string promptUser, string allowBlank, string multiValue, string usedInQuery, bool hidden, ErrorContext errorContext, CultureInfo language)
 {
     if (name == null || name.Length == 0)
     {
         throw new MissingElementException("Name");
     }
     m_name = name;
     if (type == null || type.Length == 0)
     {
         m_dataType = DataType.String;
     }
     else
     {
         try
         {
             m_dataType = (DataType)Enum.Parse(typeof(DataType), type, ignoreCase: true);
         }
         catch (ArgumentException)
         {
             if (errorContext == null)
             {
                 throw new ElementTypeMismatchException("Type");
             }
             errorContext.Register(ProcessingErrorCode.rsParameterPropertyTypeMismatch, Severity.Error, ObjectType.Parameter, name, "DataType");
         }
     }
     if (nullable == null || nullable.Length == 0)
     {
         m_nullable = false;
     }
     else
     {
         try
         {
             m_nullable = bool.Parse(nullable);
         }
         catch (FormatException)
         {
             if (errorContext == null)
             {
                 throw new ElementTypeMismatchException("Nullable");
             }
             errorContext.Register(ProcessingErrorCode.rsParameterPropertyTypeMismatch, Severity.Error, ParameterObjectType, name, "Nullable");
         }
     }
     if (allowBlank == null || allowBlank.Length == 0)
     {
         m_allowBlank = false;
     }
     else
     {
         try
         {
             m_allowBlank = bool.Parse(allowBlank);
         }
         catch (FormatException)
         {
             if (errorContext == null)
             {
                 throw new ElementTypeMismatchException("AllowBlank");
             }
             errorContext.Register(ProcessingErrorCode.rsParameterPropertyTypeMismatch, Severity.Error, ParameterObjectType, name, "AllowBlank");
         }
     }
     if (multiValue == null || multiValue.Length == 0 || m_dataType == DataType.Boolean)
     {
         m_multiValue = false;
     }
     else
     {
         try
         {
             m_multiValue = bool.Parse(multiValue);
         }
         catch (FormatException)
         {
             if (errorContext == null)
             {
                 throw new ElementTypeMismatchException("MultiValue");
             }
             errorContext.Register(ProcessingErrorCode.rsParameterPropertyTypeMismatch, Severity.Error, ParameterObjectType, name, "MultiValue");
         }
     }
     if (promptUser == null || promptUser == string.Empty)
     {
         if (prompt == null)
         {
             m_promptUser = false;
         }
         else
         {
             m_promptUser = true;
         }
     }
     else
     {
         try
         {
             m_promptUser = bool.Parse(promptUser);
         }
         catch (FormatException)
         {
             throw new ElementTypeMismatchException("PromptUser");
         }
     }
     if (defaultValues == null)
     {
         m_defaultValues = null;
     }
     else
     {
         int count = defaultValues.Count;
         m_defaultValues = new object[count];
         for (int i = 0; i < count; i++)
         {
             if (!CastFromString(defaultValues[i], out object newValue, m_dataType, language))
             {
                 if (errorContext == null)
                 {
                     throw new ReportParameterTypeMismatchException(name);
                 }
                 errorContext.Register(ProcessingErrorCode.rsParameterPropertyTypeMismatch, Severity.Error, ParameterObjectType, name, "DefaultValue");
             }
Example #3
0
 internal void ValidateValue(object newValue, ErrorContext errorContext, ObjectType parameterType, string parameterValueProperty)
 {
     ValidateValueForNull(newValue, Nullable, errorContext, parameterType, Name, parameterValueProperty);
     ValidateValueForBlank(newValue, errorContext, parameterValueProperty);
 }
        internal void Parse(string name, List <string> defaultValues, string type, string nullable, string prompt, string promptUser, string allowBlank, string multiValue, string usedInQuery, bool hidden, ErrorContext errorContext, CultureInfo language)
        {
            base.Parse(name, defaultValues, type, nullable, prompt, promptUser, allowBlank, multiValue, usedInQuery, hidden, errorContext, language);
            if (hidden)
            {
                m_prompt = "";
            }
            else if (prompt == null)
            {
                m_prompt = name + ":";
            }
            else
            {
                m_prompt = prompt;
            }
            if (m_validValuesValueExpressions == null || DataType.Boolean == base.DataType)
            {
                return;
            }
            int num = m_validValuesValueExpressions.Count - 1;

            while (true)
            {
                if (num < 0)
                {
                    return;
                }
                ExpressionInfo expressionInfo = m_validValuesValueExpressions[num];
                if (expressionInfo == null && base.MultiValue)
                {
                    m_validValuesValueExpressions.RemoveAt(num);
                }
                else if (expressionInfo != null && ExpressionInfo.Types.Constant == expressionInfo.Type)
                {
                    if (!ParameterBase.CastFromString(expressionInfo.Value, out object newValue, base.DataType, language))
                    {
                        if (errorContext == null)
                        {
                            break;
                        }
                        errorContext.Register(ProcessingErrorCode.rsParameterPropertyTypeMismatch, Severity.Error, base.ParameterObjectType, name, "ValidValue");
                    }
                    else
                    {
                        ValidateValue(newValue, errorContext, base.ParameterObjectType, "ValidValue");
                    }
                }
                num--;
            }
 bool IParameterDef.ValidateValueForBlank(object newValue, ErrorContext errorContext, string parameterValueProperty)
 {
     return(ValidateValueForBlank(newValue, errorContext, parameterValueProperty));
 }
 bool IParameterDef.ValidateValueForNull(object newValue, ErrorContext errorContext, string parameterValueProperty)
 {
     return(ParameterBase.ValidateValueForNull(newValue, base.Nullable, errorContext, ObjectType.ReportParameter, base.Name, parameterValueProperty));
 }