I'm not sure where you are going with the ToString idea, here's a run-down on what I was getting at.
As part of your main application class you want something like:
public class MyApp : Autodesk.Revit.UI.IExternalApplication
{
public static Autodesk.Revit.DB.Document DbDoc; // The current database document
// other code goes here...
}
Then at the biginning of each command that runs in your application you want to store away the current document like so:
public class MyCommand : IExternalCommand
{
public Autodesk.Revit.UI.Result Execute(ExternalCommandData commandData, ref String message, ElementSet elements)
{
MyApp.DbDoc = commandData.Application.ActiveUIDocument.Document; // Update the static field to hold current database document
// Your code here...
}
}
Now, wherever you are in your code you can reference the current document using MyApp.DbDoc as long as it was first updated when the command was executed.
I must stress though that the above example is quite simplistic and depending on who you ask it is also bad software design as it is basically a global variable that could be corrupted accidentally by any part of your code. That said, I use a more sophisticated and safer version of the above in my addins without issue. It is much more friendly than the alternative which involves passing the the DB.Document into every method that you write if it is even remotely possible that the method might need to either use it directly or call another method that needs it.
Having the DB.Document object cached in this way also makes it simple to access the rest of the API from other parts of your code without having to directly cache them. A few examples are:
UI.Document uiDoc = new UIDocument(MyApp.DbDoc);
Creation.Document createDoc = MyApp.DbDoc.Create;
ApplicationServices.Application servicesApp = MyApp.DbDoc.Application;
Creation.Application createApp = MyApp.DbDoc.Application.Create;
For bonus points you can create static properties that return the above objects using the cached Document object (MyApp.UiDoc, MyApp.CreateDoc, etc).