title: MVVMCross Platform specific class that has method which returns instance of same class
body: <p><strong>Background:</strong> I'm trying to integrate Firebase into my MVVMCross app using its platform specific SDK's. The basic part of my setup is working, namely I can use the basic Firebase features to retrieve info from a Firebase database from within my viewmodel. It uses an interface in my PCL that has platform specific implementations in the UI projects.</p>
  
  <p><strong>Problem:</strong> I would like to, however, implement a method in my interface (and its implementations) that can deal with the fact that the Java SDK of Firebase has a class called "Firebase" with methods that return the same type ("Firebase"), such as the "Child" method in the Java SDK:</p>
  
  <pre><code>Firebase firebase = new Firebase("URI");
  Firebase firebasechild = firebase.Child("test"); // Of same type!
  firebasechild.DoStuff();
  </code></pre>
  
  <p>I'm trying to get similar functionality in my viewmodel:</p>
  
  <pre><code>firebase = Mvx.Resolve&lt;IFirebaseConnection&gt; ();
  firebase.FirebaseConnection ("URI");
  IFirebaseConnection firebasechild = firebase.Child("test");
  firebasechild.DoStuff();
  </code></pre>
  
  <p>The relevant part of my interface in my PCL is:</p>
  
  <pre><code>public interface IFirebaseConnection
  {
      void FirebaseConnection (string URI);
  
      IFirebaseConnection Child(string child); // Probably wrong?
  
      void DoStuff();
  }
  </code></pre>
  
  <p>My setup.cs in my Android UI project contains:</p>
  
  <pre><code>Mvx.RegisterType&lt;IFirebaseConnection, FirebaseDroid&gt;();
  </code></pre>
  
  <p>The platform specific implementation in Android is:</p>
  
  <pre><code>public class FirebaseDroid : IFirebaseConnection
  {
      protected Firebase firebase;
  
      public void FirebaseConnection (string URI)
      {
          var mvxTopActivity = Mvx.Resolve&lt;IMvxAndroidCurrentTopActivity&gt;();
          Firebase.SetAndroidContext (mvxTopActivity.Activity);
          firebase = new Firebase (URI);
      }
  
      public IFirebaseConnection Child (string child)
      {
          return firebase.Child (child); // This is obviously wrong
      }
  
      public void DoStuff(){// do something}
  }
  </code></pre>
  
  <p>The above is obviously wrong since <code>firebase.Child()</code> is of type "Firebase" and not "IFirebaseConnection", or probably more correctly "FirebaseDroid". Is there a way to deal with methods of the same type as the class it is in when implementing platform specific services?</p>