System.Data.XmlSchemaDataImporter.ProcessDbSource C# (CSharp) Method

ProcessDbSource() private method

private ProcessDbSource ( XmlElement el ) : void
el System.Xml.XmlElement
return void
		private void ProcessDbSource (XmlElement el)
		{
			
			string cmdType;
			string tmp = null;
			XmlElement e;
			
			if (el == null)
				return;
			
			//Console.WriteLine ("ProcessDbSources: "+el.LocalName);

			tmp = el.GetAttribute ("GenerateShortCommands");
			//Console.WriteLine ("GenerateShortCommands: {0}", tmp);
			if (!String.IsNullOrEmpty (tmp))
				currentAdapter.ShortCommands = Convert.ToBoolean (tmp);
		
			DbCommandInfo cmdInfo = new DbCommandInfo ();
			tmp = el.GetAttribute ("GenerateMethods");
			if (!String.IsNullOrEmpty (tmp)) {
				DbSourceMethodInfo mthdInfo = null;
				
				switch ((GenerateMethodsType) Enum.Parse (typeof (GenerateMethodsType), tmp)) {
				case GenerateMethodsType.Get:
					mthdInfo = new DbSourceMethodInfo ();
					mthdInfo.Name = el.GetAttribute ("GetMethodName");
					mthdInfo.Modifier = el.GetAttribute ("GetMethodModifier");
					if (String.IsNullOrEmpty (mthdInfo.Modifier))
						mthdInfo.Modifier = "Public";
					mthdInfo.ScalarCallRetval = el.GetAttribute ("ScalarCallRetval");
					mthdInfo.QueryType = el.GetAttribute ("QueryType");
					mthdInfo.MethodType = GenerateMethodsType.Get;
					cmdInfo.Methods = new DbSourceMethodInfo [1];
					cmdInfo.Methods[0] = mthdInfo;
					break;
					
				case GenerateMethodsType.Fill:
					mthdInfo = new DbSourceMethodInfo ();
					mthdInfo.Name = el.GetAttribute ("FillMethodName");
					mthdInfo.Modifier = el.GetAttribute ("FillMethodModifier");
					if (String.IsNullOrEmpty (mthdInfo.Modifier))
						mthdInfo.Modifier = "Public";
					mthdInfo.ScalarCallRetval = null;
					mthdInfo.QueryType = null;
					mthdInfo.MethodType = GenerateMethodsType.Fill;
					cmdInfo.Methods = new DbSourceMethodInfo [1];
					cmdInfo.Methods[0] = mthdInfo;
					break;
					
				case GenerateMethodsType.Both:
					mthdInfo = new DbSourceMethodInfo ();
					// Get
					mthdInfo.Name = el.GetAttribute ("GetMethodName");
					mthdInfo.Modifier = el.GetAttribute ("GetMethodModifier");
					if (String.IsNullOrEmpty (mthdInfo.Modifier))
						mthdInfo.Modifier = "Public";
					mthdInfo.ScalarCallRetval = el.GetAttribute ("ScalarCallRetval");
					mthdInfo.QueryType = el.GetAttribute ("QueryType");
					mthdInfo.MethodType = GenerateMethodsType.Get;
					cmdInfo.Methods = new DbSourceMethodInfo [2];
					cmdInfo.Methods[0] = mthdInfo;
					
					// Fill
					mthdInfo = new DbSourceMethodInfo ();
					mthdInfo.Name = el.GetAttribute ("FillMethodName");
					mthdInfo.Modifier = el.GetAttribute ("FillMethodModifier");
					if (String.IsNullOrEmpty (mthdInfo.Modifier))
						mthdInfo.Modifier = "Public";
					mthdInfo.ScalarCallRetval = null;
					mthdInfo.QueryType = null;
					mthdInfo.MethodType = GenerateMethodsType.Fill;
					cmdInfo.Methods[1] = mthdInfo;
					break;
				}
			} else {
				// no Get or Fill methods - non <MainSource> sources
				DbSourceMethodInfo mthdInfo = new DbSourceMethodInfo ();
				mthdInfo.Name = el.GetAttribute ("Name");
				mthdInfo.Modifier = el.GetAttribute ("Modifier");
				if (String.IsNullOrEmpty (mthdInfo.Modifier))
					mthdInfo.Modifier = "Public";
				mthdInfo.ScalarCallRetval = el.GetAttribute ("ScalarCallRetval");
				mthdInfo.QueryType = el.GetAttribute ("QueryType");
				mthdInfo.MethodType = GenerateMethodsType.None;
				// Add MethodInfo to DbCommandInfo
				cmdInfo.Methods = new DbSourceMethodInfo [1];
				cmdInfo.Methods[0] = mthdInfo;
			}
			
			foreach (XmlNode n in el.ChildNodes) {
				e = n as XmlElement;
				
				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;
				}
			}
		}