interface

C# Use Generics to Call Overridden Method

拈花ヽ惹草 提交于 2019-12-23 05:15:32
问题 I think I am a bit mixed up at this point, but I can't seem to be able to solve this issue. I have an Interface ILinkHandler<T> and 4 other handler classes (inheriting from that interface) that validate different structures of links. From that interface, I have a Task<List<T>> Validate() function that does the validation of links and returns a Task> of results. Depending on T , I return a different model on Validate() (I have 4 different models). My console app does the following. It calls

Use an interface from an external assembly that's marked as “internal” (C#)

我的未来我决定 提交于 2019-12-23 04:47:23
问题 I'd like to implement an interface that resides in an external assembly. However that particular interface has been marked as "internal". Is there a way I can still implement this interface for my own classes? I know how to call private/internal methods using reflection in C#, so I guess reflection should be used in this case too. However, I don't know how. And yes, I do know it usually isn't wise to use internal/private stuff, but in this case I see no other solution. Update: I'm not able to

Why the forEach method in Iterable interface is not abstract? [duplicate]

孤街醉人 提交于 2019-12-23 04:43:39
问题 This question already has answers here : Interface with default methods vs Abstract class in Java 8 (15 answers) Closed 2 years ago . When I see the Iterable interface source, it looks like the foreach method and Spliterator methods are not abstract. How an interface can have non abstract methods? Or is there anything I am missing in this? See the Iterbale interface source below. package java.lang; import java.util.Iterator; import java.util.Objects; import java.util.Spliterator; import java

How to implement multi interfaces from a jar file in java? [duplicate]

久未见 提交于 2019-12-23 04:30:18
问题 This question already has answers here : Implementing multiple interfaces with Java - is there a way to delegate? (4 answers) Closed 3 years ago . I have created a class and import my interfaces but how to do the rest, what should I do? Here I have anything but it doesn't work I mean ClassCastExeption doesn't work code example : import java.util.LinkedList; import java.util.Queue; import com.revmetrix.code_test.linkify_queue.ProcessingQueue; import com.revmetrix.code_test.linkify_queue

Efficiently Propagating Interface Changes in Visual Studio

偶尔善良 提交于 2019-12-23 04:26:45
问题 As I delve into the world of decoupling and dependency injection, I'm finding myself writing more and more interfaces. I try my best to create interfaces knowing exactly how I'm going to use them, but there's always the case that I end up implementing the interface and then changing how it's used. I've become accustomed to VS' automatic refactoring ability. But I've found that it doesn't support propagating interface changes automatically to the implementing classes. Is there a way to do this

Can't implement OnCheckedChangeListener? [duplicate]

隐身守侯 提交于 2019-12-23 03:37:09
问题 This question already has answers here : I can't create an onCheckedChanged listener for my RadioGroup (3 answers) Closed 6 years ago . I've a question. Here is my code: public class MyCheckBox extends CheckBox implements OnCheckedChangeListener { public MyCheckBox(Context context, AttributeSet attrs) { super(context, attrs); // TODO Auto-generated constructor stub } But "onCheckedChangeListener" can't be implemented ( eclipse marks as red squiggly line). It says "Import

Are traits and interfaces binary compatible?

你离开我真会死。 提交于 2019-12-23 03:36:15
问题 I've just kind of surprised by the fact that Scala is binary incompatible across different releases. Now, since in Java 8 we have default method implementations which is pretty much the same as trait s provide us with is it safe to use traits in Java code? I tried to use it myself as this: trait TestTrait { def method(v : Int) def concrete(v : Int) = println(v) } public class Test implements TestTrait{ // Compile-error. Implement concrete(Int) @Override public void method(int v) { System.out

Adding events to an interface / implementation

筅森魡賤 提交于 2019-12-23 03:22:26
问题 Know this has been asked before, however my question is slightly different. I have an interface: IEmailDispatcher It looks like this: public interface IEmailDispatcher { void SendEmail(string[] to, string fromName, string fromAddress, string subject, string body, bool bodyIsHTML, Dictionary<string, byte[]> Attachments); } As a bit of background: I have a static EmailDispatcher class that has the method: SendEmail(string[] to, string fromName, string fromAddress, string subject, string body,

Adding events to an interface / implementation

北城余情 提交于 2019-12-23 03:22:12
问题 Know this has been asked before, however my question is slightly different. I have an interface: IEmailDispatcher It looks like this: public interface IEmailDispatcher { void SendEmail(string[] to, string fromName, string fromAddress, string subject, string body, bool bodyIsHTML, Dictionary<string, byte[]> Attachments); } As a bit of background: I have a static EmailDispatcher class that has the method: SendEmail(string[] to, string fromName, string fromAddress, string subject, string body,

Why can an array of references to an interface house classes that implement that interface?

a 夏天 提交于 2019-12-23 02:59:09
问题 I've read a number of threads explaining the differences between Interfaces and Abstract Classes; these posts in particular was very helpful: What is the difference between an interface and abstract class? and Interface vs Abstract Class (general OO); however, I couldn't find any answers that specifically addressed my question. Context: Today in class we wrote an interface and two classes that implement the interface: public interface Animal{ // This is in its own file void move(); void