| Serialization |
|---|
|
I was playing with serializing a class to a db. There were several frameworks that I found to implement this but I wanted to see what was involved. This is what I came up with after a little quick searching in msdn. Not a terrible solution. I need to look at the resources that MemoryStream eats up and when it gives them back. The app won't use this heavily as it really only stores this data once. The test app
using System;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Serialization;
namespace Serialize{
public class myApp{
[STAThread]
static void Main(string[] args){
myClass mc = new myClass();
mc.myInt = 2;
mc.myStr = "Ari";
string str = "";
//Filestream to hold the data object
MemoryStream mem = new MemoryStream();
//BinaryFormatter that will push the data to the stream
BinaryFormatter bf = new BinaryFormatter();
try
{
bf.Serialize(mem,mc);
str = Convert.ToBase64String(mem.ToArray());
}
catch(SerializationException e)
{
Console.WriteLine("Failed to serialize. Reason: " + e.Message);
}
finally
{
mem.Close();
}
Console.WriteLine("MyClass serialized");
myClass mc2 = new myClass();
//new filstream to deserialize
mem = new MemoryStream(Convert.FromBase64String(str));
try{
BinaryFormatter bf2 = new BinaryFormatter();
//deserialize
mc2 = (myClass) bf2.Deserialize(mem);
}
catch(SerializationException e)
{
Console.WriteLine("Failed to deserialize. Reason: " + e.Message);
throw;
}
finally
{
mem.Close();
}
mc.myStr = "Boo";
Console.WriteLine("Class de-serialized");
Console.WriteLine(mc2.ToString());
Console.WriteLine("Because I need proof " + mc.ToString());
}
}
}
And the class that is being serialized
and the output h:\Development\Test\Serialize>Serialize.exe Serialize.exe MyClass serialized Class de-serialized Ari says: 2 Because I need proof Boo says: 2 This post is mostly for my own purpose and as a test of 'blog-buffer-html and 'blog-region-html in the now world famous blog-mode™ mentioned earlier in this very blog! |
| comment (0) | Ari Turetzky | permanent link |
| Do You Wanna Dance |
|---|
|
Weight: NaN
Workout: 30 Minute Walk I will not be weighing until friday. I figure that will give me enough time to drop whatever weight I put on at the fair. Cecilia and Owen did very well at the fair. Owen only had a short nap and Cecilia opted to forgo a nap all together. Both of them seemed to have a great time and ate lots of new and exciting foods! Pictures to come. Today is the 19th yahrzeit for my father. 19 years, Sometimes it stuns me how fast time actually goes by. More suprising is how many wonderful things that have happened in that time that I think would have made him proud. |
| comment (0) | Ari Turetzky | permanent link |
| Lucky Kid |
|---|
|
Weight: 205
Workout: 20 Minute Walk Just took a 20 Minute walk today. I don't think the weather will cooperate with the walk at lunch. The sushi seems to have punched the weight up again. I think next week I will try to run once or twice. I will probably need to to drop whatever I pick up at the fair. I have decided that the next time someone tells me it's easier to install windows than linux I will just kill them. I am building Jennifer's new machine and it really astounds me what it takes to install windows. First, I had to reformat the drive so that the installer could read the disk. Apparently it did not understand the ext3 and reiserfs partitions that were already on the disk enough to ask if I wanted to delete them. Then, there was the applying of service packs, download and install drivers, updates, more updates, last round of updates. I think in all it was about 4 hours and at least 7 reboots. And that is just for the OS! The last install of Gentoo linux I did took 45 minutes start to finish. At the end of that 45 minutes I had a fully installed system that was up to date with all patches. Additionally, the linux kernel had drivers for all of my hardware, they were detected and adding the neccessary modules to the kernel took about 10 seconds. Windows failed to recognize any of the nforce chipsets on the motherboard. If only quicken ran on linux even under wine. Sigh. Update: I can now search for and edit blogs with my blogging mode |
| comment (0) | Ari Turetzky | permanent link |
| Happiness Runs |
|---|
|
Weight: 203
Workout: None Slept in today. I got up at 2:30 and 3:00 with a teething owen. I had trouble getting back to sleep and when I finally got to sleep I slept til almost 6:00 My regular thursday lunch partners are both out today so I will go for a walk at lunch to make up for the missed workout. |
| comment (2) | Ari Turetzky | permanent link |
| Just testing some blogging features |
|---|
|
This is mostly just a test of some features of blog.el. I may even delete it. If I have time this weekend I think I have found a way to get this to pull up past entries for editing. However I don't think it will be cross platform because it uses grep. |
| comment (0) | Ari Turetzky | permanent link |
| Too Old to Rock and Roll |
|---|
|
Weight: 203
Workout: 20 Minutes Climber Did 20 on the climber this morning. The scale dropped to 202.8 then settled at 203.0 this morning. So I'm pretty close. As long as it doesn't rain and I can go for a walk tomorrow I should be close by Friday. Cecilia said something funny last night. She does not go to sleep easily. And when she woke up for the third time last night I went up to get her back in bed. She met me at the top of the stairs, I picked her up and she gave me a big hug. I carried her to her room and she said "I don't understand people who just get in bed and go to sleep." This was also funny because I heard her say "I don't have time to sleep" earlier on the monitor. She's just a very very VERY busy person. |
| comment (0) | Ari Turetzky | permanent link |
| Numb As A Statue |
|---|
|
Weight: 205
Workout: 20 Minute Walk Got to the gym a little late. Walked for 20 and headed in to work. Not sure what the weather is going to do. Looked like it might rain. If it isn't I'm going to go for a walk at lunch too. |
| comment (0) | Ari Turetzky | permanent link |
| The Winner Takes It All |
|---|
|
Weight: 206
Workout: 20 Minutes Bike Just did the bike today. I think the weight is the result of turtle bars and barbecue. I had a pretty big dinner last night. I'll make sure I drink enough water and see what tomorrow brings. I started the build on Jennifers new computer. When I left it last night the XP installer was apparently reading every block on the disk before letting me install. I'll see where it is when I get home. It was a great weekend. Cecilia and Owen helped with breakfast both days. We played alot. Jennifer and I went and saw Pericles at the Shakespeare festival. I got to buy computer equipment for Jen's computer(really much better than a ring). All in all not a bad weekend! |
| comment (0) | Ari Turetzky | permanent link |
| Hyper-Trackback Conversation pinging idea |
|---|
|
I don't comment on blogs much. And when I do I almost always fail to follow up and see if there was a response. The main reason for this is that I use an aggregator to track blogs and changes to them. I do not know of an aggregator that tracks comment additions. My thought this afternoon was that it would be really nifty if there was a mechanism like trackback pinging that would notify people of responses etc. to comments left at blogs, and in somecases across blogs. For those who don't know a trackback is a method supported by some blogs that allows a blogger to create an entry that "pings" back to the original blog with an abstract that appears as a comment. This gets part of the way there for what I was thinking. My idea would be to have some mechanism that once there was some linking via comments/trackbacks etc in blogs there would be a way to view the entire discussion. So for instance a blogger blogs. People comment. Other's trackback. People comment on the blogs that have tracked back, and so on. Add to this sites like reddit.com, digg, slashdot etc. Now there is an entire discussion that has, or is, taking place out there that is disjointed. My idea would be to provide a mechanism whereby that discussion could be presented in one place. I realize that actually creating something like that would be of a scope so massive that it really isn't possible but still it would be cool. I also know that the end result of this would be flamewars of ridiculous proportions. But this could be the next Web 2.0™ Übersite. |
| comment (0) | Ari Turetzky | permanent link |
| World Go'round |
|---|
|
Weight: 203
Workout: 20 Minute Walk My sinuses seem to still be draining a bit. Other than that I'm feeling pretty good. It looks like it is going to be a nice day today and I should be able to go for a walk. Most likely I will be walking over to Parking Services to make them cancel the ticket they wrote me on Wednesday. In more geekier news I was able to get emacs to compile on windows yesterday. It seems that cygwin is not up to the task. MinGW and the gnuWin32 projects are required. It really wasn't to bad of project. Mostly just had to download the gnuwin packages of some unix tools and checkout emacs from cvs. It requires doing a make bootstrap which takes some time. I started yesterday when I left work and this morning this is the message I saw: GNU Emacs 22.0.50.1 (i386-mingw-nt5.1.2600) of 2006-08-03 on SYS270307. Pretty sweet! |
| comment (1) | Ari Turetzky | permanent link |