public VSXmlTransaction( VSXmlModelProvider provider, XmlEditingScope editorTransaction) { _provider = provider; _editorTransaction = editorTransaction; }
internal VSXmlTransaction GetTransaction(XmlEditingScope editorTx) { VSXmlTransaction tx = null; if (!(_txDictionary.TryGetValue(editorTx, out tx))) { tx = new VSXmlTransaction(this, editorTx); _txDictionary[editorTx] = tx; } return(tx); }
internal VSXmlTransaction GetTransaction(XmlEditingScope editorTx) { VSXmlTransaction tx = null; if (!(_txDictionary.TryGetValue(editorTx, out tx))) { tx = new VSXmlTransaction(this, editorTx); _txDictionary[editorTx] = tx; } return tx; }
/// <summary> /// This method is called when it is time to save the designer values to the /// underlying buffer. /// </summary> /// <param name="undoEntry"></param> public void SaveModelToXmlModel(string undoEntry) { LanguageService langsvc = GetXmlLanguageService(); try { //We can't edit this file (perhaps the user cancelled a SCC prompt, etc...) if (!CanEditFile()) { DesignerDirty = false; BufferDirty = true; throw new Exception(); } if (!SearchDefaultTablesInModel()) { InsertDefaultTablesInModel(); } UpdateAttTypes(); UpdateSyncOrder(); XmlSerializer serializer = new XmlSerializer(typeof(model)); XDocument documentFromDesignerState = new XDocument(); using (XmlWriter w = documentFromDesignerState.CreateWriter()) { serializer.Serialize(w, XmlTemplateModel); } XDocument document = GetParseTree(_xmlModel); /*_synchronizing = true; * Source src = GetSource(); * if (src == null || langsvc == null) * { * return; * } * * langsvc.IsParsing = true; // lock out the background parse thread.*/ // Wrap the buffer sync and the formatting in one undo unit. /*using (CompoundAction ca = new CompoundAction(src, ResourceInfo.SynchronizeBuffer)) * {*/ using (XmlEditingScope scope = _xmlStore.BeginEditingScope(ResourceInfo.SynchronizeBuffer, this)) { //Replace the existing XDocument with the new one we just generated. document.Root.ReplaceWith(documentFromDesignerState.Root); document.Save(m_FileName); scope.Complete(); } /*ca.FlushEditActions(); * FormatBuffer(src); * } * DesignerDirty = false;*/ } catch (Exception ex) { // if the synchronization fails then we'll just try again in a second. _dirtyTime = Environment.TickCount; } /*finally * { * langsvc.IsParsing = false; * _synchronizing = false; * }*/ }