It recently began to annoy me that every time I want to redirect to a page I have to use a string. Not a big deal I know but when you have broken links it can reflect badly on you as a developer, so I began to look for some solution that would allow for [...]
I find mocking the http context rather difficult, you can’t inherit from it and making a wrapper class is a lot of work. Thankfully someone came up with a solution, unfortunately the link they included with the code is dead and I can’t seem to remember where I got the code, if anyone finds out [...]
Taken from http://www.galcho.com/Blog/P…
Here is how to call a method with an out parameter using MethodInfo.Invoke, in this case the out parameter is the last one (int).
int parNum = 0;
string parText = “99″;
object[] methodParms = new object[] { parText, parNum };
MethodInfo methInfo = parNum.GetType().GetMethod(“TryParse”, new Type[] { typeof(string), typeof(int).MakeByRefType() });
methInfo.Invoke(null, methodParms);
parNum = (int)methodParms[1];
Console.WriteLine(“Parsed number:{0}”, parNum);
I’ve recently started moving a large amount of code on the project I’m working on from the presentation layer into a business logic layer. One of the problems I found was trying to link to other pages on the site without know where the application would be located or if it would be http or [...]
Say you have an outer method:
public OuterMethod(object x)
{
InnerMethod(x);
}
and an inner method with these overloads
public InnerMethod(object x)
{
//Generic Actions
}
public InnerMethod(Person x)
{
//Person Specific Actions
}
public InnerMethod(Dog x)
{
// Dog Specific Actions
}
How do you make it so that when the outer method calls the inner method it completes the specific actions as well as the generic ones that allows you to [...]