interface

How to use code contracts when deriving from interfaces like IDictionary<T, U>?

One class I am writing implements IDictionary<string, object>. In my CopyTo implementation, I would like to use code contracts: stuff like Contract.Requires<ArgumentNullException>(array != null). But, I get this warning (with some namespaces removed for readability): Method 'LuaDictionary.CopyTo(KeyValuePair<String,Object>[],Int32)' im...

MSVC 2010 back and forward navigation toolbar buttons

I just started trying out MSVC-2010 seriously, and discovered 2 critical toolbar buttons I always used are missing: The back and forward navigation buttons, which were present in MSVC 2003 through 2008. These jump back (or forward) through the sequence of locations observed in the code recently. Can anyone tell me how to get these button...

How to persist a collection of interface's Collection<Interface> in JPA ?

Hi, I have an the following scenario: // several classes that implement different interfaces class A implements X,Y {} class B implements Y,Z {} class C implements X,Z {} // other classes that contain collections of one of the interfaces(different objects) class G { Collection<X> mayContainAC; } class H { Collection<Y> mayContainA...

Possible to create a custom interface, making use of files managed by Alfresco?

Hi, Our company's switching from traditional, lame Windows shared drive to a Linux install of Alfresco. I'm the sole developer here (...go me!) and I would like to hear any thoughts on what I envisage being an interface, created by me, accessible by my team, and drawing on files stored in Alfresco, to modify some HTML files presented b...

Is this an F# bug?

I have an type that is implementing IEnumerable<T> interface, all is ok: open System type Bar() = interface Collections.IEnumerable with member x.GetEnumerator () = null interface Collections.Generic.IEnumerable<int> with member x.GetEnumerator () = null But things goes wrong if type inherits IEnumerable...

Enforcing implementation of events in derived abstract classes.

I am trying to create what I am thinking of as a translation class, so that my program can speak to a variety of target platforms. Each platform will be handled by a separate implementation of an abstract class. I have pared things down for the sake of simplicity. I have an abstract class, with a couple of abstract methods: abstract cl...

C# - is it possible to implement the singleton pattern by using an interface?

Hello, I'm currently developing an application in which I'm using a plugin system. For providing unified access to a configuration screen I added a settings class to each plugin which must implement a settings interface. Furthermore each Settings class should implement the singleton pattern as shown below: public sealed class PluginSet...

Define class-implementations in an interface

Are you able to define class-implementations in an interface? For instance (pseudo-code alert!)... interface IClass1 { String s { get; set; } // classes implementing this interface has to implement Class2 as "SubClass" Class2 SubClass; } interface IClass2 { Int32 i { get; set; } } class Class1 : IClass1 { String...

External Javascript Interface on Flash Player not working on CDN (Cloudfront)

I have a flash player with an external javascript interface: reloadData() I'm calling that function via Javascript when editing information on the page - basically to keep data on the page and in the player in synch. The reloadData() function works fine when the player is hosted locally. When we move it to the CDN (Amazon Cloudfront),...

Polymorphic delegates

C# chokes on delegate void Bar<T>(T t); void foo(Bar bar) { bar.Invoke("hello"); bar.Invoke(42); } The workaround is to use an interface interface Bar { void Invoke<T>(T t); } but now I need to go out of my way to define the implementations of the interface. Can I achieve the same thing with delegates and simple metho...

Are Using Interfaces Soley to Facilitate Stubing and Mocking in Unit Tests Now Obsolete?

In .NET, TypeMock Isolator and Microsoft Moles allow one to isolate any class, property, or method - be it sealed, static, protected or non-virtual. So what was impossible to mock in Moq or Rhino Mocks, now no longer is the case. I've always had some aversion with the idea of using an interface merely to be able to allow for mocking, wh...

Interfaces inheritance in C#

Hello! I'm trying to overrun quite big (for me) problem that I came across while writing my application. Look at this, please (I will try to shorten the code for simplicity): I have root interface called IRepository<T>. Next, IBookRepository : IRepository<Book> Next, concrete class that implements it: BookRepository : IBookRepository ...

Interface, Abstract or Inheritance? C# Design Question

Hi, I have a table which houses two entities, StaticProgram and DynamicProgram. There is one column in that table called ProgramType which determines if a program is of type "Static" or "Dynamic". Though these two entities are stored in one table (I am guessing because the primitive fields for Static and Dynamic programs are exactly the...

Overloading virtual functions in two different interfaces

I have an issue where I have an interface that has parts that make sense as templated, and parts that make sense as not-templated. I'm in the middle of a refactor where I'm splitting that out into two different interfaces where the more specific (the templated one) inherits from the other one. E.g., say I have an interface IArray, this...

Interface implementation overrides, etc.

Here's the simplest form of my question: IApple requires, among other things, property Flavor IToffeeApple also requires property Flavor The problem is, I want IToffeeApple to implement IApple (public interface IToffeeApple : IApple), but they both have the same property requirement. This becomes a problem when, for 1 purpose I need a...

Why are there no final interfaces in Java?

Extending an interface simply adds additional operations to be defined in any implementors and cannot break any existing implementations (unlike extending a class). But it can change (EDIT 3 WHICH CONSTANTS) and hence the PERCIEVED value of constants (EDIT 2 AS SEEN BY THE IMPLEMENTATION CLASSES). For instance, the following: interfac...

iPhone Tap Counter

I'm trying to get a UI Button to interact with a UI Label through Xcode and Interface Builder. What should I change in this code to do so? (I have everything linked up in Interface Builder already. The app just crashes when I press the button.) @synthesize window; @synthesize label; @synthesize anotherLabel; @synthesize myButton; ...

How to Protect a private REST API

I'm currently thinking how I could protect my REST API which is used only by my mobile application from being used by other applications? Could a API-Key be a good solution, because just me know the secret API key. Is there a better solution? ...

Do the same parameters of different JNI calls have the same values?

For example, there are two different JNI methods of the SAME object class JavaObj{ public native void methodA(); public native void methodB(); } The JNI headers for these methods could be JNIEXPORT void JNICALL Java_JavaObj_methodA(JNIEnv * pEnv, jobject javaobj); JNIEXPORT void JNICALL Java_JavaObj_methodB(JNIEnv * pEnv, job...

Implementing a generic interface

I have a generic interface: public interface IUnauthorizedRequestRespondable<out T> where T:class { T GetResponseForUnauthorizedRequest(); } (I'm not sure why Resharper recommended T is "out", but that's not the question). In my scenario, the object returned by GetResponseForUnauthorizedRequest is always of the type that impl...