-4

I have class

class ManagerCar : IBlalba
{
   public void Render(IViewTemplate template)
   {
   }
}

and I know what the parameter template is CarViewTemplate I want check type and throw exception if IViewTemplate != CarViewTemplate

I can do check if(template is typeof(CarViewTemplate)).

But I have many Managers.

I want check this type on compilation and with help attribute like [IsType(typeof(CarViewTemplate))]

Is it possible ?

UPDATE I have interface with Render(IViewTemplate template)

Mediator
  • 14,951
  • 35
  • 113
  • 191

1 Answers1

2

This type of check already exists in the compiler, no need to try to help it.

Simply change your method signature to this:

public void RenderCar(CarViewTemplate template)
Lasse V. Karlsen
  • 380,855
  • 102
  • 628
  • 825
  • 2
    I'm actually assuming this answer is unusable, but the main problem here is that this information (that it is unusable) is not in any way or form spelled out in the question. I'm assuming there is a reason the OP cannot just change the code, but since this isn't spelled out, I want to provoke that information to appear. – Lasse V. Karlsen Jul 31 '13 at 16:17