I have an abstract class which I would like to be able to expose to WCF so that any subclasses will also be able to be started as a WCF service.
This is what I have so far:
[ServiceContract(Name = "PeopleManager", Namespace = "http://localhost:8001/People")]
[ServiceBehavior(IncludeExceptionDetailInFaults = true)]
[DataContract(Namespac...
I'm pretty new to mocking so this might be something I'm just not picking up on yet, but I can't find a good example anywhere.
I'm trying to assert that by default, any class that inherits from my abstract class will instantiate a collection in the constructor. Here's the abstract class:
public abstract class DataCollectionWorkflow : ...
Can you give me an almost overly simplistic understanding of abstract class vs inheritance use and help me so I can truly understand the concept and how to implement? I have a project I'm trying to complete, and am lost on how to implement. I've been chatting with my professor and been told off pretty much, saying that if I can't figure ...
I have an abstract class 'Server' which I create in my JavaScript in my UI and then I want to have a method on my Web Service which does the following:
public List<Database> GetDatabases(Server server)
{
Type type = server.GetType();
Server x = null;
if (typeof (SqlServer2005Server).Equals(type))
...
Hi,
So I have two classes. One is abstract:
public abstract class AbstractClient {
protected boolean running = true;
protected void run() {
Scanner scanner = new Scanner(System.in);
displayOptions();
while (running) {
String input = null;
while (scanner.hasNext()) {
...
I'm trying to use an abstract class when passing an extended object as an parameter to a function, but my attempts so far have led to some compiler errors.
I have a few clues as to what the problem is, I'm obviously not allowed to instantiate an abstract class, and I believe some of the code in MyClass is trying to do this, even though ...
One interesting aspect of extension methods in .NET is the fact that you can apply them to interfaces. For me, it seems nice that I can define functionality near the interface without defining an abstract class that clutters the assembly.
I know that abstract classes are not obsolete or anything, but how do you feel about utilizing this...
I have a situation which I think I need the functionality provided by an interface and an abstract class.
I am creating models to be used in a simulation. Each model is contained in a C# class that implements an IModel interface (of my design so it can be modified). I also created a c++ unmanaged Win32 DLL that acts as a bridge between ...
I found the following code in a library:
class Bar {
public:
bool foo(int i) {
return foo_(i);
}
private:
virtual bool foo_(int i) = 0;
};
Now I'm wondering: Why would you use this indirection? Could there be any reasons why the above would be better than the simple alternative:
class Bar {
public:
virtual bool foo(int i) ...
I have the following structure:
abstract class Base {
public abstract List<...> Get(); //What should be the generic type?
}
class SubOne : Base {
public override List<SubOne> Get() {
}
}
class SubTwo : Base {
public override List<SubTwo> Get() {
}
}
I want to create an abstract method that returns whate...
Duplicate:
When to use an interface instead of an abstract class and vice versa?
Probably one of the most famous software developer job interview questions.
What would be your answer?
EDIT: I'm trying to find out how you would answer this in a real-life situation. Please try to formulate your answer as you would on a real job int...
I have a warehouse. Sometimes I want to lookup a box location by a name, sometimes by a description, sometimes by a UPC, maybe something else, etc. Each of these lookup methods call the same various private methods to find information to help locate the data.
For example, upc calls a private method to find a rowid, so does name, so do...
I'm learning C# coming from C++ and have run into a wall.
I have an abstract class AbstractWidget, an interface IDoesCoolThings, and a class which derives from AbstractWidget called RealWidget:
public interface IDoesCoolThings
{
void DoCool();
}
public abstract class AbstractWidget : IDoesCoolThings
{
void IDoesCoolThings.DoCo...
I am only familiar with the basics of serialization, now I have a use for it. I have an existing reporting system with a ReportBase abstract class and multiple reports deriving from the base class. These each have different report parameters specified in the constructor and occasionally extra methods. Is it possible to serialize any of t...
My problem here is that I would like to pass an object to a derived class, but it must be done before the base class constructor, since the base class will immediately call the derived class's Start() method that uses the object.
Here's an excerpt from the base class, (renamed from BarcodeScanner for convenience).
public abstract class...
I need to write handlers for several different case types (in Python). The interface for all this types are the same, but the handling logic is different.
One option would be defining a common class that receives the particular handler type as one of the __init__ parameters:
class Handler:
def __init__ (self, handlerType):
...
Duplicate
Interface vs Base class
With C#, when to use Interfaces and when to use Abstract Classes, what can be the deciding factor.
...
I'm creating an abstract class that can be inherited in a partial class of a LINQ to SQL class. The LINQ to SQL class contains a bunch of built-in partial methods. Is there a way that I can implement one or more of the partial methods in the abstract class? I know that partial methods can only be contained within partial classes or struc...
I'm trying to come to terms with using IoC/Dependency Injection while at the same time programming to contracts rather than specific classes. The dilemma I'm having is the tension between:
Do program to interfaces for IoC: I started out with IoC relying heavily on interfaces. Judging by Spring's sample projects, interfaces are the way ...
Hi,
I have had recently two telephone interviews where I've been asked about the differences between an Interface and an Abstract class. I have explained every aspect of them I could think of, but it seems they are waiting for me to mention something specific, and I dont know what it is.
From my experience I think the following is tru...