public static DocumentNode GetParsedOrSniffedRootNode(IProjectItem projectItem, IProjectContext projectContext) { if (projectItem.Document != null) { SceneDocument sceneDocument = projectItem.Document as SceneDocument; if (sceneDocument != null && sceneDocument.DocumentRoot != null) { return(sceneDocument.DocumentRoot.RootNode); } } DocumentContext documentContext = DocumentContextHelper.CreateDocumentContext((IProject)projectContext.GetService(typeof(IProject)), projectContext, DocumentReferenceLocator.GetDocumentLocator(projectItem.DocumentReference)); IType type = DocumentContextHelper.SniffRootNodeType(projectItem, documentContext); if (type != null && type.RuntimeType != (Type)null) { return((DocumentNode)documentContext.CreateNode((ITypeId)type)); } return((DocumentNode)null); }