// resolve the property names and path parameters early, if possible
        void ResolvePathParts(ITypeDescriptorContext typeDescriptorContext)
        {
            bool throwOnError = (typeDescriptorContext != null);

            object context = null;

            TypeConvertContext typeConvertContext = typeDescriptorContext as TypeConvertContext;

            if (typeConvertContext != null)
            {
                context = typeConvertContext.ParserContext;
            }

            if (context == null)
            {
                context = typeDescriptorContext;
            }
            _earlyBoundPathParts = new object[Length];

            for (int level = Length - 1; level >= 0; --level)
            {
                if (_arySVI[level].type == SourceValueType.Property)
                {
                    string name = _arySVI[level].name;
                    if (IsPropertyReference(name))
                    {
                        object accessor = ResolvePropertyName(name, null, null, context, throwOnError);
                        _earlyBoundPathParts[level] = accessor;

                        if (accessor != null)
                        {
                            _arySVI[level].propertyName = GetPropertyName(accessor);
                        }
                    }
                    else
                    {
                        _arySVI[level].propertyName = name;
                    }
                }
                else if (_arySVI[level].type == SourceValueType.Indexer)
                {
                    IndexerParameterInfo[] indexerParams = ResolveIndexerParams(_arySVI[level].paramList, context, throwOnError);
                    _earlyBoundPathParts[level] = indexerParams;
                    _arySVI[level].propertyName = Binding.IndexerName;
                }
            }
        }
Example #2
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[]";
                }
            }
        }
        internal void AddApplicationProperty(MemberInfo memberInfo, string attributeValue, int lineNumber)
        {
            Debug.Assert(_ccRoot == (_codeContexts.Peek() as CodeContextRoot));
            Debug.Assert(_ccRoot.ElementType == null ||
                         (memberInfo.DeclaringType.IsAssignableFrom(_ccRoot.ElementType) && (memberInfo is PropertyInfo)));

            TypeConvertContext ctx = new TypeConvertContext(_parserContext, attributeValue);
            CodeExpression ceValue = GetPropertyValueExpression(ctx, typeof(Uri), null, attributeValue);
            CodeThisReferenceExpression ctreTag = new CodeThisReferenceExpression();
            CodePropertyReferenceExpression cprePropSet = new CodePropertyReferenceExpression(ctreTag, memberInfo.Name);

            CodeStatement csPropSet = new CodeAssignStatement(cprePropSet, ceValue);

            AddLinePragma(csPropSet, lineNumber);

            _ccRoot.EnsureInitializeComponentFn.Statements.Add(csPropSet);
        }