Пример #1
0
 // Token: 0x060007BF RID: 1983 RVA: 0x000185F8 File Offset: 0x000167F8
 private IndexerParameterInfo[] ResolveIndexerParams(FrugalObjectList <IndexerParamInfo> paramList, object context, bool throwOnError)
 {
     IndexerParameterInfo[] array = new IndexerParameterInfo[paramList.Count];
     for (int i = 0; i < array.Length; i++)
     {
         if (string.IsNullOrEmpty(paramList[i].parenString))
         {
             array[i].value = paramList[i].valueString;
         }
         else if (string.IsNullOrEmpty(paramList[i].valueString))
         {
             int num;
             if (int.TryParse(paramList[i].parenString.Trim(), NumberStyles.Integer, TypeConverterHelper.InvariantEnglishUS.NumberFormat, out num))
             {
                 if (0 <= num && num < this.PathParameters.Count)
                 {
                     object obj = this.PathParameters[num];
                     if (obj != null)
                     {
                         array[i].value = obj;
                         array[i].type  = obj.GetType();
                     }
                     else if (throwOnError)
                     {
                         throw new InvalidOperationException(SR.Get("PathParameterIsNull", new object[]
                         {
                             num
                         }));
                     }
                 }
                 else if (throwOnError)
                 {
                     throw new InvalidOperationException(SR.Get("PathParametersIndexOutOfRange", new object[]
                     {
                         num,
                         this.PathParameters.Count
                     }));
                 }
             }
             else
             {
                 array[i].value = "(" + paramList[i].parenString + ")";
             }
         }
         else
         {
             array[i].type = this.GetTypeFromName(paramList[i].parenString, context);
             if (array[i].type != null)
             {
                 object typedParamValue = this.GetTypedParamValue(paramList[i].valueString.Trim(), array[i].type, throwOnError);
                 if (typedParamValue != null)
                 {
                     array[i].value = typedParamValue;
                 }
                 else
                 {
                     if (throwOnError)
                     {
                         throw new InvalidOperationException(SR.Get("PropertyPathIndexWrongType", new object[]
                         {
                             paramList[i].parenString,
                             paramList[i].valueString
                         }));
                     }
                     array[i].type = null;
                 }
             }
             else
             {
                 array[i].value = "(" + paramList[i].parenString + ")" + paramList[i].valueString;
             }
         }
     }
     return(array);
 }
Пример #2
0
 // resolve indexer parameters
 IndexerParameterInfo[] ResolveIndexerParams(FrugalObjectList <IndexerParamInfo> paramList, object context, bool throwOnError)
 {
     IndexerParameterInfo[] args = new IndexerParameterInfo[paramList.Count];
     for (int i = 0; i < args.Length; ++i)
     {
         if (String.IsNullOrEmpty(paramList[i].parenString))
         {
             // no paren string "foo" - value is (uninterpreted) value string
             args[i].value = paramList[i].valueString;
         }
         else if (String.IsNullOrEmpty(paramList[i].valueString))
         {
             // no value string "(2)" - value comes from PathParameter list
             int index;
             if (Int32.TryParse(paramList[i].parenString.Trim(),
                                NumberStyles.Integer,
                                TypeConverterHelper.InvariantEnglishUS.NumberFormat,
                                out index))
             {
                 if (0 <= index && index < PathParameters.Count)
                 {
                     object value = PathParameters[index];
                     if (value != null)
                     {
                         args[i].value = value;
                         args[i].type  = value.GetType();
                     }
                     else if (throwOnError)
                     {
                         // info.value will still be "(n)"
                         throw new InvalidOperationException(SR.Get(SRID.PathParameterIsNull, index));
                     }
                 }
                 else if (throwOnError)
                 {
                     throw new InvalidOperationException(SR.Get(SRID.PathParametersIndexOutOfRange, index, PathParameters.Count));
                 }
             }
             else
             {
                 // parens didn't hold an integer "(abc)" - value is (uninterpreted) paren string
                 // [this could be considered an error, but the original code
                 // treated it like this, so to preserve compatibility...]
                 args[i].value = "(" + paramList[i].parenString + ")";
             }
         }
         else
         {
             // both strings appear "(Double)3.14159" - value is type-converted from value string
             args[i].type = GetTypeFromName(paramList[i].parenString, context);
             if (args[i].type != null)
             {
                 object value = GetTypedParamValue(paramList[i].valueString.Trim(), args[i].type, throwOnError);
                 if (value != null)
                 {
                     args[i].value = value;
                 }
                 else
                 {
                     if (throwOnError)
                     {
                         throw new InvalidOperationException(SR.Get(SRID.PropertyPathIndexWrongType, paramList[i].parenString, paramList[i].valueString));
                     }
                     args[i].type = null;
                 }
             }
             else
             {
                 // parens didn't hold a type name "(abc)xyz" - value is (uninterpreted) string
                 // [this could be considered an error, but the original code
                 // treated it like this, so to preserve compatibility...]
                 args[i].value = "(" + paramList[i].parenString + ")" + paramList[i].valueString;
             }
         }
     }
     return(args);
 }
Пример #3
0
        // Token: 0x060007B9 RID: 1977 RVA: 0x00018014 File Offset: 0x00016214
        private void NormalizePath()
        {
            StringBuilder stringBuilder = new StringBuilder();

            PropertyPath.PathParameterCollection pathParameterCollection = new PropertyPath.PathParameterCollection();
            for (int i = 0; i < this._arySVI.Length; i++)
            {
                switch (this._arySVI[i].drillIn)
                {
                case DrillIn.Never:
                    if (this._arySVI[i].type == SourceValueType.Property)
                    {
                        stringBuilder.Append('.');
                    }
                    break;

                case DrillIn.Always:
                    stringBuilder.Append('/');
                    break;
                }
                switch (this._arySVI[i].type)
                {
                case SourceValueType.Property:
                    if (this._earlyBoundPathParts[i] != null)
                    {
                        stringBuilder.Append('(');
                        stringBuilder.Append(pathParameterCollection.Count.ToString(TypeConverterHelper.InvariantEnglishUS.NumberFormat));
                        stringBuilder.Append(')');
                        pathParameterCollection.Add(this._earlyBoundPathParts[i]);
                    }
                    else
                    {
                        stringBuilder.Append(this._arySVI[i].name);
                    }
                    break;

                case SourceValueType.Indexer:
                    stringBuilder.Append('[');
                    if (this._earlyBoundPathParts[i] != null)
                    {
                        IndexerParameterInfo[] array = (IndexerParameterInfo[])this._earlyBoundPathParts[i];
                        int num = 0;
                        for (;;)
                        {
                            IndexerParameterInfo indexerParameterInfo = array[num];
                            if (indexerParameterInfo.type != null)
                            {
                                stringBuilder.Append('(');
                                stringBuilder.Append(pathParameterCollection.Count.ToString(TypeConverterHelper.InvariantEnglishUS.NumberFormat));
                                stringBuilder.Append(')');
                                pathParameterCollection.Add(indexerParameterInfo.value);
                            }
                            else
                            {
                                stringBuilder.Append(indexerParameterInfo.value);
                            }
                            num++;
                            if (num >= array.Length)
                            {
                                break;
                            }
                            stringBuilder.Append(',');
                        }
                    }
                    else
                    {
                        stringBuilder.Append(this._arySVI[i].name);
                    }
                    stringBuilder.Append(']');
                    break;
                }
            }
            if (pathParameterCollection.Count > 0)
            {
                this._path = stringBuilder.ToString();
                this.SetPathParameterCollection(pathParameterCollection);
            }
        }
Пример #4
0
        // "normalize" the path - i.e. load the PathParameters with the early-bound
        // accessors, and replace the corresponding parts of the path with
        // parameter references
        private void NormalizePath()
        {
            StringBuilder           builder    = new StringBuilder();
            PathParameterCollection parameters = new PathParameterCollection();

            for (int i = 0; i < _arySVI.Length; ++i)
            {
                switch (_arySVI[i].drillIn)
                {
                case DrillIn.Always:
                    builder.Append('/');
                    break;

                case DrillIn.Never:
                    if (_arySVI[i].type == SourceValueType.Property)
                    {
                        builder.Append('.');
                    }
                    break;

                case DrillIn.IfNeeded:
                    break;
                }

                switch (_arySVI[i].type)
                {
                case SourceValueType.Property:
                    if (_earlyBoundPathParts[i] != null)
                    {
                        builder.Append('(');
                        builder.Append(parameters.Count.ToString(TypeConverterHelper.InvariantEnglishUS.NumberFormat));
                        builder.Append(')');

                        parameters.Add(_earlyBoundPathParts[i]);
                    }
                    else
                    {
                        builder.Append(_arySVI[i].name);
                    }
                    break;

                case SourceValueType.Indexer:
                    builder.Append('[');
                    if (_earlyBoundPathParts[i] != null)
                    {
                        IndexerParameterInfo[] aryIPI = (IndexerParameterInfo[])_earlyBoundPathParts[i];
                        // the params should be at the very least a single empty string
                        Debug.Assert(aryIPI.Length > 0);
                        int j = 0;
                        while (true)
                        {
                            IndexerParameterInfo info = aryIPI[j];
                            if (info.type != null)
                            {
                                builder.Append('(');
                                builder.Append(parameters.Count.ToString(TypeConverterHelper.InvariantEnglishUS.NumberFormat));
                                builder.Append(')');

                                parameters.Add(info.value);
                            }
                            else
                            {
                                builder.Append(info.value);
                            }
                            ++j;

                            if (j < aryIPI.Length)
                            {
                                builder.Append(',');
                            }
                            else
                            {
                                break;
                            }
                        }
                    }
                    else
                    {
                        builder.Append(_arySVI[i].name);
                    }
                    builder.Append(']');
                    break;

                case SourceValueType.Direct:
                    break;
                }
            }

            if (parameters.Count > 0)
            {
                _path = builder.ToString();
                SetPathParameterCollection(parameters);
            }
        }