using System;
using System.Text.RegularExpressions;
using AnticipatingMinds.Genesis.KnowledgeManagement;
using AnticipatingMinds.Genesis.CodeDOM;
using AnticipatingMinds.Genesis.CodeParser;
using System.Threading;
using AnticipatingMinds.Genesis.CodeDOM.Utilities;
using System.Windows.Forms;
namespace AnticipatingMinds.KnowledgePack.Design{
public class DesignUtils
{
public static bool CSharpNames(string name)
{
if(Regex.IsMatch(name,@"^[_A-Za-z][_A-Za-z0-9.]*$") &&
!Regex.IsMatch(name, @"[.][0-9]*[.]")&&
!Regex.IsMatch(name, @"[.][0-9]*$"))
{
return true;
}
else
{
System.Windows.Forms.MessageBox.Show(ResourceManager.GetLocalizedString("Design|SuggestedValue", name)
, "Exception", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
return false;
}
}
public static CodeTypeReferenceCollection GetBases(CodeTypeDeclaration typeDeclaration)
{
CodeTypeReferenceCollection basesCollection;
if(typeDeclaration is CodeStructDeclaration)
{
basesCollection = (typeDeclaration as CodeStructDeclaration).Interfaces;
}
else if(typeDeclaration is CodeClassDeclaration)
{
basesCollection = (typeDeclaration as CodeClassDeclaration).BaseTypes;
}
else
{
basesCollection = new CodeTypeReferenceCollection();
}
return basesCollection;
}
public static bool CheckNoreAnalyzedClasses(CodeTypeInfo typeInfo, CodeElement codeElement, System.Collections.ArrayList NotBeAnalyzedClassesList)
{
if(typeInfo == null) return false;
string typeFullName = typeInfo.FullName ;
foreach(ExcludedDisposableClasses notBeAnalyzedClasses in NotBeAnalyzedClassesList)
{
if(notBeAnalyzedClasses == null) continue;
if(!notBeAnalyzedClasses.Directly)
{
string classTypeName = (Type.GetType(notBeAnalyzedClasses.ClassName) != null) ? Type.GetType(notBeAnalyzedClasses.ClassName).FullName : notBeAnalyzedClasses.ClassName ;
if(classTypeName == typeFullName)
{
return false;
}
}
else if(notBeAnalyzedClasses.Directly)
{
if(codeElement.GetAssemblyTypeManager().IsTypeSubclassOf(typeFullName, notBeAnalyzedClasses.ClassName))
{
return false;
}
}
}
return true;
}
public static void ShowMessage(string caption, string message)
{
MessageBox.Show(message, caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
|