src/Misc/EFTools/EntityDesignPackage/CustomCode/MicrosoftDataEntityDesignDocData.cs
/// <summary>
///     DSL exposes the FileNameChanged event which we subscribe to so we can update the moniker inside
///     the text buffer, which is required to update our model as well as keep the XmlModel in sync.
///     NOTE: this function will ONLY get called when the document is open in the designer (when there is
///     a document data open in the running document table)
/// </summary>
DSL exposes the FileNameChanged event which we subscribe to so we can update the moniker inside
the text buffer, which is required to update our model as well as keep the XmlModel in sync.
NOTE: this function will ONLY get called when the document is open in the designer (when there is
a document data open in the running document table)
DSL exposes the FileNameChanged event which we subscribe to so we can update the moniker inside the text buffer which is required to update our model as well as keep the XmlModel in sync . NOTE : this function will ONLY get called when the document is open in the designer ( when there is a document data open in the running document table )
protected void OnFileNameChanged(object sender, EventArgs e)
        {
            var buffer = _underlyingBuffer as VSTextManagerInterop.IVsTextLines;
            Debug.Assert(buffer != null, "There is no underlying buffer in order to correctly change the filename");
            if (buffer != null)
            {
                var ud = buffer as VSTextManagerInterop.IVsUserData;
                Debug.Assert(
                    ud != null, "Cannot change the moniker associated with the buffer because there is no IVsUserData associated with it");
                if (ud != null)
                {
                    var GUID_VsBufferMoniker = typeof(VSTextManagerInterop.IVsUserData).GUID;
                    object oldFileNameObject;
                    var hr = ud.GetData(ref GUID_VsBufferMoniker, out oldFileNameObject);
                    if (NativeMethods.Succeeded(hr))
                    {
                        hr = ud.SetData(ref GUID_VsBufferMoniker, FileName);
                        var oldFileName = oldFileNameObject as string;
                        if (PackageManager.Package != null
                            && NativeMethods.Succeeded(hr)
                            && oldFileName != null)
                        {
                            PackageManager.Package.OnFileNameChanged(oldFileName, FileName);
                        }
                    }
                }
            }
        }
protected void OnFileNameChanged ( object sender , EventArgs e ) { var buffer = _underlyingBuffer as VSTextManagerInterop . IVsTextLines ; Debug . Assert ( buffer != null , " " ) ; if ( buffer != null ) { var ud = buffer as VSTextManagerInterop . IVsUserData ; Debug . Assert ( ud != null , " " ) ; if ( ud != null ) { var GUID_VsBufferMoniker = typeof ( VSTextManagerInterop . IVsUserData ) . GUID ; object oldFileNameObject ; var hr = ud . GetData ( ref GUID_VsBufferMoniker , out oldFileNameObject ) ; if ( NativeMethods . Succeeded ( hr ) ) { hr = ud . SetData ( ref GUID_VsBufferMoniker , FileName ) ; var oldFileName = oldFileNameObject as string ; if ( PackageManager . Package != null && NativeMethods . Succeeded ( hr ) && oldFileName != null ) { PackageManager . Package . OnFileNameChanged ( oldFileName , FileName ) ; } } } } }
DSL exposes the FileNameChanged event which we subscribe to so we can update the moniker inside
the text buffer, which is required to update our model as well as keep the XmlModel in sync.
DSL exposes the FileNameChanged event which we subscribe to so we can update the moniker inside the text buffer which is required to update our model as well as keep the XmlModel in sync .
// get the old filename from the buffer // set the new filename into the buffer so the XmlModel is satisfied when it tries to RegisterAndLock // send off notification to the package so anything else can subscribe to an event from there
sender
object
e
EventArgs