Browse Source

2009-07-23 Veerapuram Varadhan <[email protected]>

	* XmlSchemaDataImporter.cs: Added null checks.

svn path=/trunk/mcs/; revision=138444
Veerapuram Varadhan 16 years ago
parent
commit
81945b7f28

+ 4 - 0
mcs/class/System.Data/System.Data/ChangeLog

@@ -1,3 +1,7 @@
+2009-07-23  Veerapuram Varadhan  <[email protected]>
+
+	* XmlSchemaDataImporter.cs: Added null checks.
+	
 2009-07-22  Veerapuram Varadhan  <[email protected]>
 
 	* XmlSchemaDataImporter.cs:

+ 40 - 23
mcs/class/System.Data/System.Data/XmlSchemaDataImporter.cs

@@ -1251,18 +1251,20 @@ namespace System.Data
 			foreach (XmlNode n in el.ChildNodes) {
 				e = n as XmlElement;
 				
-				if (e != null && e.LocalName == "Connections") {
+				if (e == null)
+					continue;
+				
+				if (e.LocalName == "Connections") {
 					providerName = ((XmlElement)e.FirstChild).GetAttribute ("Provider");
 					connString = ((XmlElement)e.FirstChild).GetAttribute ("AppSettingsPropertyName");
+					continue;
 				}
 				// #325464 debugging
 				//Console.WriteLine ("ProviderName: " + providerName + "Connstr: " + connString);
 				
 				provider = DbProviderFactories.GetFactory (providerName);
 				
-				if (e != null && e.LocalName != "Tables") {
-					continue;
-				} else {
+				if (e.LocalName == "Tables") {
 					foreach (XmlNode node in e.ChildNodes) {
 						ProcessTableAdapter (node as XmlElement, provider, connString);
 					}
@@ -1279,6 +1281,9 @@ namespace System.Data
 			XmlElement e;
 			string datasetTableName = null;
 			
+			if (el == null)
+				return;
+			
 			// #325464 debugging
 			//Console.WriteLine ("in ProcessTableAdapters...");
 			currentAdapter = new TableAdapterSchemaInfo (provider); 
@@ -1330,6 +1335,9 @@ namespace System.Data
 			string tmp = null;
 			XmlElement e;
 			
+			if (el == null)
+				return;
+			
 			//Console.WriteLine ("ProcessDbSources: "+el.LocalName);
 
 			tmp = el.GetAttribute ("GenerateShortCommands");
@@ -1412,23 +1420,23 @@ namespace System.Data
 			foreach (XmlNode n in el.ChildNodes) {
 				e = n as XmlElement;
 				
-				if (e != null) {
-					
-					switch (e.LocalName) {
-						case "SelectCommand": 
-							cmdInfo.Command = ProcessDbCommand (e.FirstChild as XmlElement);
-							currentAdapter.Commands.Add (cmdInfo);
-							break;
-						case "InsertCommand": 
-							currentAdapter.Adapter.InsertCommand = ProcessDbCommand (e.FirstChild as XmlElement);
-							break;
-						case "UpdateCommand": 
-							currentAdapter.Adapter.UpdateCommand = ProcessDbCommand (e.FirstChild as XmlElement);
-							break;
-						case "DeleteCommand": 
-							currentAdapter.Adapter.DeleteCommand = ProcessDbCommand (e.FirstChild as XmlElement);
-							break;
-					}
+				if (e == null) 
+					continue;
+				
+				switch (e.LocalName) {
+					case "SelectCommand": 
+						cmdInfo.Command = ProcessDbCommand (e.FirstChild as XmlElement);
+						currentAdapter.Commands.Add (cmdInfo);
+						break;
+					case "InsertCommand": 
+						currentAdapter.Adapter.InsertCommand = ProcessDbCommand (e.FirstChild as XmlElement);
+						break;
+					case "UpdateCommand": 
+						currentAdapter.Adapter.UpdateCommand = ProcessDbCommand (e.FirstChild as XmlElement);
+						break;
+					case "DeleteCommand": 
+						currentAdapter.Adapter.DeleteCommand = ProcessDbCommand (e.FirstChild as XmlElement);
+						break;
 				}
 			}
 		}
@@ -1441,6 +1449,9 @@ namespace System.Data
 			string cmdType = null;
 			ArrayList parameters = null;
 			
+			if (el == null)
+				return null;
+			
 			cmdType = el.GetAttribute ("CommandType");
 			foreach (XmlNode n in el.ChildNodes) {
 				e = n as XmlElement;
@@ -1468,10 +1479,13 @@ namespace System.Data
 		{
 			//Console.WriteLine ("ProcessDbParameters: "+el.LocalName);
 			string tmp = null;
-			ArrayList parameters = new ArrayList ();
+			XmlElement e;
 			DbParameter param = null;
+			ArrayList parameters = new ArrayList ();
+			
+			if (el == null)
+				return parameters;
 			
-			XmlElement e;
 			foreach (XmlNode n in el.ChildNodes) {
 				e = n as XmlElement;
 				
@@ -1511,6 +1525,9 @@ namespace System.Data
 
 		private void ProcessColumnMapping (XmlElement el, DataTableMapping tableMapping)
 		{
+			if (el == null)
+				return;
+			
 			tableMapping.ColumnMappings.Add (el.GetAttribute ("SourceColumn"), 
 			                                 el.GetAttribute ("DataSetColumn"));
 		}