I have some classes:
public class clsAnimal
{
public int ID { get; set; }
public string Strain { get; set; }
}
public class clsHybridom
{
public int ID { get; set; }
public string Haplo { get; set; }
}
Those classes are instanced into session:
Session["clsAnimal"] = new clsAnimal();
and accessed like (if exist better method, please let me know):
((clsAnimal)Session["clsAnimal"])
There is a lot of classes like these two, I have a switch and by request instancing required class. Instanced class should be parsed into MyFunction .
There is public static class with functions used in whole project and in this class should be my function MyFunction
But alas! I don't know how to parse those classes into function MyFunction
My try was something like:
ASMX:
object ReturnObject;
Session["clsAnimal"] = new clsAnimal();
ReturnObject = Activator.CreateInstance(((clsAnimal)Session["clsAnimal"]));
return clsDataProc.MyFunction(ReturnObject);
public static class:
public static string MyFunction( object o )
{
return Do_Some_Evil_Things_With_Parsed_Class();
}
Obviously that is not going to happen because:
- cannot convert from 'clsAnimal' to 'System.Type'
- The best overloaded method match for 'System.Activator.CreateInstance(System.Type, params object[])' has some invalid arguments
Long story short: how to parse instanced class into public static string MyFunction?