NFe.Components.Functions.CarregaMunicipios C# (CSharp) Метод

CarregaMunicipios() публичный статический Метод

Carrega os Estados que possuem serviço de NFE já disponível. Estes Estados são carregados a partir do XML Webservice.xml que fica na pasta do executável do UNINFE
Autor: Wandrey Mundin Ferreira Data: 01/03/2010
public static CarregaMunicipios ( ) : ArrayList
Результат System.Collections.ArrayList
        public static ArrayList CarregaMunicipios()
        {
            ArrayList UF = new ArrayList();

            Propriedade.Municipios.ForEach((mun) => { UF.Add(new ComboElem(mun.UF, mun.CodigoMunicipio, mun.Nome)); });

            if (File.Exists(Propriedade.NomeArqXMLWebService_NFSe))
            {
                //Carregar os dados do arquivo XML de configurações da Aplicação
                XElement axml = XElement.Load(Propriedade.NomeArqXMLWebService_NFSe);
                var s = (from p in axml.Descendants(NFe.Components.NFeStrConstants.Estado)
                         where (string)p.Attribute(TpcnResources.UF.ToString()) != "XX"
                         select p);
                foreach (var item in s)
                {
                    if (Convert.ToInt32("0" + OnlyNumbers(item.Attribute(TpcnResources.ID.ToString()).Value)) == 0)
                        continue;

                    var temp = Propriedade.Municipios.FirstOrDefault(x => x.CodigoMunicipio == Convert.ToInt32(item.Attribute(TpcnResources.ID.ToString()).Value));
                    if (temp == null)
                    {
                        UF.Add(new ComboElem(item.Attribute(TpcnResources.UF.ToString()).Value,
                            Convert.ToInt32(item.Attribute(NFe.Components.TpcnResources.ID.ToString()).Value),
                            item.Element(NFe.Components.NFeStrConstants.Nome).Value));
                    }
                }
            }
            UF.Sort(new OrdenacaoPorNome());
            return UF;
        }