private void DispatchLoadToExtensions() { if (Hierarchy != null) { var projectItem = VsUtils.GetProjectItem(Hierarchy, ItemId); if (projectItem != null) { var fileContents = VSHelpers.GetTextFromVsTextLines(VsBuffer); string newBufferContents; List <ExtensionError> extensionErrors; if (StandaloneXmlModelProvider.TryGetBufferViaExtensions( projectItem, fileContents, out newBufferContents, out extensionErrors)) { if (VSHelpers.CheckOutFilesIfEditable(ServiceProvider, new[] { FileName })) { VsUtils.SetTextForVsTextLines(VsBuffer, newBufferContents); } else { ErrorListHelper.LogExtensionErrors( new List <ExtensionError> { new ExtensionError( string.Format( CultureInfo.CurrentCulture, Resources.ExtensionError_SourceControlLock, Path.GetFileName(FileName)), ErrorCodes.ExtensionsError_BufferNotEditable, ExtensionErrorSeverity.Error) }, projectItem); } } } } }
// <summary> // Loads document in an temporary model manager to see if it is designer safe. // </summary> private static bool IsUnloadedDocumentDesignerSafe(Uri uri) { Debug.Assert(uri != null, "uri is null"); using (var tempModelManager = new EntityDesignModelManager(new EFArtifactFactory(), new VSArtifactSetFactory())) { using (var xmlModelProvider = new StandaloneXmlModelProvider(PackageManager.Package)) { var artifact = tempModelManager.GetNewOrExistingArtifact(uri, xmlModelProvider); Debug.Assert(artifact != null, "failed to get the artifact to determine if it is designer-safe"); if (artifact == null) { return(true); } artifact.DetermineIfArtifactIsDesignerSafe(); return(artifact.IsDesignerSafe); } } }