1

I have created a Frame control - Frame1 under Class1:

public Frame<_> Frame1 { get; private set; }

And defined Class2 for frame page:

public class Class2<TPage> : Page<TPage> where TPage : Page<TPage>

When I call Frame1.SwitchTo<Class2>() I get a compile error:

Using generic type requires 1 type argument

Is there any way to resolve this?

I am defining Class2 as above as I want to define other classes inheriting Class2.

Ronan Boiteau
  • 9,608
  • 6
  • 34
  • 56

1 Answers1

0

If your Class2 page object type is a generic base page object, then it cannot be passed directly to SwitchTo method. You can pass only complete classes. For example you can create non-generic Class2 and pass it.

// Base page object.
public class Class2<TOwner> : Page<TOwner> where TOwner : Class2<TOwner>
{
}

public class Class2 : Class2<Class2>
{
}

public class AnotherClass2 : Class2<AnotherClass2>
{
}

This will allow you to pass Class2 to SwitchTo method:

Frame1.SwitchTo<Class2>()

or

Frame1.SwitchTo<AnotherClass2>()
Yevgeniy Shunevych
  • 1,136
  • 6
  • 11