All pastes #442879 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-04-16 15:06 UTC
rendered paste body
/// <summary>
		/// Allows the creation of the show-level form by identifying it as a sub-class. 
		/// The types of the show level forms should be added to the _ShowLevelFormTypes array.
		/// This does not take into account multiple levels of inheritance, and will create
		/// the first form who's type is a sub-class of the baseFormType argument.
		/// </summary>
		/// <param name="baseFormType">The base form type to create</param>
		/// <returns></returns>

		public static Form CreateShowLevelFormFromBase(Type baseFormType)
		{
			Form newForm = null;
			foreach (Type showLevelType in UIControllerBase._ShowLevelFormTypes)
			{
				if (showLevelType.IsSubclassOf(baseFormType))
				{
					newForm = (Form)System.Activator.CreateInstance(showLevelType);
					break;
				}
			}

			if (newForm == null)
			{
				newForm = (Form)System.Activator.CreateInstance(baseFormType);
			}

			return newForm;
		}