Example #1
0
        public static School GetObject()
        {
            School s = new School()
            {
                name = "北京一零一中", address = "北京市海淀区圆明园遗址", phone = "0108888666", classitems = new List <ClassItems>()
            };
            Random r = new Random();

            for (int i = 0; i < 1; i++)
            {
                ClassItems c = new ClassItems()
                {
                    grade = string.Format("高中{0}年级", i.ToString()), students = new List <Student>(), teachers = new List <Teacher>()
                };
                for (int j = 0; j < 1; j++)
                {
                    c.teachers.Add(new Teacher()
                    {
                        id = i * 10 + j, name = "教师" + (i * 10 + j), age = r.Next(18, 60), course = "课程" + j.ToString(), sex = (sbyte)r.Next(0, 1), introduce = "北京101中学教师" + (i * 10 + j)
                    });
                }
                for (int j = 0; j < 1; j++)
                {
                    c.students.Add(new Student()
                    {
                        id = i * 10 + j, name = "教师" + (i * 10 + j), age = r.Next(14, 20), sex = (sbyte)r.Next(0, 1), introduce = "北京101中学学生" + (i * 10 + j), fatherName = "父亲" + (i * 10 + j), motherName = "母亲" + (i * 10 + j)
                    });
                }
                s.classitems.Add(c);
            }

            s.Set();
            return(s);
        }
Example #2
0
        private void MapJson()
        {
            if (ClassItems?.Any() != true)
            {
                service = new GeneratorService
                {
                    Example               = Json,
                    MainClass             = MainClass,
                    Namespace             = DefaultNamespace,
                    PropertyAttribute     = UseJsonProperty ? "JsonProperty" : "",
                    AlwaysUsePublicValues = UsePublicValues
                };

                service.GenerateClasses();
            }

            HandleGeneratedClasses(service);
        }
 private ClassItem GetClassItem(string className)
 {
     return(ClassItems
            .FirstOrDefault(m => m.ClassName.Equals(className, StringComparison.OrdinalIgnoreCase)));
 }