Exemplo n.º 1
0
        /// <summary>
        /// Classe Interfaces
        /// </summary>
        /// <param name="NomeTabela"></param>
        /// <param name="NameSpace"></param>
        /// <returns></returns>
        public string CriandoInterfaces(string NomeTabela, string NameSpace, string NameSchema)
        {
            Using            = string.Empty;
            NameSpaceProjeto = string.Empty;
            NomeClasse       = string.Empty;
            Atributo         = string.Empty;

            NomeTabelaSemSchema = string.Empty;

            if (NameSchema.Equals(NomeTabela.Substring(0, 3)))
            {
                var _NomeTabela   = NomeTabela.Remove(0, 3);
                var _PrimeiroNome = _NomeTabela.Substring(0, 1);
                var _RestoNome    = NomeTabela.Remove(0, 4);
                NomeTabelaSemSchema = _PrimeiroNome + _RestoNome.ToLower();
            }
            else
            {
                //var _NomeTabela = NomeTabela.Remove(0, 3);
                var _PrimeiroNome = NomeTabela.Substring(0, 1);
                var _RestoNome    = NomeTabela.Remove(0, 1);
                NomeTabelaSemSchema = _PrimeiroNome + _RestoNome.ToLower();
            }

            dir = new Diretorio();
            string _NameSpacesFisico = path + dir.DirInfraInterfacesFisico(NameSpace);
            string _NameSpacesLogico = dir.DirInfraInterfacesLogico(NameSpace);

            NaoExisteClasse = _NameSpacesFisico + "I" + NomeTabelaSemSchema + ".cs";

            //// Determine whether the directory exists.
            //if (Directory.Exists(@path))
            //{
            //    ExisteArquivo = System.IO.File.Exists(NaoExisteClasse);
            //    if (ExisteArquivo)
            //        return "Essa classe já existe.";
            //}

            Using += "using SEACore.Infra.Entidades;" + Environment.NewLine;
            Using += "using SEACore.Repositorio;" + Environment.NewLine;

            NameSpaceProjeto += "namespace " + _NameSpacesLogico;
            NameSpaceProjeto += Environment.NewLine;
            NameSpaceProjeto += "{";
            NameSpaceProjeto += Environment.NewLine;

            //Nome da classe
            NomeClasse  = "\tpublic interface I" + NomeTabelaSemSchema + " : IRepositorio<" + NomeTabelaSemSchema + ">" + Environment.NewLine;
            NomeClasse += "\t{";
            NomeClasse += Environment.NewLine;

            NomeClasse       += "\t}";
            NameSpaceProjeto += NomeClasse;
            NameSpaceProjeto += Environment.NewLine;
            NameSpaceProjeto += "}";
            Using            += NameSpaceProjeto;

            using (FileStream fs = new FileStream(NaoExisteClasse, FileMode.Create))
            {
                using (StreamWriter w = new StreamWriter(fs, Encoding.UTF8))
                {
                    w.WriteLine(Using);
                }
            }
            return("Interface I" + NomeTabelaSemSchema + ".cs criada com sucesso. Caminho: " + _NameSpacesFisico + "I" + NomeTabelaSemSchema + ".cs");
        }