Natavia Finnie
asked on
Remove this useless object instantiation of class in C# or use it -- Help
I am not directly following why I am getting this as a Major Bug from my Sonar scan at both lines where this (new SynchronizationTokenMonito r...) is being called.
Result from SonarQube scan:
Either remove this useless object instantiation of class 'SynchronizationTokenMonit or' or use it.
here is the call that is coming from another method:
Result from SonarQube scan:
Either remove this useless object instantiation of class 'SynchronizationTokenMonit
here is the call that is coming from another method:
AddSynchronizationTokenToOutboundPages(context);
private static void AddSynchronizationTokenToOutboundPages(HttpContext context) {
if (context.Handler != null) {
if (context.Handler is Page){
new SynchronizationTokenMonitor(context.Handler as Page);
}
else if (context.Handler is TASK.Web.PageHandlerBase) {
new SynchronizationTokenMonitor(((TASK.Web.PageHandlerBase)context.Handler).PageControl as UserControl);
}
}
}
public class SynchronizationTokenMonitor
{
public SynchronizationTokenMonitor(Page page)
{
if (page != null) {
page.PreRender += PagePreRender;
page.Load += PageLoad;
}
}
public SynchronizationTokenMonitor(UserControl control)
{
if (control != null)
{
control.PreRender += ControlPreRender;
control.Load += ControlLoad;
}
}
}
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.