/// <summary>
        /// This method is called when it is time to save the designer values to the
        /// underlying buffer.
        /// </summary>
        /// <param name="undoEntry"></param>
        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();
                }

                //PopulateModelFromReferencesBindingList();
                //PopulateModelFromContentBindingList();

                XmlSerializer serializer = new XmlSerializer(typeof(VSTemplate));
                XDocument     documentFromDesignerState = new XDocument();
                using (XmlWriter w = documentFromDesignerState.CreateWriter())
                {
                    serializer.Serialize(w, _vstemplateModel);
                }

                _synchronizing = true;
                XDocument document = GetParseTree();
                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, Resources.SynchronizeBuffer))
                {
                    using (XmlEditingScope scope = _xmlStore.BeginEditingScope(Resources.SynchronizeBuffer, this))
                    {
                        //Replace the existing XDocument with the new one we just generated.
                        document.Root.ReplaceWith(documentFromDesignerState.Root);
                        scope.Complete();
                    }
                    ca.FlushEditActions();
                    FormatBuffer(src);
                }
                DesignerDirty = false;
            }
            catch (Exception)
            {
                // if the synchronization fails then we'll just try again in a second.
                _dirtyTime = Environment.TickCount;
            }
            finally
            {
                langsvc.IsParsing = false;
                _synchronizing    = false;
            }
        }
 public override void Commit()
 {
     _editorTransaction.Complete();
 }
Exemple #3
0
        /// <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;
             * }*/
        }