razordotnetnuke2sxc

In DNN with 2sxc v16.03+, how can I get access to the older Razor14 while converting to RazorTyped?


I have a couple of recently created Views inheriting from Custom.Hybrid.Razor14. I thought it would be fairly easy to update to .RazorTyped and then work my way through the errors. However, its become a bit complicated. Especially when I get to errors without line numbers and have trouble understanding where the error is taking place (what needs to change).

So I thought it might be possible to implement a Razor14 object like this

@inherits Custom.Hybrid.RazorTyped
@{
  // converting from Razor14 to RazorTyped
  var _R14 = new Custom.Hybrid.Razor14();
...

and use it like this on the old code...

  var help = _R14.CreateInstance("AccuHelper.cs");

  var qSubmissions = _R14.AsList(App.Query["Submissions (Live Forms)"])
    .Where(s => s.CreatedOn >= DateTime.Today.AddDays(-90))
  ;
...

But as you know (and I didn't), this isn't possible and I get the following error CS0144: "Cannot create an instance of the abstract class or interface 'Razor14' at..."

Is there a way to do this? I understand that its an abstract class, but I don't understand what the class is that I need to 'new'. Can I instantiate the old class/object properly so that I more easily get the page working again then work through the changes to RazorTyped one at a time?

Or, does 2sic/2sxc (or anyone yet) have a recommended way of working through these conversions (for less advanced, less knowledgeable programmer-wannabes)?


Solution

  • There is no real way to do what you're describing.

    What you can do is still use Partials of other razors - which for example are not yet converted. So you could have some partials already in RazorTyped and others still in Razor14.

    I recommend you wait another ca. 2 weeks as we're still tweaking the APIs and creating various samples https://2sxc.org/dnn-tutorials/en/razor/quick-ref-typed/page which will help a lot.