Note that there are some explanatory texts on larger screens.

plurals
  1. POFind class with a specific property value - and then create instance of this class
    primarykey
    data
    text
    <p>I have the following class sample:</p> <pre><code>public class ExceptionOne : BaseException { //Define the error bit the exception represents public static int ErrorBitNumber = 1234; public ExceptionOne() { //Do something in the ctor } } </code></pre> <p>(<em>There is no relevant functionality in <code>BaseException</code> so its not necessary to show the code ;)</em> )</p> <p>Further there are other exception classes with the property called <code>ErrorBitNumber</code> but with other values for the property <code>ErrorBitNumber</code>. Each exception class represents an errorbitnumber - so there is always one class for one errorbitnumber.</p> <p>As i never know which errorbitnumber i receive (<em>if i receive one</em>) i want to implement the following --></p> <ul> <li>Go thru each existing class which derives from <code>BaseException</code> and look for the received error bit number</li> <li>If class is found, create an instance of the specific class (<em>fill some further properties or something</em>)</li> <li>Throw it</li> </ul> <p>I know that this should be possible to implement by using reflection - but truly i don't know how. Further i think using the <code>ErrorBitNumber</code> as <code>public static</code> should be the right approach. If not, feel free to correct me.</p> <p><strong>Update 1:</strong></p> <p>For understanding: We have header files which will be parsed. In this header files there are errors defined. For each error a exception class with the specific errorbitnumber will be created. So on the lowest tier in the architecture i receive an error bit number and have to throw the specific exception which represents the specific errorbitnumber</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.
 

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