interface

c# Mocking Interface members of a concrete class with Moq

I have an interface ITransaction as follows: public interface ITransaction { DateTime EntryTime { get; } DateTime ExitTime { get; } } and I have a derived class PaymentTransaction as follows: public class PaymentTransaction : ITransaction { public virtual DateTime LastPaymentTime { get {...

Correct interface use with Entity Framework / Linq-to-SQL

I'm about to show my inexperience here, but hey - like any developer I want to learn. Given the following interface: public interface IRepository { entityDB Database { get; set; } IQueryable<T> All<T>() where T:class, new(); T Single<T>(Expression<Func<T, bool>> expression) where T : class, new(); IList<T> Find<T>(Expr...

More about Virtual / new...plus interfaces!

Hello again Yesterday I posted a question about the new/virtual/override keywords, and i learned a lot from your answers. But still i remain with some doubts. In between all the "boxes", i lost touch with what's really happening to the type's method tables. For instance: interface I1 { void Draw(); } interface I2 { void Draw(); } cla...

Java - Make sure an object implements an interface

EDIT: Solved, see below Hi, In Java, I got an object that could be of any class. BUT - that object will always have to implement an interface, so when I call methods defined by the interface, that object will contain that method. Now, when you try to call a custom method on a generic object in Java, it mucks about typing. How can I so...

Members of interface's methods have different types

Hello, I have this interface public interface TestInterface { [returntype] MethodHere(); } public class test1 : TestInterface { string MethodHere(){ return "Bla"; } } public class test2 : TestInterface { int MethodHere(){ return 2; } } Is there any way to make [returntype] dynamic? ...

C# Implementing IEquatable<T>.Equal<T>

I have a class like this: public class Foo<T> : IEquatable<T> where T : struct { List<T> lst; [Other irrelevant member stuff] } I want to implement the IEquatable<T> interface for the Foo class. What do I need to do. For simplicity I want to just check whether the List members are equal. Thanks. C# 4.0 supported answers ar...

Generic interface members

Hey All, I've asked this question yesterday and got lots of good answers, only I just realized my question was wrong and here I want to rephrase it. I have this interface public interface IFoo<T> { T Value(); } With this members public class Bar : IFoo<string> { string Value(){return "test";} } public class Bar2 : IFoo<int> {...

Compelling Reasons to Use Marker Interfaces Instead of Attributes

It's been discussed before on Stack Overflow that we should prefer attributes to marker interfaces (interfaces without any members). Interface Design article on MSDN asserts this recommendation too: Avoid using marker interfaces (interfaces with no members). Custom attributes provide a way to mark a type. For more information ab...

naming convention for two interfaces for one object

Hi, I am working on a project to develop a poker bot, I have to store the state of every hand that is played. I wanted to do this via an object - however Players can only read from the state and the Dealer is allowed to write to the state. I thought a good way to solve this would be to make the HandState object implement 2 interfaces (o...

Compile-time interface implementation check in C++

I'm using pseudo-interfaces in C++, that is, pure abstract classes. Suppose I have three interfaces, IFoo, IBar and IQuux. I also have a class Fred that implements all three of them: interface IFoo { void foo (void); } interface IBar { void bar (void); } interface IQuux { void quux (void); } class Fred : implements ...

C# Interfaces and Generic Lists

I have an interface defined as: namespace RivWorks.Interfaces.DataContracts { public interface IProduct { [XmlElement] [DataMember(Name = "ID", Order = 0)] Guid ProductID { get; set; } [XmlElement] [DataMember(Name = "altID", Order = 1)] long alternateProductID { get; set; } ...

inline if and interfaces (polymorphism)

public class Foo : IFooBarable {...} public class Bar : IFooBarable {...} So why then will this not compile... int a = 1; IFooBarable ting = a == 1 ? new Foo() : new Bar(); but this will... IFooBarable ting = a == 1 ? new Foo() : new Foo(); IFooBarable ting = a == 1 ? new Bar() : new Bar(); ...

Persist an enum wrapped in an interface with hibernate?

I'm using the latest version of Hibernate with Java. I've got three enum types that are being used as property names, each of the three property names go with different objects. There are different sets of property names for each object. Each property name is stored in a map with it's respective property value object, the property value ...

Application Design question - Database Tables and Interfaces

I have a database with tables for each entity in the system. e.g. PersonTable has columns PersonId, Name, HomeStateId. There is also a table for 'reference data' (i.e. states, countries, all currencies, etc.) data that will be used to fill drop down list boxes. This reference table will also be used so that PersonTable's HomeStateId wi...

C# Type-casting oddity - interface as the generic type

I've just run into what I think is an oddity in type-casting. I have code similar to the following: interface IMyClass { } class MyClass: IMyClass { } class Main { void DoSomething(ICollection<IMyClass> theParameter) { } HashSet<MyClass> FillMyClassSet() { //Do stuff } void Main() { HashSet<MyClass> classSet = Fi...

Are there any Timekeeping standards or specifications?

Hi, I'm currently thinking about a timekeeping application which can store and process information about the times and durations somebody is working. There is national law about working times (at least in Germany), which should be considered. But what about more technical standards? Are there any standards or spezification of models ...

Why is there no IArray(T) interface in .NET?

Question (in short): I asked why .NET has IList<T>, which implements ICollection<T> and therefore provides methods to modify the list (Add, Remove, etc.), but doesn't offer any in-between interface such as IArray<T> to provide random access by index without any list modification. EDIT 2010-Jan-21 2:22 PM EST: In a comment to Jon Skeet...

interface builder setters? please punch me!

if you have an IBOutlet on an ivar like IBOutlet UIView *view; @property (nonatomic, retain) UIView *view; that object created by ib will be managed by ib, but what if you have, UIView *view; @property (nonatomic, retain) IBOutlet UIView *view; does ib now use your setter to set that object? that would mean the setter has added +...

Internationalization in VB.Net : Choosing the right structure type

Hello! I'm about to start translating my vb.net application, and I don't want to use the default methods provided by Visual Studio to do so. I need my application to be very light, and it nearly doubles it size to use the resources option. Therefore, I'm planning to use some thing like a class, of which I would have one instance per la...

Blackberry BES Trancoders database access

Is that possible that transcoders working under BES server can have access to external database? ...