jeudi 1 novembre 2018

Any way to further optimize this?

I'm looking for ways to reduce the number of lines of code for this function. Any help is appreciated!

private bool CanSubmitPackage ( object obj )
    {
        // ---- Checks if the package contains any files to be submitted ----
        if ( _selectedWorkspace.Package.Files != null )
        {
            if ( _selectedWorkspace.Package.Files.Count > 0 )
                if ( _selectedWorkspace.Package.Platform != null || _selectedWorkspace.Package.Platform != "" )
                    if ( _selectedWorkspace.Package.PackagePath != null || _selectedWorkspace.Package.PackagePath != "" )
                        if ( _selectedWorkspace.Package.PackageSize != null || _selectedWorkspace.Package.PackageSize != "" )
                            if ( _selectedWorkspace.Package.SubmittedBy != null || _selectedWorkspace.Package.SubmittedBy != "" )
                                return true;
                            else
                                return false;
                        else
                            return false;
                    else
                        return false;
                else
                    return false;
            else
                return false;
        }
        else
            return false;
    }

Aucun commentaire:

Enregistrer un commentaire