我知道spring.net将类配置为Spring对象。 Spring.NET框架通过getter返回这些类的实例。我被要求只访问spring.net对象属性(直接来自使用C#属性的类内部)。这首先是可能的,如果是的话我该怎么做?
class Student
{
public string firstName{get;set};
public string lastName{get;set}
}
<object id="MySudent" Type="StudenntsProject.Student,StudentProject">
<property name="firstName" value="David">
<property name="lastName" value="Fletcher">
</object>
class NewStudent
{
public NewStudent()
{
if( Student.firstName == null)
throw new Exception;
}
if(Student
// I have added this property. Lets say the value of this property is
// hardcoded and is not need in the class. Can I use this method directly
// in the class. I know I have to add reference to in the xml but how
// will it work and is it even possible to do that?
property IsOutofState{get;set}
//This fetches the object
property Student Student{get;set}
}
我知道我的例子非常蹩脚,但想知道我是否可以直接在C#代码中读取spring属性(不是通过对象)