Quantcast
Channel: Developer to developer
Viewing all articles
Browse latest Browse all 9076

Suspicious cast there is no type in the solution which is inherited from both 'BlockData' and 'IContent'

$
0
0

Hi all,

the code below causes "Suspicious Cast" warning. Nevertheless everything works.

if(contentRepository.TryGet<FormContainerBlock>(copyContentEventArgs.ContentLink, out var formContainerBlock))
{
    var writableFormContainerBlock = formContainerBlock.CreateWritableClone() as IContent;

    ...

    contentRepository.Save(writableFormContainerBlock, SaveAction.Publish);

}

The point is that without "as IContent" part, I could not call "Save" since it's requiring first parameter to be "IContent". And if I put "IContent" in "TryGet<>" instead of "FormContainerBlock", I then can't call "CreateWritableClone()" method.


Viewing all articles
Browse latest Browse all 9076