Imagine the following class:
public class Settings
{
[FileBackedProperty("foo.txt")]
public string Foo { get; set; }
}
I would like to write something similar to the previous one and settings.Fooread from the file "foo.txt" and settings.Foo = "bar"write in "foo.txt".
Obviously, this is a simplified example, and I would not have done it in a production application, but there are other examples, for example, if I wanted Foo to be stored in the ASP.net "foo" session state, but I'm tired of repeating the following code :
public int Foo
{
get
{
if (Session["foo"] != null)
return Convert.ToInt32(Session["foo"]);
else
}
set
{
Session["foo"] = value;
}
}
(Once again, this example is simplified, and I would not have written the code above, in fact I lie, I have the code above and I am working to reorganize it, thus this question)
, 50 , . - - ? ( , , , ?)