Esempio n. 1
0
 public void StoreLabels()
 {
     this.EnsureLabelsAreGenerated();
     if (this.Values != null)
     {
         this.m_labels = new string[this.Values.Length];
         for (int i = 0; i < this.Values.Length; i++)
         {
             string text = null;
             object obj  = this.Values[i];
             bool   flag = false;
             if (this.ValidValues != null)
             {
                 int num = 0;
                 while (num < this.ValidValues.Count)
                 {
                     if (!ParameterBase.ParameterValuesEqual(obj, this.ValidValues[num].Value))
                     {
                         num++;
                         continue;
                     }
                     flag = true;
                     text = this.ValidValues[num].Label;
                     break;
                 }
             }
             if (!flag && obj != null)
             {
                 text = ParameterInfo.CastValueToLabelString(obj, Thread.CurrentThread.CurrentCulture);
             }
             this.m_labels[i] = text;
         }
     }
 }
        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);
        }
Esempio n. 3
0
        public static string CastToString(object val, DataType type, CultureInfo language)
        {
            object obj = default(object);

            if (!ParameterBase.Cast(val, type, out obj, DataType.String, language))
            {
                throw new InternalCatalogException("Can not cast value of report parameter to string.");
            }
            return(ParameterInfo.CastValueToLabelString(val, language));
        }
Esempio n. 4
0
 public bool ValueIsValid()
 {
     if (this.Values != null && this.Values.Length != 0)
     {
         for (int i = 0; i < this.Values.Length; i++)
         {
             object obj = this.Values[i];
             if (!base.Nullable && obj == null)
             {
                 if (Global.Tracer.TraceVerbose)
                 {
                     Global.Tracer.Trace(TraceLevel.Verbose, "Value provided for parameter '{0}' is null and parameter is not nullable.", base.Name.MarkAsPrivate());
                 }
                 return(false);
             }
             if (base.DataType == DataType.String && !base.AllowBlank && obj != null && ((string)obj).Length == 0)
             {
                 if (Global.Tracer.TraceVerbose)
                 {
                     Global.Tracer.Trace(TraceLevel.Verbose, "Value provided for string parameter '{0}' is either null or blank and parameter does not allow blanks.", base.Name.MarkAsPrivate());
                 }
                 return(false);
             }
             if (this.ValidValues != null)
             {
                 bool flag = false;
                 int  num  = 0;
                 while (num < this.ValidValues.Count)
                 {
                     if (!ParameterBase.ParameterValuesEqual(obj, this.ValidValues[num].Value))
                     {
                         num++;
                         continue;
                     }
                     flag = true;
                     break;
                 }
                 if (!flag)
                 {
                     if (Global.Tracer.TraceVerbose)
                     {
                         Global.Tracer.Trace(TraceLevel.Verbose, "The provided value '{0}' for parameter '{1}' is not a valid value.", obj.ToString().MarkAsPrivate(), base.Name.MarkAsPrivate());
                     }
                     return(false);
                 }
             }
         }
         return(true);
     }
     return(false);
 }
Esempio n. 5
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);
        }
Esempio n. 6
0
 public ParameterBase(ParameterBase source)
 {
     this.m_name       = source.m_name;
     this.m_dataType   = source.m_dataType;
     this.m_nullable   = source.m_nullable;
     this.m_promptUser = source.m_promptUser;
     this.m_allowBlank = source.m_allowBlank;
     this.m_multiValue = source.m_multiValue;
     if (source.m_defaultValues != null)
     {
         int num = source.m_defaultValues.Length;
         this.m_defaultValues = new object[num];
         for (int i = 0; i < num; i++)
         {
             this.m_defaultValues[i] = source.m_defaultValues[i];
         }
     }
     this.m_usedInQuery = source.m_usedInQuery;
 }
Esempio n. 7
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;
     }
 }
Esempio n. 8
0
        public static ParameterInfo Cast(ParameterInfo oldValue, ParameterInfo newType, CultureInfo language, ref bool metaChanges)
        {
            object[] array  = null;
            object[] array2 = null;
            if (oldValue.Values != null)
            {
                array = new object[oldValue.Values.Length];
                for (int i = 0; i < oldValue.Values.Length; i++)
                {
                    if (!ParameterBase.Cast(oldValue.Values[i], oldValue.DataType, out array[i], newType.DataType, language))
                    {
                        return(null);
                    }
                }
            }
            if (oldValue.DefaultValues != null)
            {
                array2 = new object[oldValue.DefaultValues.Length];
                for (int j = 0; j < oldValue.DefaultValues.Length; j++)
                {
                    if (!ParameterBase.Cast(oldValue.DefaultValues[j], oldValue.DataType, out array2[j], newType.DataType, language))
                    {
                        return(null);
                    }
                }
            }
            if (oldValue.DataType != newType.DataType)
            {
                metaChanges = true;
            }
            ParameterInfo parameterInfo = new ParameterInfo(newType);

            parameterInfo.Values        = array;
            parameterInfo.DefaultValues = array2;
            parameterInfo.StoreLabels();
            return(parameterInfo);
        }
Esempio n. 9
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");
            }
        }
Esempio n. 10
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;
        }
Esempio n. 11
0
        public static bool CastFromString(string oldString, out object newValue, DataType newType, CultureInfo language)
        {
            newValue = null;
            if (oldString == null)
            {
                return(true);
            }
            switch (newType)
            {
            case DataType.Object:
                return(ParameterBase.DecodeObjectFromBase64String(oldString, out newValue));

            case DataType.String:
                newValue = oldString;
                return(true);

            case DataType.Boolean:
                if (string.Compare(oldString, "true", true, language) != 0 && string.Compare(oldString, "enable", true, language) != 0 && string.Compare(oldString, "enabled", true, language) != 0 && string.Compare(oldString, "yes", true, language) != 0 && string.Compare(oldString, "on", true, language) != 0 && string.Compare(oldString, "+", true, language) != 0)
                {
                    if (string.Compare(oldString, "false", true, language) != 0 && string.Compare(oldString, "disable", true, language) != 0 && string.Compare(oldString, "disabled", true, language) != 0 && string.Compare(oldString, "no", true, language) != 0 && string.Compare(oldString, "off", true, language) != 0 && string.Compare(oldString, "-", true, language) != 0)
                    {
                        return(false);
                    }
                    newValue = false;
                    return(true);
                }
                newValue = true;
                return(true);

            case DataType.Float:
                try
                {
                    newValue = double.Parse(oldString, language);
                    return(true);
                }
                catch (Exception ex)
                {
                    if (!(ex is FormatException) && !(ex is OverflowException))
                    {
                        throw;
                    }
                    return(false);
                }

            case DataType.Integer:
                try
                {
                    newValue = int.Parse(oldString, language);
                    return(true);
                }
                catch (Exception ex2)
                {
                    if (!(ex2 is FormatException) && !(ex2 is OverflowException))
                    {
                        throw;
                    }
                    return(false);
                }

            case DataType.DateTime:
            {
                DateTimeOffset dateTimeOffset = default(DateTimeOffset);
                bool           flag           = default(bool);
                if (DateTimeUtil.TryParseDateTime(oldString, language, out dateTimeOffset, out flag))
                {
                    if (flag)
                    {
                        newValue = dateTimeOffset;
                    }
                    else
                    {
                        newValue = dateTimeOffset.DateTime;
                    }
                    return(true);
                }
                return(false);
            }

            default:
                throw new InternalCatalogException("Parameter type is not one of the supported types in Cast");
            }
        }
Esempio n. 12
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");
 }
Esempio n. 13
0
 public void ValidateValue(object newValue, ErrorContext errorContext, ObjectType parameterType, string parameterValueProperty)
 {
     ParameterBase.ValidateValueForNull(newValue, this.Nullable, errorContext, parameterType, this.Name, parameterValueProperty);
     this.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));
 }
Esempio n. 15
0
 public ParameterInfo(ParameterBase source)
     : base(source)
 {
     this.m_prompt = source.Prompt;
 }