Reflection and performance

loading assemblies and performance

Page 1 of 1

0 Replies - 1234 Views - Last Post: 04 April 2009 - 07:47 AM Rate Topic: -----

#1 YankeeImperialistDog  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 04-April 09

Reflection and performance

Post icon  Posted 04 April 2009 - 07:47 AM

Ok here's my code. It's a way to return a collection to populate dropdowns. My business objects are in a seprate assembly/layer. they are all part od the same project, but different areas of the namespace. to make it flexable i'm using a string, loading the assembly, then reflecting to get the enum requested. Question Will ibe re loading the assembly each time i call this method, or does it stay cached? and is there a big performance issue with how i'm doing this.
		 /// <summary>
		/// return a list of ther product type from the enum collection
		/// </summary>
		/// <returns></returns>
		[DataObjectMethod(DataObjectMethodType.Select, true)]
		public static BasicListCollection eNumForDDLUsingString(string enumName)
		{
			string str = "mycomapny.EBS.BusinessEntities." + enumName;
			Assembly assembly = null;
			assembly = Assembly.Load("mycompany.EBS.BusinessEntities");
			Type typ = assembly.GetType(str);
			string[] names = Enum.GetNames(typ);
			Array values = Enum.GetValues(typ);
			var blc = new BasicListCollection();
			for (int i = 0; i < names.Length; i++)
			{
				var bli = new BasicList();
				bli.IID = Convert.ToInt32(values.GetValue(i));
				bli.SzDesc = names[i];
				blc.Add(bli);
			}
			return blc;
		}



Is This A Good Question/Topic? 0
  • +

Page 1 of 1