Ejemplo n.º 1
0
        /// <summary>
        /// Helper method to determine if an IDataObject is valid
        /// for dropping on the tree view. It must be a the drop
        /// of a single file with a valid assembly file type.
        /// </summary>
        /// <param name="data">IDataObject to be tested</param>
        /// <returns>True if dropping is allowed</returns>
        private bool IsValidFileDrop(IDataObject data)
        {
            if (!data.GetDataPresent(DataFormats.FileDrop))
            {
                return(false);
            }

            string [] fileNames = data.GetData(DataFormats.FileDrop) as string [];

            if (fileNames == null || fileNames.Length == 0)
            {
                return(false);
            }

            // We can't open more than one project at a time
            // so handle length of 1 separately.
            if (fileNames.Length == 1)
            {
                string fileName  = fileNames[0];
                bool   isProject = Services.UserSettings.GetSetting("Options.TestLoader.VisualStudioSupport", false)
                                        ? NUnitProject.CanLoadAsProject(fileName)
                                        : NUnitProject.IsProjectFile(fileName);

                return(isProject || PathUtils.IsAssemblyFileType(fileName));
            }

            // Multiple assemblies are allowed - we
            // assume they are all in the same directory
            // since they are being dragged together.
            foreach (string fileName in fileNames)
            {
                if (!PathUtils.IsAssemblyFileType(fileName))
                {
                    return(false);
                }
            }

            return(true);
        }
 protected override bool IsValidParameter(string parm)
 {
     return(NUnitProject.CanLoadAsProject(parm) || PathUtils.IsAssemblyFileType(parm));
 }