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


C# IType.IsAssignableFrom方法代码示例

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


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

示例1: ReadFrom

        public object ReadFrom(IHttpEntity request, IType destinationType, string parameterName)
        {
            if (destinationType.IsAssignableFrom<IEnumerable<IMultipartHttpEntity>>())
            {
                var multipartReader = new MultipartReader(request.ContentType.Boundary, request.Stream);
                return multipartReader.GetParts();
            }

            if (destinationType.IsAssignableFrom<IDictionary<string, IList<IMultipartHttpEntity>>>())
            {
                return FormData(request);
            }

            var binder = BinderLocator.GetBinder(destinationType);
            
            if (binder == null)
            {
                throw new InvalidOperationException("Cannot find a binder to create the object");
            }

            binder.Prefixes.Add(parameterName);
            bool wasAnyKeyUsed = ReadKeyValues(request).Aggregate(false, (wasUsed, kv) => kv.SetProperty(binder) || wasUsed);
            var result = binder.BuildObject();

            return wasAnyKeyUsed && result.Successful ? result.Instance : Missing.Value;
        }
开发者ID:endjin,项目名称:openrasta-stable,代码行数:26,代码来源:MultipartFormDataObjectCodec.cs

示例2: IsAssignableFrom

 public static bool IsAssignableFrom(IType expectedType, IType actualType)
 {
     return expectedType.IsAssignableFrom(actualType);
 }
开发者ID:Bombadil77,项目名称:boo,代码行数:4,代码来源:TypeCompatibilityRules.cs

示例3: IsSubclassOf

        public virtual bool IsSubclassOf(IType other)
        {
            if (other.IsAssignableFrom(_array)) return true;

            // Arrays also implement generic IEnumerable of their element type
            if (other.ConstructedInfo != null &&
                other.ConstructedInfo.GenericDefinition == _enumerable &&
                other.ConstructedInfo.GenericArguments[0].IsAssignableFrom(_elementType))
            {
                return true;
            }
            return false;
        }
开发者ID:boo,项目名称:boo-lang,代码行数:13,代码来源:ArrayType.cs

示例4: CalculateArgumentScore

 private int CalculateArgumentScore(IParameter param, IType parameterType, Node arg)
 {
     IType argumentType = GetExpressionTypeOrEntityType(arg);
     if (param.IsByRef)
     {
         if (IsValidByRefArg(param, parameterType, argumentType, arg))
         {
             return ExactMatchScore;
         }
         return -1;
     }
     else if (parameterType == argumentType
         || (TypeSystemServices.IsSystemObject(argumentType) &&
             TypeSystemServices.IsSystemObject(parameterType)))
     {
         return parameterType is ICallableType
             ? CallableExactMatchScore
             : ExactMatchScore;
     }
     else if (parameterType.IsAssignableFrom(argumentType))
     {
         ICallableType callableType = parameterType as ICallableType;
         ICallableType callableArg = argumentType as ICallableType;
         if (callableType != null && callableArg != null)
         {
             return CalculateCallableScore(callableType, callableArg);
         }
         return UpCastScore;
     }
     else if (TypeSystemServices.FindImplicitConversionOperator(argumentType, parameterType) != null)
     {
         return ImplicitConversionScore;
     }
     else if (TypeSystemServices.CanBeReachedByPromotion(parameterType, argumentType))
     {
         if (IsWideningPromotion(parameterType, argumentType)) return WideningPromotion;
         return NarrowingPromotion;
     }
     else if (TypeSystemServices.CanBeReachedByDowncast(parameterType, argumentType))
     {
         return DowncastScore;
     }
     return -1;
 }
开发者ID:w4x,项目名称:boolangstudio,代码行数:44,代码来源:CallableResolutionService.cs

示例5: IsAssignableFrom

 bool IsAssignableFrom(IType expectedType, IType actualType)
 {
     return (IsPtr(expectedType) && IsPtr(actualType))
         || expectedType.IsAssignableFrom(actualType);
 }
开发者ID:w4x,项目名称:boolangstudio,代码行数:5,代码来源:EmitAssembly.cs

示例6: GetMostGenericType

        public IType GetMostGenericType(IType current, IType candidate)
        {
            if (current.IsAssignableFrom(candidate))
            {
                return current;
            }

            if (candidate.IsAssignableFrom(current))
            {
                return candidate;
            }

            if (IsNumberOrBool(current) && IsNumberOrBool(candidate))
            {
                return GetPromotedNumberType(current, candidate);
            }

            if (IsCallableType(current) && IsCallableType(candidate))
            {
                return ICallableType;
            }

            if (current.IsClass && candidate.IsClass)
            {
                if (current ==  ObjectType || candidate == ObjectType)
                {
                    return ObjectType;
                }
                if (current.GetTypeDepth() < candidate.GetTypeDepth())
                {
                    return GetMostGenericType(current.BaseType, candidate);
                }
                return GetMostGenericType(current, candidate.BaseType);
            }
            return ObjectType;
        }
开发者ID:boo,项目名称:boo-lang,代码行数:36,代码来源:TypeSystemServices.cs

示例7: CanBeReachedByDowncast

 public virtual bool CanBeReachedByDowncast(IType expectedType, IType actualType)
 {
     return actualType.IsAssignableFrom(expectedType);
 }
开发者ID:boo,项目名称:boo-lang,代码行数:4,代码来源:TypeSystemServices.cs

示例8: AreTypesRelated

        public bool AreTypesRelated(IType lhs, IType rhs)
        {
            ICallableType ctype = lhs as ICallableType;
            if (null != ctype)
            {
                return ctype.IsAssignableFrom(rhs)
                    || ctype.IsSubclassOf(rhs);
            }

            return lhs.IsAssignableFrom(rhs)
                || (lhs.IsInterface && !rhs.IsFinal)
                || (rhs.IsInterface && !lhs.IsFinal)
                || CanBeReachedByDownCastOrPromotion(lhs, rhs)
                || FindImplicitConversionOperator(rhs,lhs) != null;
        }
开发者ID:boo,项目名称:boo-lang,代码行数:15,代码来源:TypeSystemServices.cs

示例9: IsSubclassOf

        public bool IsSubclassOf(IType other)
        {
            if (BaseType != null && (BaseType == other || BaseType.IsSubclassOf(other)))
            {
                return true;
            }

            if (other.IsInterface && Array.Exists(
                GetInterfaces(),
                delegate(IType i) { return other.IsAssignableFrom(i); }))
            {
                return true;
            }

            return false;
        }
开发者ID:w4x,项目名称:boolangstudio,代码行数:16,代码来源:GenericConstructedType.cs


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