interface

Specify interface member not by name but type

拜拜、爱过 提交于 2019-12-12 12:34:57
问题 I have a lot of similar classes generated by svcutil from some external WSDL file. Any class has a Header property and string property which named class name + "1" . For instance, I have classes: SimpleRequest that has Header property and SimpleRequest1 property. Another one is ComplexRequest that has Header property and ComplexRequest1 property. So, I want to create a common interface for such classes. So, basically I can define something like that: interface ISomeRequestClass { string

Is the signedness of char an interface issue?

北战南征 提交于 2019-12-12 12:12:53
问题 Suppose I have a function void foo(char *) which, internally, needs to treat its input as a block of NUL-terminated bytes (say, it's a hash function on strings). I could cast the argument to unsigned char* in the function. I could also change the declaration to void foo(unsigned char *) Now, given that char , signed char and unsigned char are three different types, would this constitute an interface change, under any reasonable definition of the term "interface" in C? (This question is

c++ cli interface event explicit implementation

霸气de小男生 提交于 2019-12-12 12:12:41
问题 I am trying to convert c# code into c++/cli. Everything went smoothly until i started translating interface event explicit implementations into c++/cli syntax. Let's say in c# i have this interface public interface Interface { public event MyEventHandler Event; } Which is implemented in Class in explicit way, so it doesn't conflict with another member by its name: public interface Class : Interface { event MyEventHandler Interface.Event; public event AnotherEventHandler Event; } I am trying

How to prevent having to update all implementing classes after updating an interface?

痞子三分冷 提交于 2019-12-12 11:28:14
问题 We have a WPF application which is primarily a charting application. There are approximately 30 charts. Each chart has its own table in a database which holds configuration information for the chart. Each chart has an class in the app containing configuration information related to the chart. We have an interface in our app ( IChartConfiguration ) which each chart configuration class implements. It allows the app to work with any particular chart configuration in a consistent and similar

C# call an interface method non-virtual implementation

牧云@^-^@ 提交于 2019-12-12 11:19:51
问题 I am new to C# and I don't understand why compiler does not complain on this code. Here is the hierarchy of classes: interface IAble { void f(); } class AAble : IAble { public void f() { Debug.Log("---->> A - Able"); } } class BAble : AAble { public void f() { Debug.Log("---->> B - Able"); } } execution code: IAble i = new BAble(); i.f(); On execution ---->> A - Able was printed. Why? How the compiler knows what function should be called? When the decision is made of what function to call -

how to pass interface type to procedure

浪子不回头ぞ 提交于 2019-12-12 11:08:09
问题 how to I pass interface type to over procedure parameter ? type Hello_PortType = interface(ISoapInvokable) ['{243CBD89-8766-F19D-38DF-427D7A02EAEE}'] function GetDeneme(s: string): string; end; SoapCall(Hello_PortType , 'http://localhost:8080/wsdl/ITDeneme'); then how to get TypeInfo using with saopcall method variable ? function TLib.SoapCall(Intf: Variant; Addr: string): ISoapInvokable; var RIO: THTTPRIO; begin InvRegistry.RegisterInterface(TypeInfo(Intf), 'urn:DenemeIntf-IDeneme', ''); //-

Was the “interface” keyword removed from Dart?

眉间皱痕 提交于 2019-12-12 10:51:35
问题 Just to be sure, has Dart removed explicitly defining an interface now in favor of implicitly defining it via abstract ? I see it mentioned in Dart and Interface Segregation Principle, however I'm also finding a lot of content still referencing the explicit definition, such as When to use interfaces in Dart? 回答1: Yes. The interface keyword was removed from Dart. Instead all classes have implicit interfaces. So if you want to define an interface you can use an abstract class instead. See this

Should methods that implement pure virtual methods of an interface class be declared virtual as well?

这一生的挚爱 提交于 2019-12-12 10:37:09
问题 I read different opinions about this question. Let's say I have an interface class with a bunch of pure virtual methods. I implement those methods in a class that implements the interface and I do not expect to derive from the implementation. Is there a need for declaring the methods in the implementation as virtual as well? If yes, why? 回答1: No - every function method declared virtual in the base class will be virtual in all derived classes. But good coding practices are telling to declare

Interface for method that returns its own type

北城余情 提交于 2019-12-12 10:36:24
问题 I have a situation where i have a class class Foo { Foo Bar() { return new Foo(); } } Now i wan tot create an interface for it class IFoo { ??? Bar(); } What should be in place of the question marks? Each class should return it's own type, not Foo. The solutions below work but do not looks clean. I don't understand why i have to specify the same class twice, and there is nothing like "this" for the current type This is how i am using it later class GenericClass<T> where T : IFoo { T foo = new

Are single implementer interfaces for unit testing an antipattern?

夙愿已清 提交于 2019-12-12 10:32:04
问题 In regards to unit testing, I was taught that production code shouldn't have test-related code in it. Well, I feel like I'm breaking that rule every time I try to unit test. I have a class internal to my assembly, Xyzzy . I want to dependency inject it into another class and then stub it so I can test that the other class in isolation, so I make an interface, IXyzzy . Oops, now I have code in production that's really only there for test. Even worse, I've kind of gone against what interface is