Canguro.Model.Section.SectionManager.Initialize C# (CSharp) Method

Initialize() public method

Inicializa leyendo todos los archivos *.sec en el directorio \section Se tiene que llamar después de crear Model
public Initialize ( Catalog &modelSections ) : void
modelSections Catalog
return void
        public void Initialize(ref Catalog<Canguro.Model.Section.Section> modelSections)
        {
            catalogs.Clear();

            if (this["modelCatalog"] == null)
                this["modelCatalog"] = new Catalog<Canguro.Model.Section.Section>();
            modelSections = this["modelCatalog"];
            modelSections[DefaultFrameSection.Name] = DefaultFrameSection;

            // Create a reference to the current directory.
            DirectoryInfo di = new DirectoryInfo(System.Windows.Forms.Application.StartupPath + @"\RuntimeData\section");

            if (!di.Exists)
                di = new DirectoryInfo(@"section");

            // Create an array representing the files in the current directory.
            FileInfo[] fi = di.GetFiles();

            //Console.WriteLine("The following files exist in the current directory:");
            // Print out the names of the files in the current directory.
            foreach (FileInfo fiTemp in fi)
            {
                //                Console.WriteLine(fiTemp.Name);
                try
                {
                    if (fiTemp.Extension.Equals(".sec"))
                    {
                        Catalog<Section> tmp = new Catalog<Section>();
                        tmp.Load(fiTemp.FullName);
                        if (!catalogs.ContainsKey(tmp.Name))
                        {
                            catalogs.Add(tmp.Name, tmp);
                            tmp.CatalogChanged += new EventHandler(oneCatalogChanged);
                        }
                    }
                    else if (fiTemp.Extension.Equals(".txt"))
                    {
                        string name = fiTemp.Name;
                        name = name.Substring(0, name.Length - 4);
                        Catalog<Section> tmp = new Catalog<Section>(name, false);
                        LoadTxtCatalog(tmp, fiTemp.FullName);
                        if (!catalogs.ContainsKey(tmp.Name))
                        {
                            catalogs.Add(tmp.Name, tmp);
                            tmp.CatalogChanged += new EventHandler(oneCatalogChanged);
                        }
                        tmp.IsReadOnly = true;
                        //tmp.Save(fiTemp.Directory + "\\" + tmp.Name + ".sec");
                    }
                    else if (fiTemp.Extension.Equals(".xsec"))
                    {
                        if (!catalogs.ContainsKey(Culture.Get("userSectionsCatalog")))
                            catalogs.Add(Culture.Get("userSectionsCatalog"), new Catalog<Section>(Culture.Get("userSectionsCatalog"), false));
                        LoadXmlSections(fiTemp.FullName, catalogs[Culture.Get("userSectionsCatalog")]);
                    }
                }
                catch (System.IO.FileNotFoundException e)
                {
                    // Reconstruir catálogo
                    throw e;
                }
            }
        }