public 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)
            {
                this.m_prompt = "";
            }
            else if (prompt == null)
            {
                this.m_prompt = name + ":";
            }
            else
            {
                this.m_prompt = prompt;
            }
            if (this.m_validValuesValueExpressions == null)
            {
                return;
            }
            if (DataType.Boolean == base.DataType)
            {
                return;
            }
            int num = this.m_validValuesValueExpressions.Count - 1;

            while (true)
            {
                if (num >= 0)
                {
                    ExpressionInfo expressionInfo = this.m_validValuesValueExpressions[num];
                    if (expressionInfo == null && base.MultiValue)
                    {
                        this.m_validValuesValueExpressions.RemoveAt(num);
                    }
                    else if (expressionInfo != null && ExpressionInfo.Types.Constant == expressionInfo.Type)
                    {
                        object newValue = default(object);
                        if (!ParameterBase.CastFromString(expressionInfo.Value, out newValue, base.DataType, language))
                        {
                            if (errorContext == null)
                            {
                                break;
                            }
                            errorContext.Register(ProcessingErrorCode.rsParameterPropertyTypeMismatch, Severity.Error, base.ParameterObjectType, name, "ValidValue");
                        }
                        else
                        {
                            base.ValidateValue(newValue, errorContext, base.ParameterObjectType, "ValidValue");
                        }
                    }
                    num--;
                    continue;
                }
                return;
            }
            throw new ReportParameterTypeMismatchException(name);
        }
예제 #2
0
        public void AddValidValue(string paramValue, string paramLabel, ErrorContext errorContext, CultureInfo language)
        {
            object paramValue2 = default(object);

            if (!ParameterBase.CastFromString(paramValue, out paramValue2, base.DataType, language))
            {
                if (errorContext != null)
                {
                    errorContext.Register(ProcessingErrorCode.rsParameterPropertyTypeMismatch, Severity.Error, ObjectType.ReportParameter, base.Name, "ValidValue");
                    return;
                }
                throw new ReportParameterTypeMismatchException(base.Name);
            }
            this.AddValidValueExplicit(paramValue2, paramLabel);
        }
예제 #3
0
 public void Parse(string name, List <string> defaultValues, string type, string nullable, string prompt, bool promptIsExpr, string promptUser, string allowBlank, string multiValue, ValidValueList validValues, string usedInQuery, bool hidden, ErrorContext errorContext, CultureInfo language)
 {
     base.Parse(name, defaultValues, type, nullable, prompt, promptUser, allowBlank, multiValue, usedInQuery, hidden, errorContext, language);
     if (hidden)
     {
         this.m_prompt = "";
     }
     else if (prompt == null)
     {
         this.m_prompt = name + ":";
     }
     else
     {
         this.m_prompt = prompt;
     }
     this.DynamicPrompt = promptIsExpr;
     if (validValues != null)
     {
         int count = validValues.Count;
         for (int i = 0; i < count; i++)
         {
             object obj = default(object);
             if (!ParameterBase.CastFromString(validValues[i].StringValue, out obj, base.DataType, language))
             {
                 if (errorContext != null)
                 {
                     errorContext.Register(ProcessingErrorCode.rsParameterPropertyTypeMismatch, Severity.Error, ObjectType.ReportParameter, name, "ValidValue");
                     continue;
                 }
                 throw new ReportParameterTypeMismatchException(name);
             }
             validValues[i].Value = obj;
             base.ValidateValue(obj, errorContext, base.ParameterObjectType, "ValidValue");
         }
         this.m_validValues = validValues;
     }
 }
예제 #4
0
        public static bool Cast(object oldValue, DataType oldType, out object newValue, DataType newType, CultureInfo language)
        {
            if (oldValue == null)
            {
                newValue = null;
                return(true);
            }
            switch (oldType)
            {
            case DataType.Object:
                newValue = oldValue;
                return(true);

            case DataType.String:
                return(ParameterBase.CastFromString((string)oldValue, out newValue, newType, language));

            case DataType.Boolean:
                return(ParameterBase.CastFromBoolean((bool)oldValue, out newValue, newType, language));

            case DataType.Float:
                return(ParameterBase.CastFromDouble((double)oldValue, out newValue, newType, language));

            case DataType.DateTime:
                if (oldValue is DateTimeOffset)
                {
                    return(ParameterBase.CastFromDateTimeOffset((DateTimeOffset)oldValue, out newValue, newType, language));
                }
                return(ParameterBase.CastFromDateTime((DateTime)oldValue, out newValue, newType, language));

            case DataType.Integer:
                return(ParameterBase.CastFromInteger((int)oldValue, out newValue, newType, language));

            default:
                throw new InternalCatalogException("Parameter type is not one of the supported types in Cast");
            }
        }
예제 #5
0
        public void Parse(string name, string type, string nullable, string allowBlank, string multiValue, string usedInQuery, string state, string dynamicPrompt, string prompt, string promptUser, ParameterInfoCollection dependencies, string dynamicValidValues, ValidValueList validValues, string dynamicDefaultValue, List <string> defaultValues, List <string> values, string[] labels, CultureInfo language)
        {
            bool hidden       = prompt != null && 0 == prompt.Length;
            bool promptIsExpr = false;

            if (dynamicPrompt != null)
            {
                promptIsExpr = bool.Parse(dynamicPrompt);
            }
            this.Parse(name, defaultValues, type, nullable, prompt, promptIsExpr, promptUser, allowBlank, multiValue, validValues, usedInQuery, hidden, null, language);
            if (state != null)
            {
                this.State = (ReportParameterState)Enum.Parse(typeof(ReportParameterState), state);
            }
            this.DependencyList = dependencies;
            if (dynamicValidValues != null)
            {
                this.DynamicValidValues = bool.Parse(dynamicValidValues);
            }
            if (dynamicDefaultValue != null)
            {
                this.DynamicDefaultValue = bool.Parse(dynamicDefaultValue);
            }
            if (values != null)
            {
                this.Values = new object[values.Count];
                for (int i = 0; i < values.Count; i++)
                {
                    if (!ParameterBase.CastFromString(values[i], out this.Values[i], base.DataType, language))
                    {
                        throw new InternalCatalogException("Can not cast report parameter to correct type when reading from XML");
                    }
                }
            }
            this.Labels = labels;
        }
예제 #6
0
 public 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)
     {
         this.m_name = name;
         if (type != null && type.Length != 0)
         {
             try
             {
                 this.m_dataType = (DataType)Enum.Parse(typeof(DataType), type, true);
             }
             catch (ArgumentException)
             {
                 if (errorContext != null)
                 {
                     errorContext.Register(ProcessingErrorCode.rsParameterPropertyTypeMismatch, Severity.Error, ObjectType.Parameter, name, "DataType");
                     goto end_IL_0050;
                 }
                 throw new ElementTypeMismatchException("Type");
                 end_IL_0050 :;
             }
         }
         else
         {
             this.m_dataType = DataType.String;
         }
         if (nullable != null && nullable.Length != 0)
         {
             try
             {
                 this.m_nullable = bool.Parse(nullable);
             }
             catch (FormatException)
             {
                 if (errorContext != null)
                 {
                     errorContext.Register(ProcessingErrorCode.rsParameterPropertyTypeMismatch, Severity.Error, this.ParameterObjectType, name, "Nullable");
                     goto end_IL_00a5;
                 }
                 throw new ElementTypeMismatchException("Nullable");
                 end_IL_00a5 :;
             }
         }
         else
         {
             this.m_nullable = false;
         }
         if (allowBlank != null && allowBlank.Length != 0)
         {
             try
             {
                 this.m_allowBlank = bool.Parse(allowBlank);
             }
             catch (FormatException)
             {
                 if (errorContext != null)
                 {
                     errorContext.Register(ProcessingErrorCode.rsParameterPropertyTypeMismatch, Severity.Error, this.ParameterObjectType, name, "AllowBlank");
                     goto end_IL_00fe;
                 }
                 throw new ElementTypeMismatchException("AllowBlank");
                 end_IL_00fe :;
             }
         }
         else
         {
             this.m_allowBlank = false;
         }
         if (multiValue != null && multiValue.Length != 0 && this.m_dataType != DataType.Boolean)
         {
             try
             {
                 this.m_multiValue = bool.Parse(multiValue);
             }
             catch (FormatException)
             {
                 if (errorContext != null)
                 {
                     errorContext.Register(ProcessingErrorCode.rsParameterPropertyTypeMismatch, Severity.Error, this.ParameterObjectType, name, "MultiValue");
                     goto end_IL_0160;
                 }
                 throw new ElementTypeMismatchException("MultiValue");
                 end_IL_0160 :;
             }
         }
         else
         {
             this.m_multiValue = false;
         }
         if (promptUser != null && !(promptUser == string.Empty))
         {
             try
             {
                 this.m_promptUser = bool.Parse(promptUser);
             }
             catch (FormatException)
             {
                 throw new ElementTypeMismatchException("PromptUser");
             }
         }
         else if (prompt == null)
         {
             this.m_promptUser = false;
         }
         else
         {
             this.m_promptUser = true;
         }
         if (defaultValues == null)
         {
             this.m_defaultValues = null;
         }
         else
         {
             int count = defaultValues.Count;
             this.m_defaultValues = new object[count];
             object obj = default(object);
             for (int i = 0; i < count; this.m_defaultValues[i] = obj, i++)
             {
                 if (!ParameterBase.CastFromString(defaultValues[i], out obj, this.m_dataType, language))
                 {
                     if (errorContext != null)
                     {
                         errorContext.Register(ProcessingErrorCode.rsParameterPropertyTypeMismatch, Severity.Error, this.ParameterObjectType, name, "DefaultValue");
                         continue;
                     }
                     throw new ReportParameterTypeMismatchException(name);
                 }
                 this.ValidateValue(obj, errorContext, this.ParameterObjectType, "DefaultValue");
             }
         }
         this.m_usedInQuery = true;
         if (usedInQuery != null && usedInQuery.Length != 0)
         {
             try
             {
                 this.m_usedInQueryAsDefined = (UsedInQueryType)Enum.Parse(typeof(UsedInQueryType), usedInQuery, true);
             }
             catch (ArgumentException)
             {
                 if (errorContext != null)
                 {
                     errorContext.Register(ProcessingErrorCode.rsParameterPropertyTypeMismatch, Severity.Error, this.ParameterObjectType, name, "MultiValue");
                     goto end_IL_02a3;
                 }
                 throw new ElementTypeMismatchException("UsedInQuery");
                 end_IL_02a3 :;
             }
             if (this.m_usedInQueryAsDefined == UsedInQueryType.False)
             {
                 this.m_usedInQuery = false;
             }
             else if (this.m_usedInQueryAsDefined == UsedInQueryType.True)
             {
                 this.m_usedInQuery = true;
             }
         }
         else
         {
             this.m_usedInQueryAsDefined = UsedInQueryType.Auto;
         }
         if (usedInQuery != null && usedInQuery.Length != 0)
         {
             try
             {
                 this.m_usedInQueryAsDefined = (UsedInQueryType)Enum.Parse(typeof(UsedInQueryType), usedInQuery, true);
             }
             catch (ArgumentException)
             {
                 throw new ElementTypeMismatchException("UsedInQuery");
             }
             if (this.m_usedInQueryAsDefined == UsedInQueryType.False)
             {
                 this.m_usedInQuery = false;
             }
             else if (this.m_usedInQueryAsDefined == UsedInQueryType.True)
             {
                 this.m_usedInQuery = true;
             }
         }
         else
         {
             this.m_usedInQueryAsDefined = UsedInQueryType.Auto;
         }
         return;
     }
     throw new MissingElementException("Name");
 }