interface

Interface method as event handler

假装没事ソ 提交于 2019-12-23 13:06:43
问题 Is it possible to use interface method as event handlers in Delphi 2007? The simple versions don't work: type TMyEvent = procedure of object; IMyInterface = interface procedure Handler; end; TMyClass = class(TInterfacedObject, IMyInterface) public procedure Handler; end; var ev: TMyEvent; obj: TMyClass; intf: IMyInterface; begin obj := TMyClass.Create; intf := obj; ev := obj.Handler; // compiles ev := intf.Handler; // <== Error E2010 (incompatible types) end. Adding @ or Addr changes the

Functions Overloading in interface and classes - how to?

こ雲淡風輕ζ 提交于 2019-12-23 12:50:00
问题 I have this interface : interface IPoint { getDist(): string; getDist(x: number): any; } and I need a class to implement it but I can't get the right syntax to implement the getDist() method in the class.. class Point implements IPoint { // Constructor constructor (public x: number, public y: number) { } pointMethod() { } getDist() { Math.sqrt(this.x * this.x + this.y * this.y); } // Static member static origin = new Point(0, 0); } it says: Class 'Point' declares interface 'IPoint' but does

Explicit C# interface implementation of interfaces that inherit from other interfaces

青春壹個敷衍的年華 提交于 2019-12-23 12:45:36
问题 Consider the following three interfaces: interface IBaseInterface { event EventHandler SomeEvent; } interface IInterface1 : IBaseInterface { ... } interface IInterface2 : IBaseInterface { ... } Now consider the following class that implements both IInterface1 and IInterface 2: class Foo : IInterface1, IInterface2 { event EventHandler IInterface1.SomeEvent { add { ... } remove { ... } } event EventHandler IInterface2.SomeEvent { add { ... } remove { ... } } } This results in an error because

What's the use of attributes on an interface?

有些话、适合烂在心里 提交于 2019-12-23 12:38:42
问题 Using Resharper, I extracted an interface of an existing class. This class has some attributes set on a few members, and Resharper also put these on the interface members. Can I delete these attributes from the interface? Attributes on an interface aren't inherited when implementing an interface right? 回答1: They aren't used by the implementing class - but still might be critical. For example, WCF defines service-contracts and operation-contracts by the attributes on the interface. If they

checkstyle JavadocType only on interfaces

冷暖自知 提交于 2019-12-23 12:29:40
问题 As we are drowning in thousands of checkstyle rules, I want to relax them (if only to stop devs from ignoring them). One of the rules I want to relax is the JavaDocType check: Only on interfaces should javadoc be mandatory, not on other public classes. Unfortunately, I don't see an 'interface' Scope. Has anyone a suggestion to make this possible without writing our own check? 回答1: This sounds like the right thing: tokens definitions to check subset of tokens INTERFACE_DEF, CLASS_DEF Try this:

Discovering Interface Dependencies

余生颓废 提交于 2019-12-23 12:04:02
问题 I have taken over maintenance of a very large (>2M SLOC) software project, all written in C#. There is very little documentation. I am now wanting to make a change to a module that has public interfaces (about 400), but I don't know what all other modules (there are about 50 total) in the solution may be using this public interface. How would you create an interface dependency usage tree for a situation such as this? The codebase is too big to simply navigate the Project Explorer and read

PHP ↔ Perl interface or bindings

こ雲淡風輕ζ 提交于 2019-12-23 10:17:24
问题 What PHP ↔ Perl interface or bindings do you recommend? I need to be able to run Perl functions located in a Perl file from a PHP script and get the return values. I've already found the PECL "perl" package but I'm not sure how reliable it is since the last Subversion activity was ~12 months ago. I've also found the Perl module PHP::Interpreter that is supposed to work both ways according to an almost 3 year old tutorial, Integrating PHP and Perl . I would really appreciate it if you can

C# - How can I have an type that references any object which implements a set of Interfaces?

非 Y 不嫁゛ 提交于 2019-12-23 10:14:05
问题 How can I have a type reference that refers to any object that implements a set of interfaces? For example, I can have a generic type like this: Java: public class Foo<T extends A & B> { } C# public class Foo<T> where T : A, B { } That's how to have a class-wide generic type. However, I'd like to simply have a data member which references any object that extends a given set of interfaces. Example: public class Foo { protected <? extends A, B> object; public void setObject(<? extends A, B>

Making a button easier to click

痴心易碎 提交于 2019-12-23 09:26:04
问题 I have a button that on certain phones is too hard to click because of its size. But making it bigger breaks layout. It is possible to explain to a view that it has a bigger "click box" than its visible area? 回答1: Not sure if this can help: If you use an ImageButton with no background and you set a Padding value, your button will have a larger clickable area. <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/img_close" android:id="@

How to create an interface in Swift

女生的网名这么多〃 提交于 2019-12-23 09:14:56
问题 i want to create functionality like interface in swift, my goal is when i call another class suppose i'm calling API and the response of that class i want to reflect in to my current screen, in android interface is used to achieve but what should i use in swift for that? can anyone help me with example. the code for android is given below... public class ExecuteServerReq { public GetResponse getResponse = null; public void somemethod() { getResponse.onResponse(Response); } public interface