Kameleon – Uletu sm u disko
May0
Neverjetno.
Youtube komentar: “o lol, ti bi bil v šoli za posebne potrebe častni gost”
”A ti sploh veš kaj je rima pa flow???”
Jogurt
May0
Jogurt je zakon
Najbolši je tekoči jogurt od ljubljanskih mlekarn… Mleko mi pa nikol ni preveč pasal. Kaj pa vi?
Tukej je en zanimiv blog post o tem: http://www.medrants.com/index.php/archives/2682
New idea for Windows Touch Remix
May3
I’m going to do a quick-dial feature for Windows Touch Remix. I want to keep the code nice so it’ll take me a few days to get there, but this is how it looks at the moment (and how it’s supposed to look, anyway):
Personally i kind of like the shading, what do you think?
F#.NET
May0
F#.NET is a new functional language from Microsoft. It looks very promising, and here you can see a very good video presentation Luca Bolognese gave about it.
![]()
Snippet of the day: C#.NET configuration files
May0
I’ll start with a longer snippet – handling configuration files in C#.NET. I used this in Windows Touch Remix.
This is the base class I use for my configuration classes:
[Serializable()]
public class XmlConf
{
public static T FromFile<T>(string filename)
{
if (!File.Exists(filename)) return default(T);
XmlSerializer ser = new XmlSerializer(typeof(T));
StreamReader fs = new StreamReader(filename);
T t = (T) ser.Deserialize(fs);
fs.Close();
return t;
}
public void Save(string filename)
{
XmlSerializer ser = new XmlSerializer(this.GetType());
StreamWriter fs = new StreamWriter(filename, false);
ser.Serialize(fs, this);
fs.Close();
}
}
Just subclass it and add your configuration properties:
[Serializable()]
public class MyConf : XmlConf
{
public int IntVal { get; set; }
public string StrVal { get; set; }
}
Make sure you use getters and setters like in the above example, so the values get serialized properly. Most .NET classes (like List) are serializable, but if you have properties of your own class, make sure they are serializable.
Here’s a usage example of saving and loading the configuration:
// Save
MyConf conf = new MyConf();
conf.IntVal = 100;
conf.StrVal = "hey";
conf.Save("my.conf");
// Load
conf = MyConf.FromFile<MyConf>("my.conf");
if (conf == null) new Exception("Configuration file not found.");
Console.WriteLine(conf.IntVal);
Console.WriteLine(conf.StrVal);
