当前位置: 首页>>代码示例>>C#>>正文


C# AggregateType.GetTypeArgsAll方法代码示例

本文整理汇总了C#中Microsoft.CSharp.RuntimeBinder.Semantics.AggregateType.GetTypeArgsAll方法的典型用法代码示例。如果您正苦于以下问题:C# AggregateType.GetTypeArgsAll方法的具体用法?C# AggregateType.GetTypeArgsAll怎么用?C# AggregateType.GetTypeArgsAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.CSharp.RuntimeBinder.Semantics.AggregateType的用法示例。


在下文中一共展示了AggregateType.GetTypeArgsAll方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CheckAccess2

        public virtual ACCESSERROR CheckAccess2(Symbol symCheck, AggregateType atsCheck, Symbol symWhere, CType typeThru)
        {
            Debug.Assert(symCheck != null);
            Debug.Assert(atsCheck == null || symCheck.parent == atsCheck.getAggregate());
            Debug.Assert(typeThru == null ||
                   typeThru.IsAggregateType() ||
                   typeThru.IsTypeParameterType() ||
                   typeThru.IsArrayType() ||
                   typeThru.IsNullableType() ||
                   typeThru.IsErrorType());

#if DEBUG

            switch (symCheck.getKind())
            {
                default:
                    break;
                case SYMKIND.SK_MethodSymbol:
                case SYMKIND.SK_PropertySymbol:
                case SYMKIND.SK_FieldSymbol:
                case SYMKIND.SK_EventSymbol:
                    Debug.Assert(atsCheck != null);
                    break;
            }

#endif // DEBUG

            ACCESSERROR error = CheckAccessCore(symCheck, atsCheck, symWhere, typeThru);
            if (ACCESSERROR.ACCESSERROR_NOERROR != error)
            {
                return error;
            }

            // Check the accessibility of the return CType.
            CType CType = symCheck.getType();
            if (CType == null)
            {
                return ACCESSERROR.ACCESSERROR_NOERROR;
            }

            // For members of AGGSYMs, atsCheck should always be specified!
            Debug.Assert(atsCheck != null);

            if (atsCheck.getAggregate().IsSource())
            {
                // We already check the "at least as accessible as" rules.
                // Does this always work for generics?
                // Could we get a bad CType argument in typeThru?
                // Maybe call CheckTypeAccess on typeThru?
                return ACCESSERROR.ACCESSERROR_NOERROR;
            }

            // Substitute on the CType.
            if (atsCheck.GetTypeArgsAll().size > 0)
            {
                CType = SymbolLoader.GetTypeManager().SubstType(CType, atsCheck);
            }

            return CheckTypeAccess(CType, symWhere) ? ACCESSERROR.ACCESSERROR_NOERROR : ACCESSERROR.ACCESSERROR_NOACCESS;
        }
开发者ID:ChuangYang,项目名称:corefx,代码行数:60,代码来源:SemanticChecker.cs

示例2: ExactTypeArgumentInference

        ////////////////////////////////////////////////////////////////////////////////

        private void ExactTypeArgumentInference(
            AggregateType pSource, AggregateType pDest)

        {
            Debug.Assert(pSource != null);
            Debug.Assert(pDest != null);
            Debug.Assert(pSource.GetOwningAggregate() == pDest.GetOwningAggregate());

            TypeArray pSourceArgs = pSource.GetTypeArgsAll();
            TypeArray pDestArgs = pDest.GetTypeArgsAll();

            Debug.Assert(pSourceArgs != null);
            Debug.Assert(pDestArgs != null);
            Debug.Assert(pSourceArgs.size == pDestArgs.size);

            for (int arg = 0; arg < pSourceArgs.size; ++arg)
            {
                ExactInference(pSourceArgs.Item(arg), pDestArgs.Item(arg));
            }
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:22,代码来源:MethodTypeInferrer.cs

示例3: UpperBoundTypeArgumentInference

        ////////////////////////////////////////////////////////////////////////////////

        private void UpperBoundTypeArgumentInference(
            AggregateType pSource, AggregateType pDest)
        {
            // SPEC: The choice of inference for the i-th CType argument is made
            // SPEC: based on the declaration of the i-th CType parameter of C, as
            // SPEC: follows:
            // SPEC:  if Ui is known to be of reference CType and the i-th CType parameter
            // SPEC:   was declared as covariant then an upper-bound inference is made.
            // SPEC:  if Ui is known to be of reference CType and the i-th CType parameter
            // SPEC:   was declared as contravariant then a lower-bound inference is made.
            // SPEC:  otherwise, an exact inference is made.

            Debug.Assert(pSource != null);
            Debug.Assert(pDest != null);
            Debug.Assert(pSource.GetOwningAggregate() == pDest.GetOwningAggregate());

            TypeArray pTypeParams = pSource.GetOwningAggregate().GetTypeVarsAll();
            TypeArray pSourceArgs = pSource.GetTypeArgsAll();
            TypeArray pDestArgs = pDest.GetTypeArgsAll();

            Debug.Assert(pTypeParams != null);
            Debug.Assert(pSourceArgs != null);
            Debug.Assert(pDestArgs != null);

            Debug.Assert(pTypeParams.size == pSourceArgs.size);
            Debug.Assert(pTypeParams.size == pDestArgs.size);

            for (int arg = 0; arg < pSourceArgs.size; ++arg)
            {
                TypeParameterType pTypeParam = pTypeParams.ItemAsTypeParameterType(arg);
                CType pSourceArg = pSourceArgs.Item(arg);
                CType pDestArg = pDestArgs.Item(arg);

                if (pSourceArg.IsRefType() && pTypeParam.Covariant)
                {
                    UpperBoundInference(pSourceArg, pDestArg);
                }
                else if (pSourceArg.IsRefType() && pTypeParam.Contravariant)
                {
                    LowerBoundInference(pSourceArgs.Item(arg), pDestArgs.Item(arg));
                }
                else
                {
                    ExactInference(pSourceArgs.Item(arg), pDestArgs.Item(arg));
                }
            }
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:49,代码来源:MethodTypeInferrer.cs

示例4: GetNubFromNullable

 public NullableType GetNubFromNullable(AggregateType ats)
 {
     Debug.Assert(ats.isPredefType(PredefinedType.PT_G_OPTIONAL));
     return GetNullable(ats.GetTypeArgsAll().Item(0));
 }
开发者ID:ChuangYang,项目名称:corefx,代码行数:5,代码来源:TypeManager.cs

示例5: CalculateAssociatedSystemTypeForAggregate

        private static Type CalculateAssociatedSystemTypeForAggregate(AggregateType aggtype)
        {
            AggregateSymbol agg = aggtype.GetOwningAggregate();
            TypeArray typeArgs = aggtype.GetTypeArgsAll();

            List<Type> list = new List<Type>();

            // Get each type arg.
            for (int i = 0; i < typeArgs.size; i++)
            {
                // Unnamed type parameter types are just placeholders.
                if (typeArgs.Item(i).IsTypeParameterType() && typeArgs.Item(i).AsTypeParameterType().GetTypeParameterSymbol().name == null)
                {
                    return null;
                }
                list.Add(typeArgs.Item(i).AssociatedSystemType);
            }

            Type[] systemTypeArgs = list.ToArray();
            Type uninstantiatedType = agg.AssociatedSystemType;

            if (uninstantiatedType.GetTypeInfo().IsGenericType)
            {
                try
                {
                    return uninstantiatedType.MakeGenericType(systemTypeArgs);
                }
                catch (ArgumentException)
                {
                    // If the constraints don't work, just return the type without substituting it.
                    return uninstantiatedType;
                }
            }
            return uninstantiatedType;
        }
开发者ID:dotnet,项目名称:corefx,代码行数:35,代码来源:Type.cs

示例6: SubstTypeArray

 public TypeArray SubstTypeArray(TypeArray taSrc, AggregateType atsCls, TypeArray typeArgsMeth)
 {
     return SubstTypeArray(taSrc, atsCls != null ? atsCls.GetTypeArgsAll() : null, typeArgsMeth);
 }
开发者ID:ChuangYang,项目名称:corefx,代码行数:4,代码来源:TypeManager.cs

示例7: SubstType

 public CType SubstType(CType typeSrc, AggregateType atsCls, TypeArray typeArgsMeth)
 {
     return SubstType(typeSrc, atsCls != null ? atsCls.GetTypeArgsAll() : null, typeArgsMeth);
 }
开发者ID:ChuangYang,项目名称:corefx,代码行数:4,代码来源:TypeManager.cs

示例8: HasVariantConversion

        //////////////////////////////////////////////////////////////////////////////

        private bool HasVariantConversion(AggregateType pSource, AggregateType pDest)
        {
            Debug.Assert(pSource != null);
            Debug.Assert(pDest != null);
            if (pSource == pDest)
            {
                return true;
            }
            AggregateSymbol pAggSym = pSource.getAggregate();
            if (pAggSym != pDest.getAggregate())
            {
                return false;
            }

            TypeArray pTypeParams = pAggSym.GetTypeVarsAll();
            TypeArray pSourceArgs = pSource.GetTypeArgsAll();
            TypeArray pDestArgs = pDest.GetTypeArgsAll();

            Debug.Assert(pTypeParams.size == pSourceArgs.size);
            Debug.Assert(pTypeParams.size == pDestArgs.size);

            for (int iParam = 0; iParam < pTypeParams.size; ++iParam)
            {
                CType pSourceArg = pSourceArgs.Item(iParam);
                CType pDestArg = pDestArgs.Item(iParam);
                // If they're identical then this one is automatically good, so skip it.
                if (pSourceArg == pDestArg)
                {
                    continue;
                }
                TypeParameterType pParam = pTypeParams.Item(iParam).AsTypeParameterType();
                if (pParam.Invariant)
                {
                    return false;
                }
                if (pParam.Covariant)
                {
                    if (!HasImplicitReferenceConversion(pSourceArg, pDestArg))
                    {
                        return false;
                    }
                }
                if (pParam.Contravariant)
                {
                    if (!HasImplicitReferenceConversion(pDestArg, pSourceArg))
                    {
                        return false;
                    }
                }
            }
            return true;
        }
开发者ID:dotnet,项目名称:corefx,代码行数:54,代码来源:SymbolLoader.cs

示例9: IsDelegateType

 private bool IsDelegateType(CType pSrcType, AggregateType pAggType)
 {
     CType pInstantiatedType = GetSymbolLoader().GetTypeManager().SubstType(pSrcType, pAggType, pAggType.GetTypeArgsAll());
     return pInstantiatedType.isDelegateType();
 }
开发者ID:dotnet,项目名称:corefx,代码行数:5,代码来源:MemberLookup.cs

示例10: SubstContext

 public SubstContext(AggregateType type, TypeArray typeArgsMeth, SubstTypeFlags grfst)
 {
     Init(type != null ? type.GetTypeArgsAll() : null, typeArgsMeth, grfst);
 }
开发者ID:noahfalk,项目名称:corefx,代码行数:4,代码来源:SubstitutionContext.cs


注:本文中的Microsoft.CSharp.RuntimeBinder.Semantics.AggregateType.GetTypeArgsAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。