Reputation: 14285
I have got a abstract class which is implementing 3 interfaces.
public abstract class ServiceBaseCore<Entity, EntityKey> : MarshalByRefObject, IComponentService, IEntityProvider<Entity, EntityKey>
where Entity : IEntityId<EntityKey>, new()
where EntityKey : IEntityKey, new()
{
// Provided functionality/body to some methods of interface
}
Problem: i am getting error that my abstract class is not providing implementation (definition/body) to functions of interface, where as what i read is that "if a class is abstract than there is no need to provide body to all/any functions of interface its implementing".
Note: the code was generated by codeSmith even though its showing error.
please tell me where i am wrong and what i am missing.
Thanks
Upvotes: 0
Views: 235
Reputation: 6422
You may try some IDE to save much of your time. I know exactly, that Eclipse can do this automatically.
Upvotes: 0
Reputation: 28728
You should be able to right click on the Interface name (near MyClass : IMyInterface
) to see the context menu, and then choose 'Implement Interface'. Visual Studio will create all the required methods and properties to satsify the interface.
Upvotes: 0
Reputation: 9469
Just create some abstract functions, and the compiler will stop complaining:
public abstract void MyMethodDeclaredInTheInterface();
EDIT: To speed up the process, just move the caret on the interface name in your abstract class, then ctrl + . and select "Implement interface YourInterface". Then a little search and replace over the NotImplementedException should do the trick.
Upvotes: 7
Reputation: 209815
Create abstract methods for the interface. Otherwise, the class doesn't actually necessarily implement those methods in any way, even though derived classes might (the derived versions wouldn't be available to the base via vtables and therefore could not fulfill the interface contract). That would violate the idea behind interfaces.
Note: it's late and I'm tired, so I might be wrong about the rationale. But adding abstract methods for the methods required by the interfaces will take care of the problem.
Upvotes: 1