Tuesday, October 11, 2005

Monday, October 10, 2005

Saturday, September 03, 2005

clone object in dotnet

private static void TestClone()
{
Person p1 = new Person();
p1.Age = 26;
p1.UserName = "yyanghhong";

Person p2 = (Person)CloneObjectEx(p1);
p2.UserName = "unruledboy";

Console.WriteLine(p1.UserName);
Console.WriteLine(p2.UserName);
}

public static Person CloneObject(Person ObjectInstance)
{
BinaryFormatter bFormatter = new BinaryFormatter();
MemoryStream stream = new MemoryStream();
bFormatter.Serialize(stream, ObjectInstance);
stream.Seek(0, SeekOrigin.Begin);
Person newObject = (Person)bFormatter.Deserialize(stream);
return newObject;
}

public static object CloneObjectEx(object ObjectInstance)
{
BinaryFormatter bFormatter = new BinaryFormatter();
MemoryStream stream = new MemoryStream();
bFormatter.Serialize(stream, ObjectInstance);
stream.Seek(0, SeekOrigin.Begin);
return bFormatter.Deserialize(stream);
}

[Serializable]
public class Person
{
private int age;
private string userName;

public Person()
{
}

public int Age
{
get{return age;}
set{age = value;}
}
public string UserName
{
get{return userName;}
set{userName = value;}
}
}

Google Code

Google Code

Thursday, April 21, 2005

InternalsVisibleTo in c#2.0

It is a very useful attribute, especially good for unit test. but it will lead to some security issue, it is better to adopt strong name or add conditional constants to restrict it.

Monday, March 28, 2005

Friday, March 25, 2005

How the Runtime Locates Assemblies

How the Runtime Locates Assemblies

Design for Performance vs. Tune for performance

Design for Performance vs. Tune for performance

There are some good points inside this article, I like using agile methods to deal with performance tuning, it requires a detailed unit testing case, and an agile way to amend the code, such as adopting AOP methods to put some business rules and logic into configuation file for ignoring re-compiling.

Tuesday, March 15, 2005

Mainsoft, Visual MainWin for the J2EE platform

Mainsoft, Visual MainWin for the J2EE platform
Visual MainWin brings the C# and Visual Basic .NET programming languages to the Java platform, enabling more than 2.5 million Microsoft-skilled developers to quickly and efficiently develop J2EE Web applications and Web services. it sounds too good to be true.

Monday, March 14, 2005

XenoCode 2005

XenoCode 2005
A good dotnet obfuscation tools, it supports a very nice feature of taking several assemblies and obfuscating them into one single assembly

Sunday, February 13, 2005