Click here to Skip to main content
15,899,474 members

Comments by macika123 (Top 26 by date)

macika123 29-Apr-16 13:48pm View    
Thank you!
macika123 29-Apr-16 13:39pm View    
Thank you for the nice answer! I really like the ServiceState enum. It's interesting that I use enums in different parts of the application, but forgot about, that I can use them here too. It looks cool in your code :) .

You were right, I should have added the original code or at least write an appropriate code snippet. I also modified the original question, which now has the original code, too.
macika123 28-Apr-16 20:21pm View    
Thank you!

I'm quite astonished, that I got three answers ( so far :) ).

To be honest, I've bad memories about doing this, because of one of the projects I worked on (but that's because that project was nightmare anyway ...).
When we got NullReferenceEx, we ended up craving through multiple function calls, because every function returned null, when it has some null variable in them. Again, it was probably the projects fault and in your answer it looks much more cleaner :)
macika123 28-Apr-16 19:54pm View    
As a current-final solution, I replaced the default constructor with a parametrised one - I must set the OtherService object when MyService is created.

Also replaced the auto-property with guarded ones, which throw InvalidOperationException when somebody tries to set them null.

Thanks again for your response :) .
macika123 28-Apr-16 19:22pm View    
Thank you!

I'm quite guilty for overthinking stuff and yet forgetting about smarter solutions. Your solution clarified lots of things and I really appreciate it :) .