interface

Convert an interface's event from VB.Net to C#

Hi, I'm struggling to convert the below code to C#. Class Class1 Implements IMyInterface Public Event MyEvent(ByVal sender As Object, ByVal e As MyEventArgs) Implements IMyInterface.MyEvent Public Sub New() AddHandler Me.Slider.ValueChanged, AddressOf OnSliderValueChanged End Sub Private Sub OnSliderValueC...

Interface for classes that have nothing in common

Lets say I want to make few classes to determine behaviour of agents. The good practice would be to make some common interface for them, such interface (simplified) could look like this: interface IModel { void UpdateBehaviour(); } All , or at least most, of such model would have some parameters, but parameters from one model mig...

How to force multiple Interfaces to include certain the same properties?

I am trying to figure out a way to force all of my Interfaces to include properties of the same name/type. For example: I have two Interfaces; IGetAlarms and IGetDiagnostics. Each of the Interfaces will contain properties that are specific to the Interface itself, however I want to force the two Interfaces (and all other Interfaces that...

How to do a mouse rollover action on a Label in Xcode?

How do I link up a mouse rollover action on a label, or any invisible object I can place over the label. I can't find it the label's action list Using xcode 3.2 and Interface builder ...

Spring.net - how to choose implementation of interface in runtime ?

Hi, in all examples of spring.net IoC i can see something like this: interface IClass; class ClassA : IClass; class ClassB : IClass, and then in config.xml file something like [object id="IClass" type="ClassB, Spring.Net.Test" /] but, i really need to do something like this: in config file there will be more implementations if i...

Object Model Contracts

I'm trying to create a data model for WCF based off of interfaces from my core object model, but I'm having trouble with some of the associations Currently I have this in my core data model public class A : IA { public string name { /* ... */ } public EntitySet<B> children { /* ... */ } } public class B : IB { publ...

How do I enumerate a list of interfaces that are directly defined on an inheriting class?

Updated question given Andrew Hare's correct answer: Given the following C# classes: public class Bar : Foo, IDisposable { // implementation of Bar and IDisposable } public class Foo : IEnumerable<int> { // implementation of Foo and all its inherited interfaces } I want a method like the following that doesn't fail on the as...

Convert to list after Cast<T>

Hi, I need to convert an IQueryable to List(is it possible to convert to IList?). There had not been an problem if it was not that i need to Cast<T> because I have interfaces to my objects. I've tried most things but for some reason I must run Cast<T> first and then ToList() which generates System.NullReferenceException. How do I solve ...

How to get actual type of an derived class from its parent interface

Lets say we have a code portion like this : IProduct product = ProductCreator.CreateProduct(); //Factory Method we have here SellThisProduct(product); //... private void SellThisProduct(IProduct product) { //..do something here } //... internal class Soda : IProduct {} internal class Book : IProduct {} How can I infer which pro...

Why can't I call methods within a class that explicitly implements an interface?

Here's the story. I created an interface, IVehicle. I explicitly implemented the interface in my class, Vehicle.cs. Here is my interface: Interface IVehicle { int getWheel(); } here is my class: class Vehicle: IVehicle { public int IVehicle.getWheel() { return wheel; } public void printWheel(...

Purpose of Zope Interfaces?

I have started using Zope interfaces in my code, and as of now, they are really only documentation. I use them to specify what attributes the class should possess, explicitly implement them in the appropriate classes and explicitly check for them where I expect one. This is fine, but I would like them to do more if possible, such as actu...

C# How to check if a class implements generic interface ?

How to get generic interface type for an instance ? Suppose this code: interface IMyInterface<T> { T MyProperty { get; set; } } class MyClass : IMyInterface<int> { #region IMyInterface<T> Members public int MyProperty { get; set; } #endregion } MyClass myClass = new MyClass(); /* returns the ...

iPhone UITableView stutters with custom cells. How can I get it to scroll smoothly?

I'm using a UITableView to display custom cells created with Interface Builder. The table scrolling isn't very smooth (it "stutters") which leaves me to believe cells aren't being reused. Is there something wrong with this code? - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPat...

Polymorphism problem: How to check type of derived class?

Hi, this is my first question here :) I know that I should not check for object type but instead use dynamic_cast, but that would not solve my problem. I have class called Extension and interfaces called IExtendable and IInitializable, IUpdatable, ILoadable, IDrawable (the last four are basicly the same). If Extension implements IExten...

xcode - warning there's no getter/setter for property not even mentioned in the code!!

I got the warning : property 'textField' requires method '-textField' to be defined - use @synthesize, @dynamic or provide a method implementation. Now, there is no such property defined in my project! More bizarre, if I just click save in Interface builder and build again, the build is successful - though, right on the line ...

using Java interfaces

I need to create interface MultiLingual, that allows to display object's data in different languages (not data itself, but introduction like "Author", "Title" etc.). Printed data looks like this : 3 grudnia 1998 10th of June 1924 Autor: Tolkien Tytul: LoTR Wydawnictwo: Amazon 2010 Author: Mitch Albom Title: Tuesdays with Morrie Pub...

C#: Specify that a function arg must inherit from one class, and implement an interface?

I'm making a game where each Actor is represented by a GameObjectController. Game Objects that can partake in combat implement ICombatant. How can I specify that arguments to a combat function must inherit from GameObjectController and implement ICombatant? Or does this indicate that my code is structured poorly? public void ComputeAtta...

simple jsf application in myeclipse using jBoss

I want to run simple application of jsf but after configuring jBoss in my application I got the following error. 14:58:38,328 ERROR [[/web3demo]] Exception sending context initialized event to listener instance of class org.jboss.web.jsf.integration.config.JBossJSFConfigureListener com.sun.faces.config.ConfigurationException: CONFIGURAT...

Joda-Time: DateTime, DateMidnight and LocalDate usage

Joda-Time library includes different datetime classes DateTime - Immutable replacement for JDK Calendar DateMidnight - Immutable class representing a date where the time is forced to midnight LocalDateTime - Immutable class representing a local date and time (no time zone) I'm wondering how are you using these classes in ...

Is it good practice to put private API in the .m files and public API in .h files in Cocoa?

Many of my classes in my current project have several properties and methods that are only ever called from within the class itself. Also, they might mess with the working of the class depending on the current state of the class. Currently, all these interfaces are defined in the main interface declaration in the .h files. Is it consider...