/// <summary>    
        /// </summary>
        /// <param name="model"></param>
        public ModelClassDefinitionViewModel(ModelClassDefinition model)
        {
            _model = model;

            Properties = _model.FieldDefinitions
                .OrderBy(field => field.Name)
                .Where(field => !field.Inherited)
                .Select(field => new PropertyDefinitionViewModel(field))
                .ToList();

            Generate = true;
        }
Exemple #2
0
        private CodeTypeDeclaration GenerateWorkItemTypeClass(ModelClassDefinition classDefinition)
        {
            var wiTypeClass = new CodeTypeDeclaration(classDefinition.ClassName)
            {
                // ReSharper disable once BitwiseOperatorOnEnumWithoutFlags
                Attributes = MemberAttributes.Public | MemberAttributes.Final,
                IsPartial  = true,
                IsClass    = true
            };

            wiTypeClass.BaseTypes.Add(typeof(GenericWorkItem));

            wiTypeClass.CustomAttributes.Add(new CodeAttributeDeclaration(
                                                 new CodeTypeReference(typeof(WorkItemTypeAttribute)),
                                                 new CodeAttributeArgument(new CodePrimitiveExpression(classDefinition.WorkItemType))));


            if (!string.IsNullOrEmpty(classDefinition.Description))
            {
                var comment = new CodeComment($"<summary>{classDefinition.Description}</summary>", true);
                wiTypeClass.Comments.Add(new CodeCommentStatement(comment));
            }


            //GenerateConstructor(wiTypeClass);

            var sortedFields = from field in classDefinition.FieldDefinitions
                               orderby field.Name
                               select field;

            foreach (var fieldDefinition in sortedFields)
            {
                if (_fieldToIgnoreList.Contains(fieldDefinition.ReferenceName))
                {
                    continue;
                }

                GenerateField(wiTypeClass, fieldDefinition);
            }
            return(wiTypeClass);
        }