Monday, November 21, 2005

Design Pattern Links

Patterns Non-Software Examples of Software Design Patterns -AGCS:

Pattern Diagrams

All the patterns that you can find in anywhere

Patterns with C# examples

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
INSERT INTO #temp EXEC sp_spaceused @tablename
FETCH NEXT FROM tabels_cursor INTO @tablename
CLOSE tabels_cursor
DEALLOCATE tabels_cursor
SELECT * FROM #temp WHERE LEN(reserved)>7

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.