Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If I understand your question correctly, you want to force a class to implement a number of different interfaces, the list of interfaces will grow with time but will have some properties in common.</p> <p>The common property part you have solved with your <code>IService</code> interface. Something like this, I presume</p> <pre><code>interface IService { DateTime LastRuntime { get; set; } } interface IGetAlarms : IService { string GetAlarms(); } interface IGetDiagnostics : IService { string GetDiagnostics(); } </code></pre> <p>The growing list of interfaces that a class will have to implement you can also solve in a similar fashion. Create a "composite" interface which inherits from all the interfaces you wish your class to implement</p> <pre><code>interface IComposite : IGetAlarms, IGetDiagnostics {} class MyClass : IComposite { ... } </code></pre> <p>When you let the <code>IComposite</code> interface inherit a new interface, the class will have implement the new interface too.</p> <p>EDIT</p> <p>In response to your clarification; in that case you should not share the specification of the <code>LastRuntim</code>e property, but declare it in each individual interface. In the implementing class you can use <code>Explicit interface member implementation</code></p> <pre><code>class MyClass : IComposite { DateTime IGetAlarms.LastRuntime { get; set; } DateTime IGetDiagnostics.LastRuntime { get; set; } ... } </code></pre> <p>However, AFAIK it is not possible to force the implementing class to explicitly implement each individual interface</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload