示例#1
0
        /// <summary>
        /// Caches the metadata.
        /// </summary>
        /// <param name="metadata">The metadata.</param>
        protected override void CacheMetadata(CodeActivityMetadata metadata)
        {
            var oldGetMethod = this.getMethod;
            var oldSetMethod = this.setMethod;

            if (typeof(TOperand).IsValueType)
            {
                metadata.AddValidationError(SR.TargetTypeIsValueType(this.GetType().Name, this.DisplayName));
            }

            if (this.Indices.Count == 0)
            {
                metadata.AddValidationError(SR.IndicesAreNeeded(this.GetType().Name, this.DisplayName));
            }
            else
            {
                IndexerHelper.CacheMethod <TOperand, TItem>(this.Indices, ref this.getMethod, ref this.setMethod);
                if (this.setMethod == null)
                {
                    metadata.AddValidationError(SR.SpecialMethodNotFound("set_Item", typeof(TOperand).Name));
                }
            }

            var operandArgument = new RuntimeArgument("Operand", typeof(TOperand), ArgumentDirection.In, true);

            metadata.Bind(this.Operand, operandArgument);
            metadata.AddArgument(operandArgument);

            IndexerHelper.OnGetArguments(this.Indices, this.Result, metadata);
            if (MethodCallExpressionHelper.NeedRetrieve(this.getMethod, oldGetMethod, this.getFunc))
            {
                this.getFunc = MethodCallExpressionHelper.GetFunc(metadata, this.getMethod, funcCache, locker);
            }

            if (MethodCallExpressionHelper.NeedRetrieve(this.setMethod, oldSetMethod, this.setFunc))
            {
                this.setFunc = MethodCallExpressionHelper.GetFunc(metadata, this.setMethod, funcCache, locker);
            }
        }
示例#2
0
        protected override void CacheMetadata(CodeActivityMetadata metadata)
        {
            if (!typeof(TOperand).IsValueType)
            {
                metadata.AddValidationError(System.Activities.SR.TypeMustbeValueType(typeof(TOperand).Name));
            }
            if (this.Indices.Count == 0)
            {
                metadata.AddValidationError(System.Activities.SR.IndicesAreNeeded(base.GetType().Name, base.DisplayName));
            }
            else
            {
                IndexerHelper.CacheMethod <TOperand, TItem>(this.Indices, ref this.getMethod, ref this.setMethod);
                if (this.setMethod == null)
                {
                    metadata.AddValidationError(System.Activities.SR.SpecialMethodNotFound("set_Item", typeof(TOperand).Name));
                }
            }
            RuntimeArgument argument = new RuntimeArgument("OperandLocation", typeof(TOperand), ArgumentDirection.InOut, true);

            metadata.Bind(this.OperandLocation, argument);
            metadata.AddArgument(argument);
            IndexerHelper.OnGetArguments <TItem>(this.Indices, base.Result, metadata);
        }