interface

Interface(s) inheriting other interface(s) in WCF services.

In my solution there's a few WCF services, each of them implementing it's own callback interface. Let's say they are called: Subscribe1, with ISubscribe1 and ICallback1, etc. It happens there are a few methods shared among ICallbacks, so I made a following interface: interface ICallback { [OperationContract] void CommonlyUsedMe...

How do I make my Linq to Sql entity expose an interface?

Using Nerd Dinner as an example: private NerdDinnerDataContext db = new NerdDinnerDataContext(); public IQueryable<Dinner> FindAllDinners() { return db.Dinners; } Is it not bad practice to directly expose the entity class Dinner here? I think it is better for the repository to return an IDinner. So my question is, how can I mak...

Generic Class VB.NET

hi guys, I am stuck with a problem about generic classes. I am confused how I call the constructor with parameters. My interface: Public Interface IDBObject Sub [Get](ByRef DataRow As DataRow) Property UIN() As Integer End Interface My Child Class: Public Class User Implements IDBObject Public Sub [Get](ByRef DataR...

Linux: Finer-grain control of INET listen socket binding?

I have interfaces lo, eth0, and eth0:1. progA creates a listen socket, and binds it to port p on INADDR_ANY. Simultaneously, I would like to use ncat to port forward, listening on the same port p, but only on the IP address associated with eth0:1. As expected, ncat is failing with "address already in use". What I would like to b...

How to Implement an Interface that Requires Duplicate Member Names?

I often have to implement some interfaces such as IEnumerable<T> in my code. Each time, when implementing automatically, I encounter the following: public IEnumerator<T> GetEnumerator() { // Code here... } public IEnumerator GetEnumerator1() { // Code here... } Though I have to implement both GetEnumerator() methods, they im...

Having trouble debugging class library plugin

Hi all. I have a windows form application in which I'm attempting to utilize a plugin (class library). In the code I have it load the assembly from a dll file, which means I have not been able to debug. Furthermore I have not found out how to compile the library so I've had to use the debuged dll version for testing. I've run into a bug ...

Design Question - how do you break the dependency between classes using an interface?

Hello, I apologize in advance but this will be a long question. I'm stuck. I am trying to learn unit testing, C#, and design patterns - all at once. (Maybe that's my problem.) As such I am reading the Art of Unit Testing (Osherove), and Clean Code (Martin), and Head First Design Patterns (O'Reilly). I am just now beginning to unde...

WCF - DataContract that inherits from an interface

I have a datacontract as part of my WCF Interface that inherits from IIdentity: [DataContract] public class AuthenticationIdentity : IIdentity { //implements IIdentity... } The service returns my AuthenticationIdentity objects just fine. However, when I try and do the obvious cast on the client: AuthenticationIdentity aId = c...

How to store and locate multiple interface types within a Delphi TInterfaceList

Hi, I'm storing small interfaces from a range of objects into a single TInterfaceList 'store' with the intention of offering list of specific interface types to the end user, so each interface will expose a 'GetName' function but all other methods are unique to that interface type. For example here are two interfaces: IBase = interfac...

List.ForEach method and collection interfaces

In .NET 3.5 List<> gains a ForEach method. I notice this does not exist on IList<> or IEnumerable<> what was the thinking here? Is there another way to do this? Nice and simple short way to do this? I ask because I was at a talk where the speaker said always use the more general interfaces. But why would I use IList<> as a return type i...

Visual Studio code generated when choosing to explicitly implement interface

Sorry for the vague title, but I'm not sure what this is called. Say I add IDisposable to my class, Visual Studio can create the method stub for me. But it creates the stub like: void IDisposable.Dispose() I don't follow what this syntax is doing. Why do it like this instead of public void Dispose()? And with the first syntax, I coul...

Difference between abstract class and interface

Possible Duplicate: Interface vs Base class A class implementing an interface has to implement all the methods of the interface, but if that class is implementing an abstract class is it necessary to implement all abstract methods? If not, can we create the object of that class which is implementing the Abstract class??? ...

Seeking suggestions on redesigning the interface

As a part of maintaining large piece of legacy code, we need to change part of the design mainly to make it more testable (unit testing). One of the issues we need to resolve is the existing interface between components. The interface between two components is a class that contains static methods only. Simplified example: class ABInte...

ASP.NET MVC - Custom Model Binder on Interface Type

I'm not sure if this behavior is expected or not, but it seems that custom model binding doesn't work when the binding is assigned to an interface type. Has anyone experimented with this? public interface ISomeModel {} public class SomeModel : ISomeModel {} public class MvcApplication : HttpApplication { protected void Application_...

C#: Method to return object whose concrete type is determined at runtime?

I'm thinking about designing a method that would return an object that implements an interface but whose concrete type won't be know until run-time. For example suppose: ICar Ford implements ICar Bmw implements ICar Toyota implements ICar public ICar GetCarByPerson(int personId) We don't know what car we will get back until runtime....

How to use derived class shared variables in shared methods of base class

Hi guys, I am trying to add shared members in derived classes and use that values in base classes... I have base class DBLayer public shared function GetDetail(byval UIN as integer) dim StrSql = string.format("select * from {0} where uin = {1}", tablename, uin) .... end function end class my derived class class Us...

Name Interface conventions when name already start with capitalized letter

Let say I want to create an interface for a class that should be name JQuery. If this class is an interface, from the conventions, I should name it IJQuery, but I find it's made the name look weird. What you think ? ...

Upcasting ServiceContract

Hi, I have a WCF service, which exposes many methods. My application consumes this service, and ServiceContract includes OperationContract definitions for only some of methods. To cut to the question, consider following code example: [ServiceContract] public interface IServer { [OperationContract] void BasicOperation(); } [S...

Can anybody explain the working of following code...?

Can anybody explain the working of following code...? interface myInterface{} public class Main { public static void main(String[] args) { System.out.println(new myInterface(){public String toString(){return "myInterfacetoString";}}); System.out.println(new myInterface(){public String myFunction(){return "myIn...

Haskell's TypeClasses and Go's Interfaces

What are the similarities and the differences between Haskell's TypeClasses and Go's Interfaces? What are the relative merits / demerits of the two approaches? ...