|
using System;
using System.Collections.Generic;
using System.Text;
namespace CodeAnalysisTools
{
public enum CodeAnalysisActivityType
{
None,
FindNotUsed,
FindDuplicateMethods,
FindCircularDependencies,
FindSubClasses,
GetNamespaces
}
public abstract class CodeAnalysisActivity
{
public delegate void OnEventCallback(object[] args, CodeAnalysisActivityType taskType);
public delegate void OnProgressUpdate(int total, int current);
private OnEventCallback onEventCallback = null;
private OnProgressUpdate onProgressUpdate = null;
private CodeAnalysisActivityType thisTaskType = CodeAnalysisActivityType.None;
internal CodeAnalysisActivity(OnEventCallback onEventCallback, OnProgressUpdate onProgressUpdate, CodeAnalysisActivityType taskType)
{
this.onEventCallback = onEventCallback;
this.onProgressUpdate = onProgressUpdate;
this.thisTaskType = taskType;
}
public abstract void Run(object[] args);
protected void CallProgressUpdate(int total, int current)
{
if (this.onProgressUpdate != null)
this.onProgressUpdate(total, current);
}
protected void CallEventCallback(object[] args)
{
if (this.onEventCallback != null)
this.onEventCallback(args, thisTaskType);
}
public static CodeAnalysisActivity CreateTask(CodeAnalysisActivityType taskType, OnEventCallback onEventCallback, OnProgressUpdate onProgressUpdate)
{
switch (taskType)
{
case CodeAnalysisActivityType.FindNotUsed:
throw new NotImplementedException("Invalid Analysis Task Requested");
//return new FindNotUsed(onEventCallback, onProgressUpdate);
case CodeAnalysisActivityType.FindDuplicateMethods:
return new FindDuplicateMethods(onEventCallback, onProgressUpdate);
case CodeAnalysisActivityType.FindCircularDependencies:
throw new NotImplementedException("Invalid Analysis Task Requested");
//return new FindCircularDependencies(onEventCallback, onProgressUpdate);
case CodeAnalysisActivityType.GetNamespaces:
throw new NotImplementedException("Invalid Analysis Task Requested");
//return new GetNamespaceHierarchy(onEventCallback, onProgressUpdate);
case CodeAnalysisActivityType.FindSubClasses:
throw new NotImplementedException("Invalid Analysis Task Requested");
default:
throw new ArgumentException("Invalid Analysis Task Requested");
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I have been a professional developer since 1996. My experience comes from many different industries; Data Mining Software, Consulting, E-Commerce, Wholesale Operations, Clinical Software, Insurance, Energy.
I started programming in the military, trying to find better ways to analyze database data, eventually automating my entire job. Later, in college, I automated my way out of another job. This gave me the great idea to switch majors to the only thing that seemed natural…Programming!