driver joystick digigear
A:
Mister Luke was right. I had to insert that 3-pack to get my DS4 to recognize the controller as a DualShock 4.
Q:
Is it possible to expose an interface and implement it in a single class?
I'm doing some refactoring in my project and want to change the way I am exposing an interface.
An example use case:
public class MyClass : IMyClass
{
void Init()
{
var myFoo = Foo();
// public interface implementation
DoSomething(myFoo);
}
public Foo Foo()
{
return new Foo();
}
public void DoSomething(Foo foo)
{
// use foo
}
}
I want to expose the interface so that others can call DoSomething(myFoo).
However, I don't want them to have to create an instance of Foo and pass it to DoSomething as I do in the example above. Instead, I want to implement the interface and then inject a "real" instance of Foo into the class. I know how to do this, but I want to make sure I'm not missing anything obvious.
public class MyClass : IMyClass
{
private readonly Foo _myFoo;
public MyClass(Foo myFoo)
{
_myFoo = myFoo;
}
public Foo Foo()
{
return _myFoo;
}
public void DoSomething(Foo foo)
{
// use foo
}
}
In the second example, the class exposes an interface that is implemented in the constructor. However, if I change this to expose the Foo member directly instead of implementing the interface, it no longer injects the Foo object into the constructor.
A: be359ba680
Related links:
Comments