How do I configure a static class via Spring .NET?
Consider the following cl开发者_如何转开发ass:
static class Abc
{
public Interface xyz
{
get;
set;
}
public void Show()
{
xyz.show();
}
}
Maybe a workaround can help.. This is not a static class but it works like one
namespace Nyan {
public class Util{
protected Util(){} //to avoid accidental instatiation
public static string DATETIMEFORMAT = "HH:mm:ss";
public static DateTime parseDate(string sDate)
{
return DateTime.ParseExact(sDate, DATETIMEFORMAT, CultureInfo.InvariantCulture);
}
}
}
<object id="Util" type="Nyan.Util, Nyan" singleton="true">
<property name="DATETIMEFORMAT" value="HH-mm-ss" />
</object
and is used like any other static class:
protected void Page_Load(object sender, EventArgs e)
{
DateTime sDate = Nyan.Util.parseDate("15-15-15"); //parsed with injected format
}
精彩评论