title: Read class data from object?
body: <p>I have a class named Document <code>DocumentViewer</code> in my selenium project which contains method named <code>CancelAndClose</code> and it returns an object. This method is accessed by four different objects. So the main idea behind using this <code>method</code> is to return the exact type of <code>object</code>(with a parameter) that called this <code>method</code>.</p>
  
  <p>Here is the body of <code>DocumentViewer</code> class:</p>
  
  <pre><code>public class DocumentViewer
  {
      private IWebDriver _driver;
  
      private object _startedFrom;
  
      public DocumentViewer(IWebDriver driver, object startedFrom)
      {
          _driver = driver;
          _startedFrom = startedFrom;
          //CODE TO CHECK WHETHER IS DRIVER IS IN THE RIGHT PAGE
          }
      }
  
      public object CancelAndClose()
      {
          //I USE A CUSTOM METHOD FOR FINDING THE RIGHT WINDOW HANDLE AND RETURN IT BELOW
          return new OneOfTheFourClasses(_driver);
      }
  }
  </code></pre>
  
  <p>So my question is, how do I find the original class of the object <code>_startedFrom</code> and set it in the place of <code>OneOfTheFourClasses</code> ?</p>
  
  <p>EDIT: This <code>DocumentViewer</code> is a page object and also <code>TheFourClasses</code> as well.</p>