src/Misc/EFTools/EntityDesign/VisualStudio/Package/ConnectionManager.cs
// <summary>
//     After removing a *.config file, the connection manager should clear the internal connection string hash table
// </summary>
After removing a *.config file, the connection manager should clear the internal connection string hash table
After removing a * . config file the connection manager should clear the internal connection string hash table
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
        private int OnAfterRemoveFile(object sender, ModelChangeEventArgs args)
        {
            if (args.ProjectObj == null)
            {
                Debug.Fail("Could not find the project object to attempt to clear the connection manager's hashtable if necessary");
                return VSConstants.E_INVALIDARG;
            }
            if (String.IsNullOrEmpty(args.OldFileName))
            {
                Debug.Fail(
                    "We are trying to figure out if we should clear the connection manager's hashtable if the file is a *.config, but where is the filename?");
                return VSConstants.E_INVALIDARG;
            }
            if ((VsUtils.GetApplicationType(Services.ServiceProvider, args.ProjectObj) == VisualStudioProjectSystem.WindowsApplication &&
                 Path.GetFileName(args.OldFileName).Equals(VsUtils.AppConfigFileName, StringComparison.CurrentCultureIgnoreCase))
                || (VsUtils.GetApplicationType(Services.ServiceProvider, args.ProjectObj) != VisualStudioProjectSystem.WindowsApplication &&
                    Path.GetFileName(args.OldFileName).Equals(VsUtils.WebConfigFileName, StringComparison.CurrentCultureIgnoreCase)))
            {
                lock (_hashSyncRoot)
                {
                    try
                    {
                        _connStringsByProjectHash.Clear();
                        _connStringsByProjectHash = null;
                    }
                    catch (Exception)
                    {
                        return VSConstants.E_FAIL;
                    }
                }
            }
            return VSConstants.S_OK;
        }
[ SuppressMessage ( " " , " " ) ] private int OnAfterRemoveFile ( object sender , ModelChangeEventArgs args ) { if ( args . ProjectObj == null ) { Debug . Fail ( " " ) ; return VSConstants . E_INVALIDARG ; } if ( String . IsNullOrEmpty ( args . OldFileName ) ) { Debug . Fail ( " " ) ; return VSConstants . E_INVALIDARG ; } if ( ( VsUtils . GetApplicationType ( Services . ServiceProvider , args . ProjectObj ) == VisualStudioProjectSystem . WindowsApplication && Path . GetFileName ( args . OldFileName ) . Equals ( VsUtils . AppConfigFileName , StringComparison . CurrentCultureIgnoreCase ) ) || ( VsUtils . GetApplicationType ( Services . ServiceProvider , args . ProjectObj ) != VisualStudioProjectSystem . WindowsApplication && Path . GetFileName ( args . OldFileName ) . Equals ( VsUtils . WebConfigFileName , StringComparison . CurrentCultureIgnoreCase ) ) ) { lock ( _hashSyncRoot ) { try { _connStringsByProjectHash . Clear ( ) ; _connStringsByProjectHash = null ; } catch ( Exception ) { return VSConstants . E_FAIL ; } } } return VSConstants . S_OK ; }
After removing a *.config file, the connection manager should clear the internal connection string hash table
After removing a * . config file the connection manager should clear the internal connection string hash table
sender
object
args
ModelChangeEventArgs