Click here to Skip to main content
15,347,244 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
AnswerRe: code sexiness question Pin
OriginalGriff29-Nov-21 22:38
mveOriginalGriff29-Nov-21 22:38 
GeneralRe: code sexiness question Pin
Richard Deeming29-Nov-21 22:54
mveRichard Deeming29-Nov-21 22:54 
GeneralRe: code sexiness question Pin
OriginalGriff29-Nov-21 23:22
mveOriginalGriff29-Nov-21 23:22 
AnswerRe: code sexiness question Pin
11917640 Member 30-Nov-21 0:19
Member11917640 Member 30-Nov-21 0:19 
GeneralRe: code sexiness question Pin
Andre_Prellwitz2-Dec-21 5:07
MemberAndre_Prellwitz2-Dec-21 5:07 
AnswerRe: code sexiness question Pin
Gerry Schmitz30-Nov-21 10:55
mveGerry Schmitz30-Nov-21 10:55 
GeneralRe: code sexiness question Pin
Andre_Prellwitz2-Dec-21 12:12
MemberAndre_Prellwitz2-Dec-21 12:12 
AnswerRe: code sexiness question Pin
Gary R. Wheeler30-Nov-21 12:02
MemberGary R. Wheeler30-Nov-21 12:02 
I would have done things this way:
C#
private IMultipleComponentHandler SelectionHandler
{
    get
    {
        if (m_selectionHandler == null)
        {
            if (SelectedObject is IMultipleComponentHandler handler)
            {
                m_selectionHandler = handler;
            }

            else
            {
                object[] collection;
                
                if (SelectedObject is IEnumerable e
                    && !SelectedObject.GetAttributes<IgnoreIEnumerableAttribute>().Any())
                {
                    collection = e as object[] ?? e.Cast<object>().ToArray();
                }
                else if (SelectedObject != null)
                {
                    collection = new[] { SelectedObject };
                }
                else
                {
                    collection = Array.Empty<object>();
                }

                m_selectionHandler = new InspectorMultipleComponentHandler(collection);
            }
        }
        
        return m_selectionHandler;
    }
}
private IMultipleComponentHandler m_selectionHandler;
I'm an old fart who prefers single-exit Big Grin | :-D .
Software Zen: delete this;

AnswerRe: code sexiness question Pin
Fueled By Decaff1-Dec-21 3:02
MemberFueled By Decaff1-Dec-21 3:02 
GeneralRe: code sexiness question Pin
Daniele Rota Nodari1-Dec-21 3:18
MemberDaniele Rota Nodari1-Dec-21 3:18 
GeneralRe: code sexiness question Pin
englebart2-Dec-21 12:51
professionalenglebart2-Dec-21 12:51 
GeneralRx DevOps Pin
BillWoodruff29-Nov-21 18:46
mveBillWoodruff29-Nov-21 18:46 
GeneralThis song is stuck in my head and it keeps seeming more relevant Pin
honey the codewitch29-Nov-21 13:51
mvahoney the codewitch29-Nov-21 13:51 
GeneralRe: This song is stuck in my head and it keeps seeming more relevant Pin
Super Lloyd29-Nov-21 16:05
MemberSuper Lloyd29-Nov-21 16:05 
GeneralRe: This song is stuck in my head and it keeps seeming more relevant Pin
honey the codewitch29-Nov-21 16:36
mvahoney the codewitch29-Nov-21 16:36 
GeneralRe: This song is stuck in my head and it keeps seeming more relevant Pin
Super Lloyd29-Nov-21 18:30
MemberSuper Lloyd29-Nov-21 18:30 
AdminThere's no survey because... Pin
Chris Maunder29-Nov-21 11:52
cofounderChris Maunder29-Nov-21 11:52 
GeneralRe: There's no survey because... Pin
PIEBALDconsult29-Nov-21 12:04
professionalPIEBALDconsult29-Nov-21 12:04 
GeneralRe: There's no survey because... Pin
Chris Maunder29-Nov-21 19:02
cofounderChris Maunder29-Nov-21 19:02 
GeneralRe: There's no survey because... Pin
Peter_in_278029-Nov-21 12:28
professionalPeter_in_278029-Nov-21 12:28 
GeneralRe: There's no survey because... Pin
Marc Clifton29-Nov-21 13:11
mvaMarc Clifton29-Nov-21 13:11 
GeneralRe: There's no survey because... Pin
CodeWraith29-Nov-21 17:36
MemberCodeWraith29-Nov-21 17:36 
GeneralRe: There's no survey because... Pin
Chris Maunder29-Nov-21 19:02
cofounderChris Maunder29-Nov-21 19:02 
GeneralRe: There's no survey because... Pin
Chris Maunder29-Nov-21 19:00
cofounderChris Maunder29-Nov-21 19:00 
GeneralRe: There's no survey because... Pin
Randor 29-Nov-21 13:27
professional Randor 29-Nov-21 13:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Straw Poll

You discover a sentient AI in your org's system. What do you do?
Well you never know what sort of orphaned projects previous employees have left behind...
  Results   594 votes