Blade.Compiler.Extensibility.ScriptObjectLiteralExtension.ValidateClass C# (CSharp) Method

ValidateClass() private method

private ValidateClass ( ClassDeclaration classDecl ) : void
classDecl ClassDeclaration
return void
        private void ValidateClass(ClassDeclaration classDecl)
        {
            if (classDecl.IsStatic)
                throw new CompilationException("A class using the [ScriptObjectLiteral] attribute cannot be declaraed static.", classDecl);

            if (classDecl.Constructors.Count > 0)
                throw new CompilationException("A class using the [ScriptObjectLiteral] attribute cannot contain constructors.", classDecl);

            if (classDecl.Methods.Count > 0)
                throw new CompilationException("A class using the [ScriptObjectLiteral] attribute cannot contain methods.", classDecl);

            if (classDecl.Events.Count > 0)
                throw new CompilationException("A class using the [ScriptObjectLiteral] attribute cannot contain events.", classDecl);

            if (classDecl.Properties.Any(p => !p.IsAutoProperty))
                throw new CompilationException("A class using the [ScriptObjectLiteral] attribute can only contain auto properties.", classDecl);

            if (classDecl.IsDerived)
                ValidateBaseClass(classDecl, classDecl.Definition.BaseClass);
        }