J
JME-56
Is it possible to define a static method in a C# interface? If not, is
there a workaround i can use?
It's like this. I'm writing this very small graphics library for .NET.
Now there's this class, and it contains 2 methods:
class DglSurface()
{
INativeSurface face;
...
internal DglSurface(INativeSurface face_)
{
face = face_;
}
public DglSurface(string filename)
{
// this is where i need help
}
}
Now, face is the native implemetation (SDL, DirectX, OpenGL). The
INativeSurface interface is as follows:
internal interface INativeSurface : IDisposable
{
DglSurface Load(string filename);
void SetAlpha(byte alpha);
void Blit(Point dest_point, DglSurface dest);
void Blit(Rectangle src_rect, Rectangle dest_rect, DglSurface dest);
int Width { get; }
int Height { get; }
}
Now the problem is: i want to construct a surface from a file, with
DglSurface.ctor(string filename). But, I can't declare Load to be
static in the interface. So I need an instance - and that's impossible
because i need the load function to create one! And it's also not
possible to declare a constructor in an interface...
So how can I arrange the Load method to be called as a static
function?
Any workarounds maybe?
I'm sorry if this message isn't very clear...
there a workaround i can use?
It's like this. I'm writing this very small graphics library for .NET.
Now there's this class, and it contains 2 methods:
class DglSurface()
{
INativeSurface face;
...
internal DglSurface(INativeSurface face_)
{
face = face_;
}
public DglSurface(string filename)
{
// this is where i need help
}
}
Now, face is the native implemetation (SDL, DirectX, OpenGL). The
INativeSurface interface is as follows:
internal interface INativeSurface : IDisposable
{
DglSurface Load(string filename);
void SetAlpha(byte alpha);
void Blit(Point dest_point, DglSurface dest);
void Blit(Rectangle src_rect, Rectangle dest_rect, DglSurface dest);
int Width { get; }
int Height { get; }
}
Now the problem is: i want to construct a surface from a file, with
DglSurface.ctor(string filename). But, I can't declare Load to be
static in the interface. So I need an instance - and that's impossible
because i need the load function to create one! And it's also not
possible to declare a constructor in an interface...
So how can I arrange the Load method to be called as a static
function?
Any workarounds maybe?
I'm sorry if this message isn't very clear...