OSDN Git Service

AppliStation-All,起動時間の高速化。起動時のpackages.list.xmlの読み込み処理を正常時に2回重複して行っていたのを修正。
authorttp <ttp@users.sourceforge.jp>
Sun, 20 Dec 2009 14:15:29 +0000 (23:15 +0900)
committerttp <ttp@users.sourceforge.jp>
Sun, 20 Dec 2009 14:15:29 +0000 (23:15 +0900)
AppliStation/Program.cs
all-get/Main.cs
na-get-lib/NaGet.Packages/PackageListsManager.cs
na-get-lib/NaGet.SubCommands/NaGetUpdate.cs
na-get-lib/NaGet/Utils.cs

index 4f7219e..466944d 100644 (file)
@@ -43,6 +43,7 @@ namespace AppliStation
                                NaGet.Packages.Install.Installation[] insts = NaGet.Utils.GetDeserializedObject<NaGet.Packages.Install.Installation[]>((string) appArgs["instsref"]);\r
                                \r
                                form = new PackageListViewForm();\r
+                               form.UpdatePackageList();\r
                                hideSplashScreen();\r
                                form.installActionInvoke(insts);\r
                        } catch (UnauthorizedAccessException e) {\r
@@ -60,6 +61,7 @@ namespace AppliStation
                                NaGet.Packages.Install.InstalledPackage[] pkgs = NaGet.Utils.GetDeserializedObject<NaGet.Packages.Install.InstalledPackage[]>((string) appArgs["pkgsref"]);\r
                                \r
                                form = new PackageListViewForm();\r
+                               form.UpdatePackageList();\r
                                hideSplashScreen();\r
                                form.uninstallActionInvoke(pkgs);\r
                        } catch (UnauthorizedAccessException e) {\r
index c0df0f1..876d8aa 100644 (file)
@@ -80,6 +80,7 @@ namespace AllGet
                        downloader.DownloadEventRaised += new EventHandler<DownloadEventArgs>(dl.OnDownload);\r
                        \r
                        pkgListMan = new PackageListsManager();\r
+                       pkgListMan.LoadPackageLists();\r
                }\r
                \r
                public void Update()\r
index 2fedc2b..861bc07 100644 (file)
@@ -42,11 +42,14 @@ namespace NaGet.Packages
                private List<InstallationLog> systemInstalledLogList;\r
                \r
                /// <summary>\r
-               /// å\88\9dæ\9c\9få\8c\96ã\82\92ã\81\99ã\82\8bã\80\82ã\83\95ã\82¡ã\82¤ã\83«ç¾¤ã\82\92読ã\81¿è¾¼ã\82\93ã\81§æ\9b´æ\96°ã\81\8cã\81ªã\81\95ã\82\8cã\82\8b\r
+               /// å\88\9dæ\9c\9få\8c\96ã\82\92ã\81\99ã\82\8bã\80\82ã\83\87ã\83¼ã\82¿ã\81®èª­ã\81¿è¾¼ã\81¿ã\81¯æ\98\8e示ç\9a\84ã\81«LoadPackageLists()ã\82\92å\91¼ã\81³å\87ºã\81\95ã\81ªã\81\91ã\82\8cã\81°ã\81ªã\82\89ã\81ªã\81\84\r
                /// </summary>\r
                public PackageListsManager()\r
                {\r
-                       LoadPackageLists();\r
+                       availablePkgList = new PackageList<Package>();\r
+                       installedPkgList = new PackageList<InstalledPackage>();\r
+                       systemInstalledPkgList = new PackageList<InstalledPackage>();\r
+                       systemInstalledLogList = new List<InstallationLog>();\r
                }\r
                \r
                #region ファイル読み書き\r
@@ -56,32 +59,37 @@ namespace NaGet.Packages
                /// </summary>\r
                public void LoadPackageLists()\r
                {\r
-                       try {\r
-                               availablePkgList = NaGet.Utils.GetDeserializedObject<PackageList<Package>>(NaGet.Env.PackageListFile);\r
-                       } catch (FileNotFoundException) {\r
+                       System.Xml.Serialization.XmlSerializer sr;\r
+                       \r
+                       // ソフトリストのパッケージリスト読み込み\r
+                       sr = new System.Xml.Serialization.XmlSerializer(typeof(PackageList<Package>));\r
+                       if (File.Exists(NaGet.Env.PackageListFile)) {\r
+                               availablePkgList = (PackageList<Package>) NaGet.Utils.GetDeserializedObject(NaGet.Env.PackageListFile, sr);\r
+                       } else {\r
                                availablePkgList = new PackageList<Package>();\r
                        }\r
                        \r
-                       try {\r
-                               installedPkgList = NaGet.Utils.GetDeserializedObject<PackageList<InstalledPackage>>(NaGet.Env.ArchiveInstalledPackageListFile);\r
-                       } catch (FileNotFoundException) {\r
+                       sr = new System.Xml.Serialization.XmlSerializer(typeof(PackageList<InstalledPackage>));\r
+                       if (File.Exists(NaGet.Env.ArchiveInstalledPackageListFile)) {\r
+                               installedPkgList = (PackageList<InstalledPackage>) NaGet.Utils.GetDeserializedObject(NaGet.Env.ArchiveInstalledPackageListFile, sr);\r
+                       } else {\r
                                installedPkgList = new PackageList<InstalledPackage>();\r
                        }\r
                        \r
-                       try {\r
-                               systemInstalledPkgList = NaGet.Utils.GetDeserializedObject<PackageList<InstalledPackage>>(NaGet.Env.SystemInstalledPackageListFile);\r
-                       } catch (FileNotFoundException) {\r
+                       //sr = new System.Xml.Serialization.XmlSerializer(typeof(PackageList<InstalledPackage>));\r
+                       if (File.Exists(NaGet.Env.SystemInstalledPackageListFile)) {\r
+                               systemInstalledPkgList = (PackageList<InstalledPackage>) NaGet.Utils.GetDeserializedObject(NaGet.Env.SystemInstalledPackageListFile, sr);\r
+                       } else {\r
                                systemInstalledPkgList = new PackageList<InstalledPackage>();\r
                        }\r
                        \r
-                       \r
-                       systemInstalledLogList = new List<InstallationLog>();\r
-                       try {\r
-                               systemInstalledLogList.AddRange(\r
-                                       NaGet.Utils.GetDeserializedObject<InstallationLog[]>(NaGet.Env.SystemInstalledPackageLogFile)\r
+                       sr = new System.Xml.Serialization.XmlSerializer(typeof(InstallationLog[]));\r
+                       if (File.Exists(NaGet.Env.SystemInstalledPackageLogFile)) {\r
+                               systemInstalledLogList = new List<InstallationLog>(\r
+                                       (InstallationLog[]) NaGet.Utils.GetDeserializedObject(NaGet.Env.SystemInstalledPackageLogFile, sr)\r
                                );\r
-                       } catch (Exception) {\r
-                               // do nothing\r
+                       } else {\r
+                               systemInstalledLogList = new List<InstallationLog>();\r
                        }\r
                }\r
                \r
index d16011d..9e7ce51 100644 (file)
@@ -89,6 +89,7 @@ namespace NaGet.SubCommands
                                                runDownloadPackages();\r
                                        } catch (NaGetTaskCanceledException) {\r
                                                RaiseTaskSetEvent(NaGetTaskSetEventType.WARNING, "リストのダウンロード処理がキャンセルされました");\r
+                                               pkgListMan.LoadPackageLists();\r
                                        } catch (System.Net.WebException e) {\r
                                                RaiseTaskSetEvent(NaGetTaskSetEventType.WARNING, e.Message);\r
                                                if (System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable()) {\r
@@ -96,6 +97,7 @@ namespace NaGet.SubCommands
                                                } else {\r
                                                        RaiseTaskSetEvent(NaGetTaskSetEventType.WARNING, "ネットワークに接続できませんでした。ネットワークが切断されているか、ファイアウォールによって遮断された可能性があります。");\r
                                                }\r
+                                               pkgListMan.LoadPackageLists();\r
                                        } finally {\r
                                                int numOfEnabledRepos = NaGet.Utils.IEnumerable2Array(repoList.EnabledRepositories).Length;\r
                                                currentTaskSetIndex = numOfEnabledRepos + 1;\r
index a11ce94..994e46f 100644 (file)
@@ -381,22 +381,36 @@ namespace NaGet
                \r
                #region シリアル化関連\r
                \r
+               \r
                /// <summary>\r
                /// XMLでシリアル化したオブジェクトのXMLファイルを読み込み、デシリアル化したオブジェクトを取得する\r
                /// </summary>\r
                /// <param name="path">XMLファイルのパス</param>\r
+               /// <param name="sr">シリアライザ</param>\r
                /// <returns>デシリアル化されたオブジェクト</returns>\r
-               public static T GetDeserializedObject<T>(string path)\r
+               public static object GetDeserializedObject(string path, System.Xml.Serialization.XmlSerializer sr)\r
                {\r
-                       T retVal = default(T);\r
+                       object retVal = null;\r
                        using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read)) {\r
-                               System.Xml.Serialization.XmlSerializer sr = new System.Xml.Serialization.XmlSerializer(typeof(T));\r
-                               retVal = (T) sr.Deserialize(fs);\r
+                               retVal = sr.Deserialize(fs);\r
                        }\r
                        return retVal;\r
                }\r
                \r
                /// <summary>\r
+               /// XMLでシリアル化したオブジェクトのXMLファイルを読み込み、デシリアル化したオブジェクトを取得する\r
+               /// </summary>\r
+               /// <param name="path">XMLファイルのパス</param>\r
+               /// <returns>デシリアル化されたオブジェクト</returns>\r
+               public static T GetDeserializedObject<T>(string path)\r
+               {\r
+                       T retVal = default(T);\r
+                       System.Xml.Serialization.XmlSerializer sr = new System.Xml.Serialization.XmlSerializer(typeof(T));\r
+                       retVal = (T) GetDeserializedObject(path, sr);\r
+                       return retVal;\r
+               }\r
+               \r
+               /// <summary>\r
                /// オブジェクトをXMLでシリアル化してファイルに書き込む\r
                /// </summary>\r
                /// <param name="path">XMLファイルのパス</param>\r