public static GameReference CreateNew(GameDocument subDoc) { if (subDoc == null) { throw new ArgumentNullException("subDoc"); } string fileName = System.IO.Path.GetFileName(subDoc.Uri.LocalPath); DomNode gameRefNode = new DomNode(Schema.gameReferenceType.Type); gameRefNode.SetAttribute(Schema.gameReferenceType.nameAttribute, fileName); gameRefNode.SetAttribute(Schema.gameReferenceType.refAttribute, subDoc.Uri); GameReference gameRef = gameRefNode.As <GameReference>(); gameRef.m_target = subDoc.Cast <IGame>(); subDoc.Cast <Game>().SetParent(gameRef); gameRef.m_error = string.Empty; return(gameRef); }