Ejemplo n.º 1
0
		private void ShowTypeSelectionForm()
		{
			UIResponse.WriteStartForm("EditProvider.aspx");
			UIResponse.WritePara(@"To add a new provider, you must first identify the type of provider you want.  Once you have selected a valid one, you may be prompted for additional information, depending on the type of the provider.");

			UIResponse.WriteStartFields();
			// Pick the right default
			string defaultProvider;
			if (TypeNameParm != null && TypeNameParm != "")
				defaultProvider = TypeNameParm;
			else
				defaultProvider = (string)(ConfigurationManager.AppSettings["DefaultNamespaceProviderForNamespaceCreation"]);

			string def = null;
			// Get the list of types in the loaded assemblies that implement INamespaceProvider
			ChoiceSet choices = new ChoiceSet();
			foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
			{
				foreach (Type each in assembly.GetTypes())
				{
					if (each.IsClass)
					{
						foreach (Type maybe in each.GetInterfaces())
						{
							if (maybe == typeof(INamespaceProvider))
							{
								INamespaceProvider worker = (INamespaceProvider)(Activator.CreateInstance(each));
								string displayString = each.FullName + " (" + worker.Description + ")";
								string val = assembly.GetName() + "#" + each.FullName;
								if (each.FullName == defaultProvider)
									def = val;

								choices.Add(displayString, val);
								break;
							}
						}
					}
				}
			}



			UIResponse.WriteCombobox(ParmNameTypeName, "Type", "The type of provider to to use", choices, def);

			// If there were any proposed values for the parms provided in the query string, pass them along
			foreach (string pName in Request.QueryString)
				UIResponse.WriteHiddenField(pName, Request.QueryString[pName]);
			
			UIResponse.WriteEndFields();

			UIResponse.WriteStartButtons();
			UIResponse.WriteSubmitButton("next1", "Next >>");
			UIResponse.WriteEndButtons();

			UIResponse.WriteEndForm();
		}
Ejemplo n.º 2
0
 public void WriteCombobox(string fieldName, string fieldLabel, string help, ChoiceSet choices, string currentValue)
 {
     StringBuilder b = new StringBuilder();
     b.Append("<select name='" + fieldName + "' id='" + fieldName + "'>");
     for (int i = 0; i < choices.DisplayStrings.Count; i++)
     {
         string disp = (string)(choices.DisplayStrings[i]);
         string val = (string)(choices.ValueStrings[i]);
         string sel = (val == currentValue) ? " selected " : "";
         b.Append("<option " + sel + " value='"+ Escape(val) + "'>" + disp + "</option>");
     }
     b.Append(@"</select>");
     WriteFieldHTML(fieldLabel, help, b.ToString());
 }