Archive for category General

Cross-browser Async File Upload

rename extension to 7z

i’ve had this post locked for years and decided to make it public. i wrote a sample to do async file uploads which took a great deal of research but never got around to writing an article for it. up above you’ll see a link to a png, download it and then rename it to 7z. 7z is a file archive much like a zip file. you’ll need to extract the file with 7zip or something like it. the sample is inside. one day ill just host the file somewhere else…

,

Leave a comment

C#: Escape Double-quote within a String

Problem

When you need to add a double-quote character to a string, you will run into a problem. Double-quotes are the delimiters for the beginning and end of a string, so placing a double-quote within a string will confuse the compiler and it will give you an exception.

Solution

Read the rest of this entry »

Leave a comment

C#: Escape Curly Braces within Formatted String

Problem

When passing in a formatted string as an argument to a method such as Console.WriteLine, String.Format, etc., curly braces have a special meaning. They are used as a placeholder for a variable. Therefore when you want to add a curly brace within the formatted string, but you don’t want it to be interpreted as a placeholder for a variable, you have a problem.

Solution

Read the rest of this entry »

Leave a comment

Dynamic Code/Class Generation (Update)

Overview
Back not to long ago, I released a post dealing with the dynamic generation of classes at run-time. Since then I have applied the concepts shown in that post in my real-world projects. As expected of any new code, I have found several bugs and inconveniences with the original code from that post. This time around I have an updated CodeGenerationHelper class, a DynamicFactory class, and an actual example of how to use the generated objects. The download-able version of the sample can be obtained through this link: http://thrash505.webs.com/DynamicCodeGeneration.zip

Read the rest of this entry »

, , , , , , ,

15 Comments

C# CodeGenerationHelper – Dynamic Classes – Create Class From Hashtable at Run-time

UPDATE
This post has been depreciated, for an updated version please visit: https://thrash505.wordpress.com/2010/03/18/dynamic-codeclass-generation-update/

Overview
Back a few months ago I had a class that needed (or so I thought) to be generated at run-time. The need arose from WPF controls only working with Properties, not fields, and more specifically ones that implemented INotifyPropertyChanged. (or dependency properties, but I typically save those for custom controls) After some research I created a simple straightforward helper class, CodeGenerationHelper, that would create a dynamic class at run-time from a hashtable. From a hashtable because my solution was working with data received through XML-RPC in the from of an extended hastable implementation. (XmlRpcStruct)

Read the rest of this entry »

, , , , ,

6 Comments

C# Array Casting

Problem

I’ve found myself in the situation where I have an array of objects that I want to cast into an array of some other type. You’d think that this would be as simple as: (TheType[])objectArray, but unfortunately, one way or another, you have to loop through each object and cast it into the new type. This becomes a pain when you need to do it frequently.

Read the rest of this entry »

, ,

1 Comment