Пример #1
0
        static TypeDeclaration CreateClassFromType(RefactoringContext context, SimpleType simpleType)
        {
            TypeDeclaration result;
            string          className = simpleType.Identifier;

            if (simpleType.Parent is Attribute)
            {
                if (!className.EndsWith("Attribute"))
                {
                    className += "Attribute";
                }
            }

            result = new TypeDeclaration()
            {
                Name = className
            };
            var entity = simpleType.GetParent <EntityDeclaration>();

            if (entity != null)
            {
                result.Modifiers |= entity.Modifiers & ~Modifiers.Internal;
            }

            return(result);
        }
Пример #2
0
        static TypeDeclaration CreateClassFromType(RefactoringContext context, ClassType classType, SimpleType simpleType)
        {
            TypeDeclaration result;
            string          className = simpleType.Identifier;

            if (simpleType.Parent is Attribute && classType == ClassType.Class)
            {
                if (!className.EndsWith("Attribute", System.StringComparison.Ordinal))
                {
                    className += "Attribute";
                }
            }

            result = new TypeDeclaration {
                Name = className, ClassType = classType
            };
            var entity = simpleType.GetParent <EntityDeclaration>();

            if (entity != null)
            {
                result.Modifiers |= entity.Modifiers & Modifiers.Public;
            }

            var guessedType = TypeGuessing.GuessType(context, simpleType);

            if (guessedType.Kind == TypeKind.TypeParameter)
            {
                ImplementConstraints(context, result, (ITypeParameter)guessedType);
            }
            return(result);
        }
        static TypeDeclaration CreateClassFromType(RefactoringContext context, ClassType classType, SimpleType simpleType)
        {
            TypeDeclaration result;
            string className = simpleType.Identifier;

            if (simpleType.Parent is Attribute && classType == ClassType.Class) {
                if (!className.EndsWith("Attribute", System.StringComparison.Ordinal))
                    className += "Attribute";
            }

            result = new TypeDeclaration { Name = className, ClassType = classType };
            var entity = simpleType.GetParent<EntityDeclaration>();
            if (entity != null)
                result.Modifiers |= entity.Modifiers & Modifiers.Public;

            var guessedType = CreateFieldAction.GuessType (context, simpleType);
            if (guessedType.Kind == TypeKind.TypeParameter)
                ImplementConstraints (context, result, (ITypeParameter)guessedType);
            return result;
        }
        static TypeDeclaration CreateClassFromType(RefactoringContext context, SimpleType simpleType)
        {
            TypeDeclaration result;
            string className = simpleType.Identifier;

            if (simpleType.Parent is Attribute) {
                if (!className.EndsWith("Attribute", System.StringComparison.Ordinal))
                    className += "Attribute";
            }

            result = new TypeDeclaration() { Name = className };
            var entity = simpleType.GetParent<EntityDeclaration>();
            if (entity != null)
                result.Modifiers |= entity.Modifiers & Modifiers.Public;

            return result;
        }