using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ZionRobot.Models.ADVISE
{
    public class IntimacoesCollection
    {
        public List<Intimacao> Intimacoes { get; set; }
    }

    public class Intimacao
    {
        public string Diario { get; set; }
        public string Processo { get; set; }
        public string PublicacaoEm { get; set; }
        public string Comarca { get; set; }
        public string Vara { get; set; }
        public string DisponibilizacaoEm { get; set; }
        public string PalavraChave { get; set; }
        public string Caderno { get; set; }
        public string Contratante { get; set; }
        public string Usuario { get; set; }
        public string Edicao { get; set; }
        public string PaginaInicial { get; set; }
        public string PaginaFinal { get; set; }
        public string Despacho { get; set; }
        public string Conteudo { get; set; }

        public string GetParamValue(string paramName)
        {
            Object obj = this;

            string[] nameParts = paramName.Split('.');
            if (nameParts.Length == 1)
            {
                object propertyValue = obj.GetType().GetProperty(paramName).GetValue(obj);
                return propertyValue is null ? string.Empty : propertyValue.ToString();
            }

            foreach (String part in nameParts)
            {
                if (obj == null)
                    break;

                Type type = obj.GetType();
                System.Reflection.PropertyInfo info = type.GetProperty(part);

                if (info == null)
                    break;

                obj = info.GetValue(obj, null);
            }

            return obj.ToString();
        }


    }
}
