Ejemplo n.º 1
0
 // Token: 0x060007C3 RID: 1987 RVA: 0x00018A51 File Offset: 0x00016C51
 internal static bool IsParameterIndex(string name, out int index)
 {
     if (PropertyPath.IsPropertyReference(name))
     {
         name = name.Substring(1, name.Length - 2);
         return(int.TryParse(name, NumberStyles.Integer, TypeConverterHelper.InvariantEnglishUS.NumberFormat, out index));
     }
     index = -1;
     return(false);
 }
Ejemplo n.º 2
0
        // Token: 0x060007B2 RID: 1970 RVA: 0x00017E70 File Offset: 0x00016070
        internal int ComputeUnresolvedAttachedPropertiesInPath()
        {
            int num = 0;

            for (int i = this.Length - 1; i >= 0; i--)
            {
                if (this._earlyBoundPathParts[i] == null)
                {
                    string name = this._arySVI[i].name;
                    if (PropertyPath.IsPropertyReference(name) && name.IndexOf('.') >= 0)
                    {
                        num++;
                    }
                }
            }
            return(num);
        }
Ejemplo n.º 3
0
        // Token: 0x060007BC RID: 1980 RVA: 0x00018270 File Offset: 0x00016470
        private void ResolvePathParts(ITypeDescriptorContext typeDescriptorContext)
        {
            bool               throwOnError       = typeDescriptorContext != null;
            object             obj                = null;
            TypeConvertContext typeConvertContext = typeDescriptorContext as TypeConvertContext;

            if (typeConvertContext != null)
            {
                obj = typeConvertContext.ParserContext;
            }
            if (obj == null)
            {
                obj = typeDescriptorContext;
            }
            this._earlyBoundPathParts = new object[this.Length];
            for (int i = this.Length - 1; i >= 0; i--)
            {
                if (this._arySVI[i].type == SourceValueType.Property)
                {
                    string name = this._arySVI[i].name;
                    if (PropertyPath.IsPropertyReference(name))
                    {
                        object obj2 = this.ResolvePropertyName(name, null, null, obj, throwOnError);
                        this._earlyBoundPathParts[i] = obj2;
                        if (obj2 != null)
                        {
                            this._arySVI[i].propertyName = PropertyPath.GetPropertyName(obj2);
                        }
                    }
                    else
                    {
                        this._arySVI[i].propertyName = name;
                    }
                }
                else if (this._arySVI[i].type == SourceValueType.Indexer)
                {
                    IndexerParameterInfo[] array = this.ResolveIndexerParams(this._arySVI[i].paramList, obj, throwOnError);
                    this._earlyBoundPathParts[i] = array;
                    this._arySVI[i].propertyName = "Item[]";
                }
            }
        }
Ejemplo n.º 4
0
        // Token: 0x060007BD RID: 1981 RVA: 0x00018390 File Offset: 0x00016590
        private object ResolvePropertyName(string name, object item, Type ownerType, object context, bool throwOnError)
        {
            string text = name;
            int    num;

            if (PropertyPath.IsParameterIndex(name, out num))
            {
                if (0 <= num && num < this.PathParameters.Count)
                {
                    object obj = this.PathParameters[num];
                    if (!PropertyPath.IsValidAccessor(obj))
                    {
                        throw new InvalidOperationException(SR.Get("PropertyPathInvalidAccessor", new object[]
                        {
                            (obj != null) ? obj.GetType().FullName : "null"
                        }));
                    }
                    return(obj);
                }
                else
                {
                    if (throwOnError)
                    {
                        throw new InvalidOperationException(SR.Get("PathParametersIndexOutOfRange", new object[]
                        {
                            num,
                            this.PathParameters.Count
                        }));
                    }
                    return(null);
                }
            }
            else
            {
                if (PropertyPath.IsPropertyReference(name))
                {
                    name = name.Substring(1, name.Length - 2);
                    int num2 = name.LastIndexOf('.');
                    if (num2 >= 0)
                    {
                        text = name.Substring(num2 + 1).Trim();
                        string text2 = name.Substring(0, num2).Trim();
                        ownerType = this.GetTypeFromName(text2, context);
                        if (ownerType == null && throwOnError)
                        {
                            throw new InvalidOperationException(SR.Get("PropertyPathNoOwnerType", new object[]
                            {
                                text2
                            }));
                        }
                    }
                    else
                    {
                        text = name;
                    }
                }
                if (!(ownerType != null))
                {
                    return(null);
                }
                object obj2 = DependencyProperty.FromName(text, ownerType);
                if (obj2 == null && item is ICustomTypeDescriptor)
                {
                    obj2 = TypeDescriptor.GetProperties(item)[text];
                }
                if (obj2 == null && (item is INotifyPropertyChanged || item is DependencyObject))
                {
                    obj2 = this.GetPropertyHelper(ownerType, text);
                }
                if (obj2 == null && item != null)
                {
                    obj2 = TypeDescriptor.GetProperties(item)[text];
                }
                if (obj2 == null)
                {
                    obj2 = this.GetPropertyHelper(ownerType, text);
                }
                if (obj2 == null && SystemCoreHelper.IsIDynamicMetaObjectProvider(item))
                {
                    obj2 = SystemCoreHelper.NewDynamicPropertyAccessor(item.GetType(), text);
                }
                if (obj2 == null && throwOnError)
                {
                    throw new InvalidOperationException(SR.Get("PropertyPathNoProperty", new object[]
                    {
                        ownerType.Name,
                        text
                    }));
                }
                return(obj2);
            }
        }