コード例 #1
0
        static bool ImplicitReferenceConversionExists(MdbEvaluationContext ctx,
                                                      TargetStructType source,
                                                      TargetStructType target)
        {
            if (source == target)
            {
                return(true);
            }

            if (source.Module.Name.StartsWith("mscorlib,") && target.Module.Name.StartsWith("mscorlib,"))
            {
                Type t1 = Type.GetType(source.Name);
                Type t2 = Type.GetType(target.Name);
                return(t2.IsAssignableFrom(t1));
            }

            if (!source.HasParent)
            {
                return(false);
            }

            TargetStructType parent_type = source.GetParentType(ctx.Thread);

            return(ImplicitReferenceConversionExists(ctx, parent_type, target));
        }
コード例 #2
0
        static bool TryParentCast(MdbEvaluationContext ctx, TargetStructType source_type, TargetStructType target_type)
        {
            if (source_type == target_type)
            {
                return(true);
            }

            if (!source_type.HasParent)
            {
                return(false);
            }

            TargetStructType parent_type = source_type.GetParentType(ctx.Thread);

            return(TryParentCast(ctx, parent_type, target_type));
        }
コード例 #3
0
        static TargetStructObject TryParentCast(MdbEvaluationContext ctx, TargetStructObject source, TargetStructType source_type, TargetStructType target_type)
        {
            if (source_type == target_type)
            {
                return(source);
            }

            if (!source_type.HasParent)
            {
                return(null);
            }

            TargetStructType parent_type = source_type.GetParentType(ctx.Thread);

            source = TryParentCast(ctx, source, parent_type, target_type);
            if (source == null)
            {
                return(null);
            }

            return(source.GetParentObject(ctx.Thread) as TargetClassObject);
        }