Questions tagged [interface-implementation]

137 questions
4
votes
1 answer

Implementing ICollection.CopyTo in C#: deep or shallow copy?

I'm writing a custom class which implements IDictionary, and I'm not sure what to do about CopyTo. Should each element just be copied to the target array (shallow copy), or should I make a copy/clone of each element then place it in the target array…
Eric Dand
  • 1,106
  • 13
  • 37
4
votes
1 answer

Finding objects that implement interface from loaded assembly -how to compare types?

I have class that will load all assemblies in a directory and then get all the types an see if they implement an interface. I cannot get the type comparison to work. In the debugger I see my type loaded (the one I am interested in) if always fails…
pogorman
  • 1,641
  • 2
  • 22
  • 41
4
votes
2 answers

Instantiating anonymous inner classes in Java with additional interface implementation

Let's say I have the following two class/interface definitions: public abstract class FooClass { public abstract void doFoo(); } and public interface BarInterface { public void doBar(); } If I want to make an anonymous inner class that…
Markus A.
  • 12,349
  • 8
  • 52
  • 116
4
votes
1 answer

Implementing Interfaces That "Inherit" (Implement) A Common Interface?

interface ITurtle { void Fight(); void EatPizza(); } interface ILeonardo : ITurtle { void UseKatana(); } interface IRaphael : ITurtle { void UseSai(); } interface IDonatello : ITurtle { void UseBo(); } interface…
Mickael Caruso
  • 8,721
  • 11
  • 40
  • 72
4
votes
2 answers

Is it supposed to be possible for methods to be missing their arguments in the implementation?

I face some common IDE bugs in Delphi XE2 (RAD Studio) but the problems themselves aren't my concern. It's the result of one of these bugs which made me stumble on something else. Somehow, auto-completion decided to destroy a few methods of a form,…
Jerry Dodge
  • 26,858
  • 31
  • 155
  • 327
4
votes
5 answers

Interface with implementation without abstract class?

I am writing a library and I want to have an interface public interface ISkeleton { IEnumerable Bones { get; } void Attach(IBone bone); void Detach(IBone bone); } The Attach() and Detach() implementation actually should be the…
Jake
  • 11,273
  • 21
  • 90
  • 147
3
votes
3 answers

Multiple Implementation Attempts

I am developing a solution which will connect to a wide variety of servers to read data and perform operations. There are many variables which complicate reliable communications such as firewalls, stopped/failed services, authentication…
Robert
  • 95
  • 2
  • 8
3
votes
6 answers

Is it allowed for a class to implement an interface plus additional private method(s) in C#?

I have the following interface: interface IExcelServices { Dictionary FilterFields(Dictionary excelContent); Dictionary ParseExcelFile(string path); } Which is implemented by the…
CiccioMiami
  • 8,028
  • 32
  • 90
  • 151
3
votes
3 answers

Can I workaround unique_ptr to not need MyType destructor definition when only storing nullptr?

I need to use VS2012 compiler and have: virtual std::unique_ptr pass_through(std::unique_ptr instance) override { return std::unique_ptr(nullptr); }; That definition exists only for a project as a stub and without the MyType…
Lukas Salich
  • 959
  • 2
  • 12
  • 30
3
votes
4 answers

Class Implementing Two Interfaces which Define the Same Method

//inteface i11 public interface i11 { void m11(); } //interface i22 public interface i22 { void m11(); } //class ab implements interfaces i11 and i22 public class ab : i11, i22 { public void…
Neo
  • 15,491
  • 59
  • 215
  • 405
3
votes
3 answers

Why interface methods can't be static in class that implements the interface?

Lets suppose I have code like this: public interface JustAnInterface { void doSomething(); } public class JustAnInterfaceImplementation implements JustAnInterface { @Override public static void doSomething() { } } Why does static…
Dmitry Smolyaninov
  • 2,159
  • 1
  • 18
  • 32
3
votes
5 answers

Undo in a transactional database

I do not know how to implement undo property of user-friendly interfaces using a transactional database. On one hand it is advisable that the user has multilevel (infinite) undoing possibility as it is stated here in the answer. Patterns that may…
rics
  • 5,494
  • 5
  • 33
  • 42
3
votes
4 answers

Could we autowire an interface without any implementation in Spring?

We have to share our code base with a partner for developing, but we don't want to reveal the implementation of some services. Say we have an interface FooService and its implementation FooServiceImpl. public interface FooService { void…
Bruce
  • 647
  • 2
  • 12
  • 30
3
votes
1 answer

How come DbContext implements IObjectContextAdapter but doesn't have public ObjectContext property

In entity framework, the DbContext class implements IObjectContextAdapter interface. When I look inside this interface I see there's only one property ObjectContext ObjectContext {get;} But DbContext class itself doesn't have that property.…
Mikayil Abdullayev
  • 12,117
  • 26
  • 122
  • 206
3
votes
1 answer

How to access abstract superclass implementation when it contains a factory method?

I have an abstract superclass with a factory that returns an instance of a subclass. Is it possible to have a method that is implemented only in superclass? In the following code, for instance, would it be possible to remove Wind::act()? abstract…
Tom Russell
  • 1,015
  • 2
  • 10
  • 29
1 2
3
9 10