Microsoft.CSharp.RuntimeBinder.Semantics.CType.AsArrayType C# (CSharp) Méthode

AsArrayType() public méthode

public AsArrayType ( ) : Microsoft.CSharp.RuntimeBinder.Semantics.ArrayType
Résultat Microsoft.CSharp.RuntimeBinder.Semantics.ArrayType
        public ArrayType AsArrayType() { return this as ArrayType; }
        public PointerType AsPointerType() { return this as PointerType; }

Usage Example

            private bool bindExplicitConversionFromArrayToIList()
            {
                // 13.2.2
                //
                // The explicit reference conversions are:
                //
                // * From a one-dimensional array-type S[] to System.Collections.Generic.IList<T>, System.Collections.Generic.IReadOnlyList<T> and
                //   their base interfaces, provided there is an explicit reference conversion from S to T.

                Debug.Assert(_typeSrc != null);
                Debug.Assert(_typeDest != null);

                if (!_typeSrc.IsArrayType() || _typeSrc.AsArrayType().rank != 1 ||
                    !_typeDest.isInterfaceType() || _typeDest.AsAggregateType().GetTypeArgsAll().Count != 1)
                {
                    return(false);
                }

                AggregateSymbol aggIList         = GetSymbolLoader().GetOptPredefAgg(PredefinedType.PT_G_ILIST);
                AggregateSymbol aggIReadOnlyList = GetSymbolLoader().GetOptPredefAgg(PredefinedType.PT_G_IREADONLYLIST);

                if ((aggIList == null ||
                     !GetSymbolLoader().IsBaseAggregate(aggIList, _typeDest.AsAggregateType().getAggregate())) &&
                    (aggIReadOnlyList == null ||
                     !GetSymbolLoader().IsBaseAggregate(aggIReadOnlyList, _typeDest.AsAggregateType().getAggregate())))
                {
                    return(false);
                }

                CType typeArr = _typeSrc.AsArrayType().GetElementType();
                CType typeLst = _typeDest.AsAggregateType().GetTypeArgsAll()[0];

                if (!CConversions.FExpRefConv(GetSymbolLoader(), typeArr, typeLst))
                {
                    return(false);
                }

                if (_needsExprDest)
                {
                    _binder.bindSimpleCast(_exprSrc, _exprTypeDest, out _exprDest, EXPRFLAG.EXF_REFCHECK);
                }
                return(true);
            }
All Usage Examples Of Microsoft.CSharp.RuntimeBinder.Semantics.CType::AsArrayType