NFe.Components.WebServiceNFSe.getURLs C# (CSharp) Method

getURLs() private static method

private static getURLs ( string local, PadroesNFSe &padrao, int idMunicipio ) : string
local string
padrao PadroesNFSe
idMunicipio int
return string
        private static string getURLs(string local, ref PadroesNFSe padrao, int idMunicipio)
        {
            /*
             * tenta ler as URL's do 'WebService.xml'
             * não encontrando, assume o ID='padrao' e UF='XX' e padrao='padrao'
             */

            if (System.IO.File.Exists(Propriedade.NomeArqXMLWebService_NFSe))
            {
                XElement axml = XElement.Load(Propriedade.NomeArqXMLWebService_NFSe);
                ///
                /// primeiro, pesquisa pelo ID
                /// 
                var s = (from p in axml.Descendants(NFe.Components.NFeStrConstants.Estado)
                         where  //(string)p.Attribute(NFe.Components.NFeStrConstants.Padrao) == padrao.ToString() &&
                                (string)p.Attribute(NFe.Components.TpcnResources.ID.ToString()) == idMunicipio.ToString()
                         select p);
                foreach (var item in s)
                {
                    if (item.Element(local) != null)
                    {
                        ///
                        /// pega o padrao definido no WebService.xml descartando o que constar no UninMunic.xml
                        /// 
                        padrao = WebServiceNFSe.GetPadraoFromString(item.Attribute(NFe.Components.NFeStrConstants.Padrao).Value);

                        return local.Equals(NFe.Components.NFeStrConstants.LocalHomologacao) ?
                            item.FirstNode.ToString() : item.LastNode.ToString();
                }
                }
                ///
                /// não encontrei, assume o ID='padrao' e UF='XX' e padrao='padrao'
                /// 
                PadroesNFSe pdr = padrao;

                var xs = (from p in axml.Descendants(NFe.Components.NFeStrConstants.Estado)
                          where  (string)p.Attribute(NFe.Components.NFeStrConstants.Padrao) == pdr.ToString() &&
                                 (string)p.Attribute(TpcnResources.UF.ToString()) == "XX" &&
                                 (string)p.Attribute(NFe.Components.TpcnResources.ID.ToString()) == pdr.ToString()
                          select p);
                foreach (var item in xs)
                {
                    if (item.Element(local) != null)
                        return local.Equals(NFe.Components.NFeStrConstants.LocalHomologacao) ?
                            item.FirstNode.ToString() : item.LastNode.ToString();
                }
            }

            return "";
        }