Exemple #1
0
        internal static PropertyInfo[] DefinirPropriedadesCustomizadas <T>(Parametros campos)
        {
            if (campos.Propriedades != null)
            {
                Type tipo                 = typeof(T);
                var  propriedades         = tipo.GetProperties();
                List <PropertyInfo> props = new List <PropertyInfo>();

                props.Add(RecuperarChavePrimaria <T>());

                foreach (var i in propriedades)
                {
                    if (i.PropertyType.FullName.Substring(0, 6) == "System")
                    {
                        if (i.PropertyType.FullName.Length >= 18)
                        {
                            if (i.PropertyType.FullName.Substring(0, 18) != "System.Collections")
                            {
                                if (campos.Propriedades == null)
                                {
                                    props.Add(i);
                                }
                                else
                                {
                                    foreach (var c in campos.Propriedades)
                                    {
                                        if (c == i.Name)
                                        {
                                            props.Add(i);
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (campos.Propriedades == null)
                            {
                                props.Add(i);
                            }
                            else
                            {
                                foreach (var c in campos.Propriedades)
                                {
                                    if (c == i.Name)
                                    {
                                        props.Add(i);
                                    }
                                }
                            }
                        }
                    }
                }


                PropertyInfo[] array = new PropertyInfo[props.Count];
                int            index = 0;
                foreach (var i in props)
                {
                    if (index == 0)
                    {
                        array[0] = i;
                        index++;
                    }
                    else
                    {
                        array[index] = i;
                        index++;
                    }
                }

                return(array);
            }
            else
            {
                return(null);
            }
        }