-
-
If you are looking at this, you probably did a Google to find out why the Timespan object is not serialize when you are using the XMLSerializer from the .NET platform.
Yes, it's right. It is not serialize, and there is no way to serialize it. But there is many workaround. The more elegant one that I found is from Kenneth Xu.
http://kennethxu.blogspot.com/2008/09/xmlserializer-doesn-serialize-timespan.html
It consist of (kinka) overriding the property by one that can be serialized.
-f.
-
-
Basically, add a HTTPModule that will add a filter on the Response Stream. A couple of lines and a web application 4 times faster.
http://www.microsoft.com/belux/msdn/nl/community/columns/desmet/compression.mspx
-f.
-
-
The basic way to do a Plugin Framework, is to use a AppDomains, because you can Load & Unload AppDomains. But, how can you communicate easily between them?
Here is a generic way (a way that use generics...!) to do it, using the singleton design pattern.
http://www.dolittle.com/blogs/einar/archive/2007/05/18/cross-appdomain-singleton.aspx
But, you might want to do more, like compile on demand, dynamic load, caching, calling without knowing what's inside etc. On the famous Code Project, Bob Amand wrote an excellent article on how to use a plugin framework.
http://www.codeproject.com/KB/cs/dynamicpluginmanager.aspx
For sure, this is the way to do it...
-f.
-
-
I already posted a way to truncate log, so that they do not grow indefinitly.
Here a little routine found on the Mark Brown's Blog. A generic way to truncate all the log files.
See the disclaimer it's important.
http://blogs.msdn.com/mab/archive/2008/01/26/how-to-backup-and-truncate-all-log-files-in-a-database.aspx
declare @sqlstring nvarchar(1024)
SET @sqlstring='use ?;DBCC SHRINKFILE (?, TRUNCATEONLY);DBCC SHRINKFILE (?_log, TRUNCATEONLY);BACKUP LOG ? WITH TRUNCATE_ONLY;DBCC SHRINKFILE (?_log, TRUNCATEONLY);';
SELECT @sqlstring;
exec master.dbo.sp_MSforeachDB @command1=@sqlstring
-f.
-
-
A simple Clipboard.SetData using the Clipboard.SetDataObject(obj, true); method is not enough to copy HTML to the Clipboard using C#.
I found a method from Tommy Carlier, that is doing exactly what I want, but this trim the first letters/html tags. Why?
The HTML Fragment method used inside this function is using the encoding GetByteCount method. This method count every single character, so, a \r\n (Environment.NewLine) is a count of two, and ... guess what, when pasting that into the clipboard, Windows count it as a single character, but only for the HTML content part of the pasted text.
So, the resulting function is
Encoding lEncoding = Encoding.UTF8;
string begin = "Version:0.9\r\nStartHTML:{0:000000}\r\nEndHTML:{1:000000}"
+ "\r\nStartFragment:{2:000000}\r\nEndFragment:{3:000000}\r\n";
string html_begin = "<html>\r\n<head>\r\n"
+ "<meta http-equiv=\"Content-Type\""
+ " content=\"text/html; charset=" + lEncoding.WebName + "\">\r\n"
+ "<title>HTML clipboard</title>\r\n</head>\r\n<body>\r\n"
+ "<!--StartFragment-->\r\n";
string html_end = "<!--EndFragment-->\r\n</body>\r\n</html>\r\n";
int count_begin = lEncoding.GetByteCount(begin);
int count_html_begin = lEncoding.GetByteCount(html_begin);
int count_html = lEncoding.GetByteCount(html);
int count_html_end = lEncoding.GetByteCount(html_end);
string html_total = String.Format(
begin
, count_begin
, count_begin + count_html_begin + count_html + count_html_end
, count_begin + count_html_begin - (html_begin.Split(Environment.NewLine.ToCharArray()).Length)
, count_begin + count_html_begin - (html_begin.Split(Environment.NewLine.ToCharArray()).Length) + count_html - (html.Split(Environment.NewLine.ToCharArray()).Length)
) + html_begin + html + html_end;
DataObject obj = new DataObject();
obj.SetData(DataFormats.Html, new System.IO.MemoryStream(lEncoding.GetBytes(html_total)));
Clipboard.SetDataObject(obj, true);
-f.