画像サイズの計算を行う基本クラスがあります。私はそれからクラスを派生させており、コードで使用される定義済みの画像サイズを持っています。自分が持っているものが機能している一方で、私はそれを適切に行っていないという強い感覚を持っています.
理想的には、DerviedClass.PreviewSize をパラメーターとして GetWidth に渡し、そのインスタンスを作成する必要はありません。
class Program
{
static void Main(string[] args)
{
ProfilePics d = new ProfilePics();
Guid UserId = Guid.NewGuid();
ProfilePics.Preview PreviewSize = new ProfilePics.Preview();
d.Save(UserId, PreviewSize);
}
}
class ProfilePicsBase
{
public interface ISize
{
int Width { get; }
int Height { get; }
}
public void Save(Guid UserId, ISize Size)
{
string PicPath = GetTempPath(UserId);
Media.ResizeImage(PicPath, Size.Width, Size.Height);
}
}
class ProfilePics : ProfilePicsBase
{
public class Preview : ISize
{
public int Width { get { return 200; } }
public int Height { get { return 160; } }
}
}