| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 | using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using UnivateProperties_API.Containers.Info;
using UnivateProperties_API.Model;
namespace UnivateProperties_API.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class InfoController : ControllerBase
    {
        [HttpGet]
        public IActionResult Get()
        {
            return new OkObjectResult("hallo");
        }
        [HttpGet("{name}")]
        public List<string> Get(string name)
        {
            List<string> list = new List<string>();
            var newClass = System.Reflection.Assembly.GetAssembly(typeof(BaseEntity)).CreateInstance(name);
            if(newClass is BaseEntity)
            {
                list = (newClass as BaseEntity).GetAllProperties().ToList();
            }
            return list;
        }
        [HttpGet("getAllClasses")]
        public List<ClassDto> GetAllClasses()
        {
            List<ClassDto> list = new List<ClassDto>();
            IEnumerable<BaseEntity> exporters = typeof(BaseEntity)
                .Assembly.GetTypes()
                .Where(t => t.IsSubclassOf(typeof(BaseEntity)) && !t.IsAbstract)
                .Select(t => (BaseEntity)Activator.CreateInstance(t));
            foreach(var item in exporters)
            {
                ClassDto cls = new ClassDto();
                list.Add(new ClassDto() { FullName = item.GetType().FullName.ToString(), Name = item.GetType().Name });
            }
            return list;
        }
    }
}
 |