interface

C#: How can Dictionary<K,V> implement ICollection<KeyValuePair<K,V>> without having Add(KeyValuePair<K,V>)?

Looking at System.Collections.Generic.Dictionary<TKey, TValue>, it clearly implements ICollection<KeyValuePair<TKey, TValue>>, but doesn't have the required "void Add(KeyValuePair<TKey, TValue> item)" function. This can also be seen when trying to initialize a Dictionary like this: private const Dictionary<string, int> PropertyIDs = ne...

Inheritance and interfaces

This is somewhat of a follow-up question to this question. Suppose I have an inheritance tree as follows: Car -> Ford -> Mustang -> MustangGT Is there a benefit to defining interfaces for each of these classes? Example: ICar -> IFord -> IMustang -> IMustangGT I can see that maybe other classes (like Chevy) would want to implement...

How do you use Ruby/DL? Is this right?

I am trying to write an interface between RSPEC (ruby flavoured BDD) and a Windows application. The application itself is written in an obscure language, but it has a C API to provide access. I've gone with Ruby/DL but am having difficulties getting even the most basic call to a DLL method to work. Here is what I have so far, in a fil...

Checking if an instance's class implements an interface?

Given a class instance, is it possible to determine if it implements a particular interface? As far as I know, there isn't a built-in function to do this directly. What options do I have (if any)? ...

Can I use jmock to replace an implementation returned by a factory?

I have a factory that returns an interface FormatService: public class FormatServiceFactory { public FormatService getService() { ... } } Is it possible to mock out this factory so that it will always return a stub implementation of FormatService - FormatServiceStub in our unit tests? ...

View multiple files in Visual Studio

I just realised that Office 2007 now shows multiple pages per default. I can finally take advantage of that huge monitor I've bought. Is there a similar feature with Visual Studio? Something like "View -> Two Pages" ...

Why to Use Explicit Interface Implementation To Invoke a Protected Method?

When browsing ASP.NET MVC source code in codeplex, I found it is common to have a class explicitly implementing interface. The explicitly implemented method/property then invoke another "protected virtual" method/property with same name. For example, public class MvcHandler : IHttpHandler, IRequiresSessionState { protected virtua...

How to work with an interface dynamically loaded from an assembly and invoke its members

I have got some code to load an assembly and get all types, which implement a certain interface, like this (assume asm is a valid and loaded assembly). var results = from type in asm.GetTypes() where typeof(IServiceJob).IsAssignableFrom(type) select type; Now I'm stuck: I need to create instances of these objects and invoke method...

JPA mapping interfaces

Hello All I am having trouble creating a mapping when the List type is an interface. It looks like I need to create an abstract class and use the discriminator column is this the case? I would rather not have to as the abstract class will just contain an abstract method and I would rather just keep the interface. I have an interface le...

Can I specify interfaces when I declare a member?

I need a member of my class to be a Control, and for it to implement an interface we define. If I declare it like this... public class MyClass { public Control MyMember; } ... then I don't get the interface methods, but if I declare it like this... public class MyClass { public IMyInterface MyMember; } ...then I don't get ...

What interface should I implement to create step driven events for my class?

I want to create a similar behavior to the data reader class but for a bespoke emailer program so that I can do the follow Dim sender As New EmailSender(emailTemplate) While sender.Send() Response.Write(sender("HTMLContent")) End While Is there an advised interface or mustInherit class to utilize the stepping functionality so that s...

Are there any static duck-typed languages?

Can I specify interfaces when I declare a member? After thinking about this question for a while, it occurred to me that a static-duck-typed language might actually work. Why can't predefined classes be bound to an interface at compile time? Example: public interface IMyInterface { public void MyMethod(); } public class MyClass //D...

How is duck typing different from the old 'variant' type and/or interfaces?

I keep seeing the phrase "duck typing" bandied about, and even ran across a code example or two. I am way too lazy busy to do my own research, can someone tell me, briefly: the difference between a 'duck type' and an old-skool 'variant type', and provide an example of where I might prefer duck typing over variant typing, and provide a...

C++: Derived + Base class implement a single interface?

In C++, is it possible to have a base plus derived class implement a single interface? For example: class Interface { public: virtual void BaseFunction() = 0; virtual void DerivedFunction() = 0; }; class Base { public: virtual void BaseFunction(){} }; class Derived : public Base, public Interface { ...

Need advice on combining ORM and SQL with legacy system

We are in the process of porting a legacy system to .NET, both to clean up architecture but also to take advantage of lots of new possibilities that just aren't easily done in the legacy system. Note: When reading my post before submitting it I notice that I may have described things a bit too fast in places, ie. glossed over details. I...

How can I frame an interface with modules in Access?

I have written a few modules of code in Access vba. Each code runs for various purpose and performs various actions on the database. I am not too much experinced in vba. I am planning to build an 'interface' or a 'form' so that a user can select which operation he wants to perfgorm and based on that that particular code runs. Can someon...

How do you return a variable in a C -> ruby interface?

A follow up to an earlier question, showing the part that fails when I try to get the error message from my target library: require 'gt4r' @@test_environment = "INCLUDE=C:\\graphtalk\\env\\aiadev\\config\\aiadev.ini" @@normal_user = "BMCHARGUE" describe Gt4r do it 'initializes' do rv = Gt4r.gTD_initialize @@normal_user, @@norm...

Changing NetBeans UI Look/Feel

Is it possible to somehow change the look/feel of NetBeans? I know it uses Swing and that usually apps using Swing for its UI can usually have their UI scheme changed. The default appearence for OSX is vomitastic and would even settle for just some sort of barebones "default" look. The whole look is just too distracting and unnecessary....

Using an interface to convert an object from one type to another?

Suppose I have two classes with the same interface: interface ISomeInterface { int foo{get; set;} int bar{get; set;} } class SomeClass : ISomeInterface {} class SomeOtherClass : ISomeInterface {} Suppose I have an instance of ISomeInterface that represents a SomeClass. Is there an easy way to copy that into a new instance ...

generics and interfaces enumeration

If have a set of classes that all implement an interface. interface IMyinterface<T> { int foo(T Bar); } I want to shove them all in a list and enumerate through them. List<IMyinterface> list foreach(IMyinterface in list) // etc... but the compiler wants to know what T is. Can I do this? How can I overcome this issue? ...