interface

“Standard simple” interfaces in Java?

我的未来我决定 提交于 2019-12-24 06:07:03
问题 So here in Java I've written a typical class, to send json to a rest server. (I'll include the whole class below for clarity.) So that's a file "Fetcher.java" Now for the callback you need an interface. The interface is trivial, just one function with a string. public interface FetcherInterface { public void fetcherDone(String result); } Annoyingly you need a whole file for that, "FetcherInterface.java" So this interface is nothing but "one callback with a string". Often all you need is just

How to extend a primitive type in typescript?

China☆狼群 提交于 2019-12-24 05:47:10
问题 I want to create an interface like this: interface Show { show(): string; } function doit(s: Show) { return 'Showed: ' + s.show(); } Then we can use it with a new class: class Foo { s: string; constructor(s: string) { this.s = s; } show() { return 'Foo with "' + this.s + '"'; } } console.log(doit(new Foo('hello'))); I'd like to do the same thing for Number s. In plain JavaScript I could make the type Number , for example, satisfy this interface with: Number.prototype.show = function() {

Check if Class Implements a Specific Interface

浪子不回头ぞ 提交于 2019-12-24 05:24:10
问题 in ActionScript 3.0, there are a few ways to check a class's extension. for example, if i want to know of a custom class extends Sprite i could use the is operator: trace(MyClass is Sprite); or i could use flash.utils.getQualifiedSuperclassName : trace(getQualifiedSuperclassName(MyClass)); i would like to accept a class as an argument and check to see if the passed class implements an certain interface. is there an equally simple or common way to check if my custom class adheres to an

Cascading generic interfaces

爱⌒轻易说出口 提交于 2019-12-24 04:40:25
问题 I am building my own framework to wrap the interfaces exposed via Microsoft.Office.Interop . I wrap Office-wide functionalities into a first set of interfaces, which are then inherited by a second set of functionalities, which are application-dependent. Here is a simplified version: Region "Office Wrappers" Interface IApplication(Of T As IFile(Of IVariable)) Property Files As IList(Of T) End Interface Interface IFile(Of T As IVariable) Property Variables As IList(Of T) End Interface Interface

How to declare an event handler in an interface?

我的未来我决定 提交于 2019-12-24 04:34:08
问题 I have a few Silverlight 4 UI objects (Navigation Pages more like it) that have to implement two things: OnError event handler, and Refresh() method. So I tried the following: public interface IDynamicUI { event EventHandler<ErrorEventArgs> OnError; void Refresh(); } public class ErrorEventArgs : EventArgs { public string Message { get; set; } public Exception Error { get; set; } } but the compiler gives me errors saying that fields cannot be declared inside public interfaces. Well the

Why cant I expose an implemented interface method?

♀尐吖头ヾ 提交于 2019-12-24 04:14:17
问题 I've been trying out some n-tier architecture and im really wondering why this code wont compile... It says the modifier public is not valid for this item. But why not? I need to be able to access the item IRepository.AddString() from a BLL object but it just wont let me make it public.... using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { BLL myBLL = new BLL(); } } interface

Solving multiple interface implementation

天涯浪子 提交于 2019-12-24 03:12:19
问题 I am in this situation where my service interface is being implemented by two service classes. For example, IFooService is implemented by FooService and FooWithExtraInfoService Here is the interface: public interface IFooService { Foo GetEntity(string fieldName, stringFieldValue); } Here is FooService : public class FooService: BarService, IFooService { public FooService(ILogService logservice): base(logservice) { } public Foo GetEntity(string fieldName, string fieldValue) { //here goes the

Scrollbars for Infinite Document?

限于喜欢 提交于 2019-12-24 02:19:05
问题 Is there a standard Aqua way to handle a practically infinite document? For example, imagine a level editor for a tile-based game. The level has no preset size (though it's technically limited by NSInteger 's size); tiles can be placed anywhere on the grid. Is there a standard interface for scrolling through such a document? I can't simply limit the scrolling to areas that already have tiles, because the user needs to be able to add tiles outside that boundary. Arbitrarily creating a level

EJB3 - Session Bean calling method of another bean interface

笑着哭i 提交于 2019-12-24 02:16:11
问题 I have a little question... I search the difference in local access between accessing a method that is only declared in the remote interface of a bean and not in the local interface... does the interface declaration (remote or local) determine the access protocol of the method? or does the ejb container understand that both beans are running the same JVM? is there a big performance difference? Do you have any source about this? BR's Laurent 回答1: I would suggest testing it on your EJB

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

ε祈祈猫儿з 提交于 2019-12-24 02:03:08
问题 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 *)indexPath { static NSString *CellIdentifier = @"TwitterCell"; TwitterCell *cell = (TwitterCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil)