OSDN Git Service

AppliStation-All,「キャッシュにダウンロード」する機能を追加
[applistation/AppliStation.git] / na-get-lib / NaGet.Packages.Install / UninstallInformation.cs
index c6cf2e0..eec7d00 100644 (file)
@@ -52,12 +52,12 @@ namespace NaGet.Packages.Install
                /// <summary>\r
                /// 「変更」ができるか否かのフラグ。NoModifyの逆(きちんと動かない??)\r
                /// </summary>\r
-               public bool CanModify;\r
+               public bool CanModify = false;\r
                \r
                /// <summary>\r
                /// 「修復」ができるか否かのフラグ。NoRepairの逆(きちんと動かない??)\r
                /// </summary>\r
-               public bool CanRepair;\r
+               public bool CanRepair = false;\r
                \r
                /// <summary>\r
                /// 「アンインストール」ができるか否かのフラグ。NoRemoveの逆\r
@@ -67,12 +67,12 @@ namespace NaGet.Packages.Install
                /// <summary>\r
                /// システムコンポーネントか否か\r
                /// </summary>\r
-               public bool IsSystemComponent;\r
+               public bool IsSystemComponent = false;\r
                \r
                /// <summary>\r
                /// OSの更新パッチか否か。\r
                /// </summary>\r
-               public bool IsOSPatch;\r
+               public bool IsOSPatch = false;\r
                \r
                /// <summary>\r
                /// アンインストールにmsiexecを使うか否か\r
@@ -123,25 +123,37 @@ namespace NaGet.Packages.Install
                {\r
                        UninstallInformation uninstInfo = new UninstallInformation();\r
                        \r
-                       uninstInfo.DisplayName = (string) regKey.GetValue("DisplayName");\r
-                       uninstInfo.DisplayVersion = (string) regKey.GetValue("DisplayVersion", null);\r
-                       uninstInfo.Publisher = (string) regKey.GetValue("Publisher", null);\r
-                       uninstInfo.URLInfoAbout = (string) regKey.GetValue("URLInfoAbout", null);\r
-                       uninstInfo.IconPath = (string) regKey.GetValue("DisplayIcon", null);\r
-                       uninstInfo.ModifyPath = (string) regKey.GetValue("ModifyPath", null);\r
-                       uninstInfo.UninstallString = (string) regKey.GetValue("UninstallString", null);\r
-                       uninstInfo.QuietUninstallString = (string) regKey.GetValue("QuietUninstallString", null);\r
-                       uninstInfo.CanModify = ((int) regKey.GetValue("NoModify", 1)) != 1;\r
-                       uninstInfo.CanRepair = ((int) regKey.GetValue("NoRepair", 1)) != 1;\r
-                       uninstInfo.CanRemove = ((int) regKey.GetValue("NoRemove", 1)) != 1; \r
-                       uninstInfo.WindowsInstaller = ((int) regKey.GetValue("WindowsInstaller", 0)) == 1; \r
-                       uninstInfo.IsSystemComponent = ((int) regKey.GetValue("SystemComponent", 0)) > 0;\r
-                       uninstInfo.IsOSPatch = ((string) regKey.GetValue("ParentKeyName", null)) == "OperatingSystem";\r
+                       uninstInfo.DisplayName = (regKey.GetValue("DisplayName") as string) ?? string.Empty;\r
+                       uninstInfo.DisplayVersion = regKey.GetValue("DisplayVersion", null) as string;\r
+                       uninstInfo.Publisher = regKey.GetValue("Publisher", null) as string;\r
+                       uninstInfo.URLInfoAbout = regKey.GetValue("URLInfoAbout", null) as string;\r
+                       uninstInfo.IconPath = regKey.GetValue("DisplayIcon", null) as string;\r
+                       uninstInfo.ModifyPath = regKey.GetValue("ModifyPath", null) as string;\r
+                       uninstInfo.UninstallString = regKey.GetValue("UninstallString", null) as string;\r
+                       uninstInfo.QuietUninstallString = regKey.GetValue("QuietUninstallString", null) as string;\r
                        try {\r
-                               uninstInfo.InstallDateString = (string) regKey.GetValue("InstallDate", null);\r
+                               uninstInfo.CanModify = ((int) regKey.GetValue("NoModify", 1)) != 1;\r
+                       } catch (InvalidCastException) {}\r
+                       try {\r
+                               uninstInfo.CanRepair = ((int) regKey.GetValue("NoRepair", 1)) != 1;\r
+                       } catch (InvalidCastException) {}\r
+                       try {\r
+                               uninstInfo.CanRemove = ((int) regKey.GetValue("NoRemove", 1)) != 1;\r
+                       } catch (InvalidCastException) {}\r
+                       try {\r
+                               uninstInfo.WindowsInstaller = ((int) regKey.GetValue("WindowsInstaller", 0)) == 1;\r
+                       } catch (InvalidCastException) {}\r
+                       try {\r
+                               uninstInfo.IsSystemComponent = ((int) regKey.GetValue("SystemComponent", 0)) > 0;\r
+                       } catch (InvalidCastException) {}\r
+                       uninstInfo.IsOSPatch = (regKey.GetValue("ParentKeyName", null) as string) == "OperatingSystem";\r
+                       try {\r
+                               uninstInfo.InstallDateString = regKey.GetValue("InstallDate", null) as string;\r
+                       } catch (ArgumentException) {}\r
+                       uninstInfo.InstallLocation = regKey.GetValue("InstallLocation", null) as string;\r
+                       try {\r
+                               uninstInfo.EstimatedSize = (int) regKey.GetValue("EstimatedSize", 0);\r
                        } catch (ArgumentException) {}\r
-                       uninstInfo.InstallLocation = (string) regKey.GetValue("InstallLocation", null);\r
-                       uninstInfo.EstimatedSize = (int) regKey.GetValue("EstimatedSize", 0);\r
                        \r
                        PrefixWithSlowInfoCache(ref uninstInfo, regKey);\r
                        \r