コード例 #1
0
        /// <summary>
        /// Determine if this expression (which is an array access) when translated supports the "at" operator,
        /// which is a little slower, but definately safer.
        /// </summary>
        /// <param name="expression"></param>
        /// <returns></returns>
        private bool ArrayAccessDoesNotSupportAt(BinaryExpression expression)
        {
            var arrInfo = expression.DetermineArrayIndexInfo();

            if (arrInfo.Item2.NodeType != ExpressionType.MemberAccess)
            {
                return(false);
            }
            var me = arrInfo.Item2 as MemberExpression;

            //
            // If it has an array index attribute, then we should use the normal []
            //

            if (me.Member.TypeHasAttribute <ArraySizeIndexAttribute>() != null)
            {
                return(true);
            }

            //
            // If this type is an array index attribute, and this is the first index, then
            // we should also be using the [] access to get past the TClonesArray stuff (which
            // does not support .at).
            //

            if (arrInfo.Item1.Count == 1 && me.Expression.Type.TypeHasAttribute <TClonesArrayImpliedClassAttribute>() != null)
            {
                return(true);
            }

            return(false);
        }