October 23, 2007 19:57 by
dgood
I am America (And So Can You!) - One word: Hilarious. Technically, that's three.
Yes, I'm still alive. I've been very busy lately. I jacked up the radiator cap on my Jeep and I've been busy putting a new Jeep under it.
ProgrammingGoody, you say? Blog about software, eh?
How's this: Boxing and Unboxing in C# can be tricky operations for the inexperienced or uninformed.
Example:
struct Point
{
int X;
int Y;
public Point(int x, int y){ X=x; Y=y; }
public void Move(int x, int y){ X = x; Y=y; }
}
public static void main(string args[])
{
Point p = new Point(0, 0); // value type
ArrayList arr = new ArrayList(); // only holds reference types
arr.Add(p); // Box it
((Point)arr[0]).Move(5, 5); // Unbox it
Console.WriteLine("Point: {0}", arr[0]);
}
When the Point struct is unboxed, the pointer to the boxed Point on the managed heap is used to copy the values from the heap into a new instance of a Point value type on the stack. In effect, there are now two separate instances of Point - one on the stack and one on the heap. Using Point in this manner will not lead to the desired outcome.
The same mechanism applies to any value type stored as a boxed reference. (Hint: think Session state)
This one's for you, Classic Colin.
Cheers.
Be the first to rate this post
- Currently 0/5 Stars.
- 1
- 2
- 3
- 4
- 5
June 27, 2007 20:41 by
dgood
As you can see the conversion to Subtext is complete. All in all it was fairly simple and went as smooth as I could have hoped.
I haven't looked at any source code but I'm impressed with the functionality and how well it works out of the box. It needs a little polish, but it's an impressive app for a zero dot something build. My hat is off to the Subtext team, I think you've put together a nice app.
There is this one dig I have to make, however. I switched from Wordpress 2.0 and there is no "simple" way to convert the data. I did search the Subtext forums on Sourceforge and found a thrown-together app to export Wordpress data to BlogML format for importing using the built-in Subtext import feature. I understand it would be difficult if not impossible to create and maintain converters for every other blog platform out there.
So, I'm working on a Wordpress to Subtext direct convert app. So far, it's been pretty simple. The data structures map fairly nicely. My hope is to make it available by this weekend as a simple Windows app to do straight MySQL to SQL data conversions, skipping the XML export. From there I'd like to make it flexible enough to support multiple versions of Wordpress, and from there I'd like to add a feature for advanced users to drag-and-drop map the data structures if the app can't figure them out.
Why all this work for a simple one-time-use converter? I dunno. Something to keep me occupied and fiddling around with non work-related code.
The last thing I'll say about it is that I'm posting this from Firefox 2.0 on my Mac. It works fine in Safari with the exception of the HTML editor. Mac functionality is one of the main reasons I chose it over dasBlog - sorry Hanselman dasBlog looks terrible in Safari. Other than that it's a peach in FF.
Cheers.
Be the first to rate this post
- Currently 0/5 Stars.
- 1
- 2
- 3
- 4
- 5