interface

C# Generics / Interfaces - Returning different types based on the class

我们两清 提交于 2019-12-11 02:37:40
问题 For work, we have specific types of records that come in, but each project has its own implementation. The columns and the like are different, but in general the process is the same (records are broken into batches, batches are assigned, batches are completed, batches are returned, batches are sent out, etc.). Many of the columns are common, too, but sometimes there are name changes (BatchId in one vs Id in another. [Column("name")] takes care of this issue). Currently this is what I have for

Comparing with a private interface

这一生的挚爱 提交于 2019-12-11 02:26:12
问题 I have two objects. key1 is of type *rsa.PublicKey . key2 is of type *ssh.PublicKey which is an interface hiding a *ssh.rsaPublicKey object. ssh.rsaPublicKey is defined as: type ssh.rsaPublicKey rsa.PublicKey And it has a few extra methods. However, I can't cast either key to an ssh.rsaPublicKey since that class is "not exported", I can't cast key2 to an rsa.PublicKey since that doesn't implement ssh.PublicKey , and I can't access the N or e from key2 because I am not supposed to know I have

Java generic programming with unknown generic type of interface

☆樱花仙子☆ 提交于 2019-12-11 02:18:54
问题 I'm using several interfaces with generics types. While combining it together I have some problems when I have to use them from a part of the code that is unaware of the concrete type of the generic parameter. Suppose I have the following interface: public interface MyObjectInterface<T extends Number> {} The object implementing that interfaceare stored in a generic collection with the same generic type: public interface MyCollectioninterface<T extends Number> { public void updateObject

C# Pass a Class as a parameter

怎甘沉沦 提交于 2019-12-11 02:18:26
问题 I have an Interface, that has some methods interface IFunction { public double y(double x); public double yDerivative(double x); } and I've got static classes, that are implementing it. static class TemplateFunction:IFunction { public static double y(double x) { return 0; } public static double yDerivative(double x) { return 0; } } I want to pass this classes as a parameter to another function. AnotherClass.callSomeFunction(TemplateFunction); And some other class that catches the request

Golang convert json with variable types to strings

你。 提交于 2019-12-11 02:14:32
问题 I am reading in json from an API response and I ran into an issue in that there are multiple data types inside the json values (strings, null, bool). In addition, some keys have values which can be either a string or null which makes reading the data into types more difficult. I want to convert everything to strings for ease of handling. I created a type switch based on googling other examples. I am wondering if this is the easiest way to do this or if I am missing a simpler approach. package

Java interface extends interface in the java.util package

心不动则不痛 提交于 2019-12-11 02:03:58
问题 As we know, interfaces can extend interface in the Java. I have a question about this, if interface B extends interface A, B need not implement the methods defined in the A. But in the java.util package, the List interface extends Collection interface, and it implements the Collection method, these methods also just have the method declaration. Why does it do this, and it there a better practice? Does it make any difference between implementing the method in the sub interface or not? 回答1:

Override / Disable super-interface method

白昼怎懂夜的黑 提交于 2019-12-11 01:36:44
问题 Consider the interfaces public interface SuperInterface { public void execute(Map<String,object> argument); } public interface SubInterface extends SuperInterface { public void execute(Argument extra , Map<String,Object> args); } Is it possible to completely override SuperInterfaces.execute with SubInterface.execute even though it has different arguments ? OR Am I doing it wrong ? What is the right way to design this spec ? 回答1: Is it possible to completely override SuperInterfaces.execute

Should concrete implementation provide any public API not present in the interface it implements?

只愿长相守 提交于 2019-12-11 01:25:09
问题 " Code to interfaces " is considered good practice. Such code is easy to unit test and enables loose coupling. Users only know the interfaces and the onus of wiring concrete objects is upon the top-most level (this can be done in some init code or with the help of frameworks). My question is about following the practice of code to interfaces : does it imply that a concrete class can never declare any public method which is not present in its interface? Otherwise, it will force users to depend

Adding a Listener to a Google Map

十年热恋 提交于 2019-12-11 00:38:00
问题 In Xamarin, how do I add an OnInfoWindowClickListener to a Google map? I have read that: You can use an OnInfoWindowClickListener to listen to click events on an info window. To set this listener on the map, call GoogleMap.setOnInfoWindowClickListener(OnInfoWindowClickListener). When a user clicks on an info window, onInfoWindowClick(Marker) will be called The resource is here: https://developers.google.com/maps/documentation/android/infowindows This is the interface code I have added: public

Can I specify interfaces when I declare a member?

你离开我真会死。 提交于 2019-12-11 00:07:22
问题 I need a member of my class to be a Control, and for it to implement an interface we define. If I declare it like this... public class MyClass { public Control MyMember; } ... then I don't get the interface methods, but if I declare it like this... public class MyClass { public IMyInterface MyMember; } ...then I don't get the Control methods. Is there a way to specify that MyMember must be initialised to a type that inherits from both? I can't find one on MSDN. Something like... public class