Why do I (sometimes) have to reference assemblies referenced by the assembly I reference?

后端 未结 5 1134
名媛妹妹
名媛妹妹 2020-12-06 10:53

I have an assembly A that defines an interface with some overloads:

public interface ITransform
{
    Point InverseTransform(Point point);
    Rect InverseTr         


        
5条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-06 11:35

    To resolve this (and providing you don't have too much calls to wrap etc.)
    you could simply define an extension wrapper for that 'Point' call you're only using e.g.

    public static Point MyInverseTransform(this ITransform mytransform, Point point)
    {
        return mytransform.InverseTransform(point);
    }
    

    ...feed that lib (where the extension is) the System.Drawing reference
    (and to avoid having to add your 'wrapper lib' everywhere as that would defeat the purpose, just put it in some common lib which you have referenced already, related to the problem. Best is if part of the 'source' lib but saying in case you cannot change that)...

    and call it then via MyInverseTransform instead.

提交回复
热议问题