private CodeTypeDeclaration GetClassDeclaration(ModelClass cls, CodeNamespace nameSpace) { if (cls == null) throw new ArgumentException("Class not supplied.", "cls"); if (String.IsNullOrEmpty(cls.Name)) throw new ArgumentException("Class name cannot be blank.", "cls"); CodeTypeDeclaration classDeclaration = CreateClass(cls.Name); if (cls.Model.UseBaseClass) { bool withValidator = cls.Properties.FindAll(delegate(ModelProperty property) { return property.IsValidatorSet(); }).Count > 0; CodeTypeReference type; // base class for every modelclass. If left empty then baseclass from model if left empty ...etc if (!string.IsNullOrEmpty(cls.BaseClassName)) type = new CodeTypeReference(cls.BaseClassName); else if (!string.IsNullOrEmpty(cls.Model.BaseClassName)) type = new CodeTypeReference(cls.Model.BaseClassName); else if (withValidator) type = new CodeTypeReference(Common.DefaultValidationBaseClass); else type = new CodeTypeReference(Common.DefaultBaseClass); if (cls.IsGeneric()) type.TypeArguments.Add(classDeclaration.Name); classDeclaration.BaseTypes.Add(type); } if (cls.DoesImplementINotifyPropertyChanged()) { classDeclaration.BaseTypes.Add(new CodeTypeReference(Common.INotifyPropertyChangedType)); AddINotifyPropertyChangedRegion(classDeclaration); } if (!String.IsNullOrEmpty(cls.Description)) classDeclaration.Comments.AddRange(GetSummaryComment(cls.Description)); classDeclaration.CustomAttributes.Add(cls.GetActiveRecordAttribute()); if (cls.Model.UseGeneratedCodeAttribute) classDeclaration.CustomAttributes.Add(AttributeHelper.GetGeneratedCodeAttribute()); // Make a note as "generated" to prevent recursive generation attempts CodeGenerationContext.AddClass(cls, classDeclaration); nameSpace.Types.Add(classDeclaration); return classDeclaration; }