interface

How do you create a unit-testing stub for an interface containing a read-only member?

I am writing some unit tests for an extension method I have written on IPrincipal. To assist, I have created a couple of helper classes (some code for not-implemented members of the interfaces has been omitted for brevity): public class IPrincipalStub : IPrincipal { private IIdentity identityStub = new IIdentityStub(); public ...

Rename parameter in a WCF client interface

Hello everyone, I was wondering if there is a way to rename a parameter in a WCF client interface method ,just the same way I can rename methods or enumerations: Renaming methods: [System.Runtime.Serialization.DataMemberAttribute(Name = "intError")] public int ErrorCode {...} Renaming enumerations: public enum MyEnumeration...

Is there a preferred way to document methods implementing an interface?

I wonder if there's some way of doing this, or even if it should be done? My thoughts soon went to using method attributes as it's a kind of metadata, but I'm unsure if there are any for this purpose. Right now, I'm simply using XML comment <remark> tags to tell when a method implements some interface. But this is of course no structured...

Can an interface be implemented across an aggregate/composite class in vb.net?

VB.NET .NET 3.5 I have an aggregate class called Package as part of a shipping system. Package contains another class, BoxType . BoxType contains information about the box used to ship the package, such as length, width, etc. of the Box. Package has a method called GetShippingRates. This method calls a separate helper class, ShipRat...

When using Data Annotations with MVC, Pro and Cons of using an interface vs. a MetadataType

If you read this article on Validation with the Data Annotation Validators, it shows that you can use the MetadataType attribute to add validation attributes to properties on partial classes. You use this when working with ORMs like LINQ to SQL, Entity Framework, or Subsonic. Then you can use the "automagic" client and server side vali...

Java - For a given function foo(X i); in Interface X, why can't implementing class Y change it to foo(Y i)??

For example public interface X{ public void foo(X i); } public class Y implements X{//error: doesn't implement foo(X i)... public void foo(Y i){ fooBar(foo); } .... } Why can't I do that? And how can I change it so this is possible? What can I do to declare foo in X with a parameter, and then be able to use Y ...

Checking to see if a generic class is inherited from an interface

I've got a class that inherits from an interface. That interface defines an event that I'd like to subscribe to in the calling code. I've tried a couple of things, but they all resolve to false (where I know it's true). How can I check to see if a class implements a specific interface. Here's what I've tried (note, the object in questio...

Delphi memory management design strategies : Object or Interface ?

Regarding Delphi memory management, what are your design strategies ? What are the use cases where you prefer to create and release Objects manually ? What are the uses cases where Interfaces, InterfacedObjects, and their reference counting mechanism will be preferred ? Do you have identified some traps or difficulties with reference...

Should primitive types or non-primitive types be preferred in Java interfaces?

(I thought I once read something about this in a book, but now I'm not sure where to find it. If this question reminds you of some material that you've read, please post a reference!) What are the pros and the cons of primitives in interfaces? In other words, is one of these preferable to the other and why? Perhaps one is preferable to...

Interface explosion problem

I am implementing a screen using MVP pattern, with more feature added to the screen, I am adding more and more methods to the IScreen/IPresenter interface, hence, the IScreen/IPresenter interface is becoming bigger and bigger, what should I do to cope with this situation? ...

svcutil, WSDL, and the generated interfaces not being sufficient for implementation

I have a WSDL file defining a service that I have to implement in WCF. I had read that I could generate the proxy using svcutil from the WSDL file, and that I could then use the generated interfaces to implement the service. Unfortunately, I can't quite seem to find a way to have the interfaces contain the correct attributes to expose t...

Why doesn't the F# Set implement ISet<T>?

The .NET Framework is adding an ISet<T> interface with the 4.0 release. In the same release, F# is being added as a first-class language. F# provides an immutable Set<'T> class. It would seem logical to me that the immutable set provided would implement the ISet<T> interface, but it doesn't. Does anyone know why? My guess is that they ...

Inherited properties aren't bound during databinding

I have two interfaces, IAuditable and ITransaction. public interface IAuditable{ DateTime CreatedOn { get; } string CreatedBy { get; } } public interface ITransaction : IAuditable { double Amount{ get; } } And a class that implements ITransaction, call Transaction. public class Transaction : ITransaction{ public ...

Optional parameters for interfaces

Using c# 4.0 -- building an interface and a class that implements the interface. I want to declare an optional parameter in the interface and have it be reflected in the class. So, I have the following: public interface IFoo { void Bar(int i, int j=0); } public class Foo { void Bar(int i, int j=0) { // do stuff } } ...

What is the best interface from Python 3.1.1 to R?

I am using Python 3.1.1 on Mac OS X 10.6.2 and need an interface to R. When browsing the internet I found out about RPy. Is this the right choice? Currently, a program in Python computes a distance matrix and, stores it in a file. I invoke R separately in an interactive way and read in the matrix for cluster analysis. In order to simpl...

Loading c libraries from php

Hi, in a recent project I've come really need the lib tre matching library. However the project is in php, and there are no php bindings for the library. I've tried to google how to create an interface for c libs, but all I found was the dl function which seams to load only php extensions. What am I missing? ...

Resharper 4.5: How can I discard an interface and change all references to the only implementation?

Given: I have an interface. I have only class that implements that interface. Question: With Resharper 4.5 - How can I discard that interface and change all references to the only implementation? ...

How can it be that PageContent implements IAddChild but has none of IAddChild interface methods?

The PageContent element implements IAddChild but doesn't implements IAddChild methods so I can't call AddChild method on PageContent.. How can it be? And if i cast PageContent to IAddChild i can call AddChild method on it - So it does implement it somewhere... I am confused with this behavior. Can someone shed some light on this? ...

When best to use an interface in java

A good example of when exactly to use interfaces specifically in Java would be ideal and any specific rulings that apply. Thanks in advance. ...

How to return an IQueryable<Something> as an IQueryable<ISomething>

I have a class Something that implements ISomething. How can I convert/cast from an IQueryable<Something> to an IQueryable<ISomething>. When I try to cast, I am able to compile, but the result of the cast is always NULL. Background: The reason I am doing this is because my Something class is a CodeSmith-generated class (PLINQO templa...