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

IsNeverSameType() public méthode

public IsNeverSameType ( ) : bool
Résultat bool
        public bool IsNeverSameType()
        {
            return IsBoundLambdaType() || IsMethodGroupType() || (IsErrorType() && !AsErrorType().HasParent());
        }
    }

Usage Example

            private bool bindExplicitConversionFromIListToArray(ArrayType arrayDest)
            {
                // 13.2.2
                //
                // The explicit reference conversions are:
                //
                // * From System.Collections.Generic.IList<T>, System.Collections.Generic.IReadOnlyList<T> and their base interfaces
                //   to a one-dimensional array-type S[], provided there is an implicit or explicit reference conversion from
                //   S[] to System.Collections.Generic.IList<T> or System.Collections.Generic.IReadOnlyList<T>. This is precisely when either S and T
                //   are the same type or there is an implicit or explicit reference conversion from S to T.

                if (!arrayDest.IsSZArray || !(_typeSrc is AggregateType aggSrc) || !aggSrc.isInterfaceType() ||
                    aggSrc.GetTypeArgsAll().Count != 1)
                {
                    return(false);
                }

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

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

                CType typeArr = arrayDest.GetElementType();
                CType typeLst = aggSrc.GetTypeArgsAll()[0];

                Debug.Assert(!typeArr.IsNeverSameType());
                if (typeArr != typeLst && !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::IsNeverSameType