Removed scary CultureInfo switching and added a quickfix for mRemoteNG namespace refactoring

ConfVersion was converted to an en-US numberformat by switching the CurrentCulture - this is not the best practice - replaced by ToString(new CultureInfo("en-US").

The refactoring done in commit e08c88db5f resulted in an unusable pnlLayout.xml (panel persistence) file. Added a quickfix to convert that file.
This commit is contained in:
Andreas Rehm
2010-05-18 06:13:38 +08:00
committed by Riley McArdle
parent be3c8de3a2
commit f06c4f7e6b
3 changed files with 17 additions and 20 deletions

View File

@@ -1,5 +1,6 @@
Imports System.Windows.Forms
Imports System.Xml
Imports System.Globalization
Imports mRemoteNG.App.Runtime
Imports System.Data
Imports System.Data.SqlClient
@@ -201,10 +202,8 @@ Namespace Config
sqlRd.Read()
End If
Dim originalCulture As System.Globalization.CultureInfo = My.Application.Culture
My.Application.ChangeCulture("en-US")
Me.confVersion = Convert.ToDouble(sqlRd.Item("confVersion"))
My.Application.ChangeCulture(originalCulture.ToString)
Dim enCulture As CultureInfo = New CultureInfo("en-US")
Me.confVersion = Convert.ToDouble(sqlRd.Item("confVersion"), enCulture)
Dim rootNode As TreeNode
rootNode = New TreeNode(sqlRd.Item("Name"))
@@ -625,10 +624,8 @@ Namespace Config
End If
If xDom.DocumentElement.HasAttribute("ConfVersion") Then
Dim originalCulture As System.Globalization.CultureInfo = My.Application.Culture
My.Application.ChangeCulture("en-US")
Me.confVersion = Convert.ToDouble(xDom.DocumentElement.Attributes("ConfVersion").Value)
My.Application.ChangeCulture(originalCulture.ToString)
Dim enCulture As System.Globalization.CultureInfo = New CultureInfo("en-US")
Me.confVersion = Convert.ToDouble(xDom.DocumentElement.Attributes("ConfVersion").Value, enCulture)
Else
mC.AddMessage(Messages.MessageClass.WarningMsg, My.Resources.strOldConffile)
End If
@@ -707,7 +704,7 @@ Namespace Config
App.Runtime.Windows.treeForm.InitialRefresh()
Catch ex As Exception
App.Runtime.ConnectionsFileLoaded = False
mC.AddMessage(Messages.MessageClass.ErrorMsg, My.Resources.strLoadFromXMLFailed & vbNewLine & ex.Message, True)
mC.AddMessage(Messages.MessageClass.ErrorMsg, My.Resources.strLoadFromXmlFailed & vbNewLine & ex.Message, True)
End Try
End Sub
@@ -783,7 +780,7 @@ Namespace Config
inTreeNode.Text = inXmlNode.Attributes("Name").Value.Trim
End If
Catch ex As Exception
mC.AddMessage(Messages.MessageClass.ErrorMsg, My.Resources.strAddNodeFromXMLFailed & vbNewLine & ex.Message, True)
mC.AddMessage(Messages.MessageClass.ErrorMsg, My.Resources.strAddNodeFromXmlFailed & vbNewLine & ex.Message, True)
End Try
End Sub

View File

@@ -1,6 +1,7 @@
Imports System.Windows.Forms
Imports System.Xml
Imports System.IO
Imports System.Globalization
Imports mRemoteNG.App.Runtime
Imports System.Data.SqlClient
Imports mRemoteNG.Tools.Misc
@@ -191,14 +192,10 @@ Namespace Config
sqlQuery = New SqlCommand("DELETE FROM tblRoot", sqlCon)
sqlWr = sqlQuery.ExecuteNonQuery
Dim originalCulture As System.Globalization.CultureInfo = My.Application.Culture
My.Application.ChangeCulture("en-US")
sqlQuery = New SqlCommand("INSERT INTO tblRoot (Name, Export, Protected, ConfVersion) VALUES('" & PrepareValueForDB(tN.Text) & "', 0, '" & strProtected & "'," & App.Info.Connections.ConnectionFileVersion & ")", sqlCon)
My.Application.ChangeCulture(originalCulture.ToString)
Dim enCulture As CultureInfo = New CultureInfo("en-US")
sqlQuery = New SqlCommand("INSERT INTO tblRoot (Name, Export, Protected, ConfVersion) VALUES('" & PrepareValueForDB(tN.Text) & "', 0, '" & strProtected & "'," & App.Info.Connections.ConnectionFileVersion.ToString(enCulture) & ")", sqlCon)
sqlWr = sqlQuery.ExecuteNonQuery
sqlQuery = New SqlCommand("DELETE FROM tblCons", sqlCon)
sqlWr = sqlQuery.ExecuteNonQuery
@@ -542,10 +539,8 @@ Namespace Config
End If
End If
Dim originalCulture As System.Globalization.CultureInfo = My.Application.Culture
My.Application.ChangeCulture("en-US")
xW.WriteAttributeString("ConfVersion", "", App.Info.Connections.ConnectionFileVersion)
My.Application.ChangeCulture(originalCulture.ToString)
Dim enCulture As System.Globalization.CultureInfo = New CultureInfo("en-US")
xW.WriteAttributeString("ConfVersion", "", App.Info.Connections.ConnectionFileVersion.ToString(enCulture))
Dim tNC As TreeNodeCollection
tNC = tN.Nodes

View File

@@ -206,6 +206,11 @@ Namespace Config
#Region "Private Methods"
Private Function GetContentFromPersistString(ByVal persistString As String) As IDockContent
' pnlLayout.xml persistence XML fix for refactoring to mRemoteNG
If (persistString.StartsWith("mRemote.")) Then
persistString = persistString.Replace("mRemote.", "mRemoteNG.")
End If
Try
If persistString = GetType(UI.Window.Config).ToString Then
Return Windows.configPanel