Monday, November 21, 2005

Design Pattern Links

Patterns Non-Software Examples of Software Design Patterns -AGCS:
http://www2.ing.puc.cl/~jnavon/IIC2142/patexamples.htm

Pattern Diagrams
http://home.earthlink.net/~huston2/dp/all_uml.html

All the patterns that you can find in anywhere
http://patternshare.org/default.aspx/Home.AllPatterns

Patterns with C# examples
http://www.dofactory.com/Patterns/Patterns.aspx

Howto list large tables in a database

This example lists all the tables, bigger than 10 MB, in a database

CREATE TABLE #temp (name varchar(50),rows int,reserved varchar(50),data varchar(50),index_size varchar(50),unused varchar(50))
DECLARE @tablename varchar(50)
DECLARE tabels_cursor CURSOR FOR SELECT NAME FROM sysobjects WHERE type='U'
OPEN tabels_cursor
FETCH NEXT FROM tabels_cursor INTO @tablename
WHILE @@FETCH_STATUS = 0
BEGIN
INSERT INTO #temp EXEC sp_spaceused @tablename
FETCH NEXT FROM tabels_cursor INTO @tablename
END
CLOSE tabels_cursor
DEALLOCATE tabels_cursor
SELECT * FROM #temp WHERE LEN(reserved)>7
DROP TABLE #temp

Friday, August 12, 2005

Getting the screen handle of a window


[DllImport("USER32.DLL", SetLastError=true)]
private static extern uint FindWindow (string lpClassName, string lpWindowName);

private IntPtr GetScreenHandle(string windowTitle){
uint handle= FindWindow(null,windowTitle);
IntPtr screenHandle= new IntPtr(handle);
return screenHandle;
}

Friday, May 27, 2005

Reading attributes of an assembly in .NET

In System.Reflection namespace are assembly attribute classes. Here is a sample for one of those. You can try the same with the other attributes you want to read.

Assembly executingAssembly=Assembly.GetExecutingAssembly();
AssemblyCopyrightAttribute copyright=AssemblyCopyrightAttribute.GetCustomAttribute(executingAssembly,typeof(AssemblyCopyrightAttribute)) as AssemblyCopyrightAttribute; System.Console.WriteLine(copyright.Copyright);

Custom attributes defined on the assembly can be read using the same way.