interface

Class inheriting from several Interfaces having same method signature

江枫思渺然 提交于 2019-12-21 10:20:01
问题 Say, I have three interfaces: public interface I1 { void XYZ(); } public interface I2 { void XYZ(); } public interface I3 { void XYZ(); } A class inheriting from these three interfaces: class ABC: I1,I2, I3 { // method definitions } Questions: If I implement like this: class ABC: I1,I2, I3 { public void XYZ() { MessageBox.Show("WOW"); } } It compiles well and runs well too! Does it mean this single method implementation is sufficient for inheriting all the three Interfaces? How can I

What does it mean to put DataMemberAttribute on interface member?

这一生的挚爱 提交于 2019-12-21 09:29:24
问题 What does it mean to put a DataMemberAttribute on an interface member? How does this affect derived classes? 回答1: As shown in the following signature, the DataMember attribute is not inheritable [AttributeUsageAttribute(AttributeTargets.Property|AttributeTargets.Field, Inherited = false, AllowMultiple = false)] public sealed class DataMemberAttribute : Attribute Therefore, it makes very little sense to decorate interface members with this attribute as you will have to decorate the

COM Interface Guid

孤人 提交于 2019-12-21 09:09:24
问题 I'm not much into COM interfaces, so i have a small question, say I have this code: [Guid("148BD528-A2AB-11CE-B11F-00AA00530503"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] internal interface IEnumWorkItems { [PreserveSig()] int Next([In] uint RequestCount, [Out] out System.IntPtr Names, [Out] out uint Fetched); void Skip([In] uint Count); void Reset(); void Clone([Out, MarshalAs(UnmanagedType.Interface)] out IEnumWorkItems EnumWorkItems); } How do I know that "148BD528-A2AB-11CE

Implementing interface C#

荒凉一梦 提交于 2019-12-21 09:08:25
问题 I'm not new to C#, but I have found a behavior that is a little puzzling. I have an interface public interface IApplicationPage { Person ThePerson { get; set; } Application Application { get; set; } } I implement the interface on a page public partial class tripapplication2 : System.Web.UI.Page, IApplicationPage { Person IApplicationPage.ThePerson { get; set; } Application IApplicationPage.IApplicationPage.Application { get; set; } } However, when I attempt to reference ThePerson in the page

Casting object to interface type with no TInterfacedObject as base class

爷,独闯天下 提交于 2019-12-21 09:07:17
问题 I need a class implementing interface with no reference counting. I did the following: IMyInterface = interface(IInterface) ['{B84904DF-9E8A-46E0-98E4-498BF03C2819}'] procedure InterfaceMethod; end; TMyClass = class(TObject, IMyInterface) protected function _AddRef: Integer;stdcall; function _Release: Integer;stdcall; function QueryInterface(const IID: TGUID; out Obj): HResult;stdcall; public procedure InterfaceMethod; end; procedure TMyClass.InterfaceMethod; begin ShowMessage('The Method');

PhpDoc for interface and class implementing interface - difference [closed]

走远了吗. 提交于 2019-12-21 08:07:52
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed last year . The question is quite simple - how should I differ phpdoc for interface and for class implementing interface? Should/Can they be the same or maybe interface documentation should be as general as possible and class implementing this interface more specific? I include one method

Is programming against interfaces in Java the same concept as using header files in C/C++?

我的梦境 提交于 2019-12-21 07:55:16
问题 The java code I'm working on at the moment has often a structure like file Controller.java: interface Controller {...} file ControllerImpl.java: class ControllerImpl implements Controller {...} But for every interface there is only one implementation. Isn't that the same as using header files in C/C++ where I have the code split into files like Controller.hpp Controller.cpp From what I know, header files in C/C++ have been introduced to help the compiler, which is not necessary anymore in

Where to define the interfaces for a repository in an layered architecture?

只愿长相守 提交于 2019-12-21 07:30:10
问题 Background I'm trying to create a simple application to really understand the whole stack of DDD+TDD+etc. My goal is to dynamically inject the DAL repository classes at runtime. This keeps my Domain and Application Services layers testable. I plan on using "poor man's DI" to accomplish this for now ... so I would do this in a simple Console application near startup: // Poor man's DI, injecting DAL repository classes at runtime var productRepository = new SimpleOrder.Repository

Where to define the interfaces for a repository in an layered architecture?

拥有回忆 提交于 2019-12-21 07:30:07
问题 Background I'm trying to create a simple application to really understand the whole stack of DDD+TDD+etc. My goal is to dynamically inject the DAL repository classes at runtime. This keeps my Domain and Application Services layers testable. I plan on using "poor man's DI" to accomplish this for now ... so I would do this in a simple Console application near startup: // Poor man's DI, injecting DAL repository classes at runtime var productRepository = new SimpleOrder.Repository

Can a child class implement the same interface as its parent?

余生长醉 提交于 2019-12-21 07:12:08
问题 I've never encountered this issue before today and was wondering what convention/best practice for accomplish this kind of behavior would be. Basic setup is this: public interface IDispatch { void Dispatch(); } public class Foo : IDispatch { void IDispatch.Dispatch() { DoSomething(); } } public class Bar : Foo { ... } Bar needs to subclass Foo because it shares all the same properties as Bar plus introduces 2 new ones that I need to encounter for. The problem I have is that Foo also needs a