static ClassType GuessClassTypeByName(NamingConventionService service, AstNode node)
 {
     if (node is SimpleType)
     {
         return(GuessClassTypeByName(service, ((SimpleType)node).Identifier));
     }
     if (node is IdentifierExpression)
     {
         return(GuessClassTypeByName(service, ((IdentifierExpression)node).Identifier));
     }
     return(ClassType.Class);
 }
 static ClassType GuessClassTypeByName(NamingConventionService service, string identifier)
 {
     if (service == null)
     {
         return(ClassType.Class);
     }
     if (service.IsValidName(identifier, AffectedEntity.Interface, Modifiers.Public))
     {
         return(ClassType.Interface);
     }
     if (!service.IsValidName(identifier, AffectedEntity.Class, Modifiers.Public) &&
         service.IsValidName(identifier, AffectedEntity.Struct, Modifiers.Public))
     {
         return(ClassType.Struct);
     }
     return(ClassType.Class);
 }
        static TypeDeclaration CreateType(RefactoringContext context, NamingConventionService service, AstNode node, ClassType classType)
        {
            TypeDeclaration result;

            if (node is SimpleType)
            {
                result = CreateClassFromType(context, classType, (SimpleType)node);
            }
            else if (node is ObjectCreateExpression)
            {
                result = CreateClassFromObjectCreation(context, (ObjectCreateExpression)node);
            }
            else
            {
                result = CreateClassFromIdentifier(context, classType, (IdentifierExpression)node);
            }

            return(AddBaseTypesAccordingToNamingRules(context, service, result));
        }
 static TypeDeclaration AddBaseTypesAccordingToNamingRules(RefactoringContext context, NamingConventionService service, TypeDeclaration result)
 {
     if (service.HasValidRule(result.Name, AffectedEntity.CustomAttributes, Modifiers.Public))
     {
         result.BaseTypes.Add(context.CreateShortType("System", "Attribute"));
     }
     else if (service.HasValidRule(result.Name, AffectedEntity.CustomEventArgs, Modifiers.Public))
     {
         result.BaseTypes.Add(context.CreateShortType("System", "EventArgs"));
     }
     else if (service.HasValidRule(result.Name, AffectedEntity.CustomExceptions, Modifiers.Public))
     {
         result.BaseTypes.Add(context.CreateShortType("System", "Exception"));
     }
     return(result);
 }
 public GatherVisitor(BaseRefactoringContext ctx) : base(ctx)
 {
     service = (NamingConventionService)ctx.GetService(typeof(NamingConventionService));
 }