(Lviv community of .NET developers)

Recent posts

Полезные сслки - Part 8

August 31, 2009 12:51 by alexk

Building .NET coverage tool

http://www.codeproject.com/KB/cs/dot-net-coverage.aspx
Отличный обзор и реализация/использование NCover.
Для тех кто не знает что такое Code Coverage:
http://en.wikipedia.org/wiki/Code_coverage ... >>>

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Корисне розширення функціоналу Snoop'а

July 30, 2008 17:22 by rredcat
Будь-хто грається з WPF повинен був стикатись з такою чудовою тулзою для дабагання візуального вигляду рантайм як Snoop. Та на мою думку дечого їй не вистачало.
... >>>

Currently rated 5.0 by 2 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

TCP ports forwarding, tunneling, proxies

April 21, 2008 11:32 by alexk
Hi Everyone,

Today I want to share a small piece of code that demonstrate TCP Sockets usage in .NET.

This is not very advanced example of sockets programming, but at the same time it show a lot of technics that you can use in programming, like:
- debugging of the windows services
- async sockets
- async operations and there synchronization
- events used for service controlling
- registry access
- advanced tracing/logs
- and etc.

Introduction

The idea was to write a simple TCP proxy class that will help us to forward ports (or better to say create a tunnel) from one source to destination.

In my case I want to use this functinality to open direct access to my computer in network shown below (ADSL modem connected by lan to the Vista computer; Vista publich AdHoc connection to the other computer Windows Xp. I setup service on Vista PC that helps me to open port directly for the Windows XP computer!!!):


In more simple way it's looks like this (configuration for testing):

... >>>

Currently rated 5.0 by 4 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Cache results with duration

January 18, 2008 15:15 by alexk
This time I want to show how to implement simple cache with duration interval. For it implementation were used generics and anonymous delegate C# features. Class is very simple but power that it give us is unmeasurable.
In real life this class is designed for DB oriented applications. It allowiing to cache long time taken operations results of which has long time of life. Enjoy.

... >>>

Currently rated 4.0 by 1 people

  • Currently 4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Полезные ссылки - Part 5

December 18, 2007 11:48 by alexk

C# Pivot Table By felipesabino

Так называемый поворот таблички на 90 градусов с групировкой...
http://www.codeproject.com/KB/recipes/CsharpPivotTable.aspx
... >>>

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: Performance | .NET | QA | General | WinForms | Links | ASP.NET
Actions: Permalink | Comments (0) | RSSRSS comment feed

Hierarchy data on DB layer

October 2, 2007 01:56 by alexk

Hierarchy data on DB layer

Simple ways

ParentId-to-ChildId

  1. define primary key in table
  2. define ParentRef column that has the same data type as primary key has and allowed NULL;
ID Data ParentRef
1 some data NULL
2 node1 1
3 node11 2
4 node2 1

Pluses:

  • easy to implement
  • good structure where data accessed level by level;

Minuses:

  • very complex queries for data extracting; implementation of query "extract node and all it childs" become very complex;

Separator

  1. define separator that can not be used by user
ID Name
1 ArtfulBits
2 ArtfulBits.Test
3 ArtfulBits.Test.Data
4 ArtfulBits.Samples

Pluses:

  • easy to implement
  • easy to extract node and it childs

Minuses:

  • some times is very hard to define seprator
  • growing of Name column value can become a problem if required deep hierarchy;

Combination

  1. define primary key in table
  2. define ParentRef column that has the same data type as primary key has and allowed NULL;
  3. define special index column varchar()
ID Name ParentRef Index
1 node1 NULL NULL
2 node2 1 0001
33 node21 2 0001-0002
4 node211 33 0001-0002-0033
5 node22 2 0001-0002
99 nodeN 33 0001-0002-0033

Pluses:

  • combination of performance and DB space usage
  • easy to extract data in any suitable way

Minuses:

  • required DB trigger on table for update and delete operations

Example

Separator is "/" char. Used 4 (four) chars for index key storage;

CREATE TABLE Articles  
(  
  -- article tree-hierarchy  
  [ArticleID]        [int]             IDENTITY (1, 1)   NOT NULL ,  
  [ArticleParentRef] [int]                               NOT NULL ,  
  [ArticleNodeKey]   [nvarchar](100)                     NULL ,  
  -- article parts  
  [ArtTitle]         [nvarchar](200)                     NULL ,  
  [ArtShortText]     [nvarchar](600)                     NULL ,  
  [ArtText]          [nvarchar](2000)                    NULL ,  
  [ArtTextFormat]    [varchar] (10)                      NULL ,  
  -- article references  
  [ArtUserRef]       [int]                               NULL ,  
  [ArtBlogRef]       [int]                               NULL ,  
  [ArtLanguage]      [varchar] (4)                       NULL ,  
  [ArtTime]          [datetime]                          NULL ,  
    
  CONSTRAINT [PK_Articles] PRIMARY KEY CLUSTERED   
  (  
    [ArticleID] ASC 
  )  
)  
 
GO  
 
CREATE function dbo.fnGetArticleNodeKey( @ID int )  
  returns nvarchar(500)  
as 
begin 
  declare   
    @Key nvarchar(500),   
    @SubKey nvarchar(10),   
    @ParentID int 
 
  select @Key = N'' 
 
  while( @ID is not NULL )  
  begin 
    select @ParentID = ArticleParentRef from Articles where ArticleID = @ID  
 
    set @SubKey = N'/' + right( replicate( '0', 3 ) + cast( @ID as nvarchar( 6 ) ), 4 )  
      
    if( charindex( @SubKey + N'/', @Key ) <> 0 )  
      return NULL 
      
    set @Key = @SubKey + @Key 
    set @ID = @ParentID  
  end 
 
  return @Key 
end 
 
GO  
 
CREATE TRIGGER tg_Articles_NodeKey  
  ON dbo.Articles  
  FOR INSERTUPDATE 
AS BEGIN 
  if TRIGGER_NESTLEVEL( @@PROCID ) = 1  
  begin 
      
    if update( ArticleID ) or update( ArticleParentRef ) or update( ArticleNodeKey )  
    begin 
      
      update Articles set   
        ArticleNodeKey = dbo.fnGetArticleNodeKey( ArticleID )  
      where isNull( ArticleNodeKey, '' ) <> isNull( dbo.fnGetArticleNodeKey( ArticleID ), '' )  
 
      if exists( select * from Articles where ArticleNodeKey is NULL )   
      begin 
        raiserror( 'Recursion in Tasks', 16, 1 )  
        rollback tran  
        return 
      end 
    end 
  end 
END 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Render, Arrange и Measure механизмы в WPF

September 14, 2007 07:03 by rat

Есть в WPF пару забавных механизмов, которые не так уж и хорошо описаны в нете - это рендеринг, компоновка и измерение.
Про них и я буду писать некоторые свои познания. (думаю будет полезно почитать особенно тем, кого интересует вопрос производительности програмного обеспечения написанного на WPF)

... >>>

Currently rated 4.8 by 4 people

  • Currently 4.75/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags: , ,
Categories: Performance | WinFx
Actions: Permalink | Comments (2) | RSSRSS comment feed

Обнаружение и предотвращение утечек памяти в управляемом коде

September 10, 2007 07:49 by RredCat

автор: Джеймс Ковач (James Kovacs)

 

В статье рассматривается:

·         Понятие об утечках памяти в управляемых приложениях.

·         Использование неуправляемой памяти в приложениях .NET.

·         Помощь сборщику мусора .NET в его работе.

... >>>

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags: , ,
Categories: Performance | .NET
Actions: Permalink | Comments (3) | RSSRSS comment feed

Developers Issues

September 5, 2007 12:55 by alexk
Сегодня в результе профайлинга нашел один интересный исью: сам исью в .NET Framework классе, а точнее в XmlSchemaCollection.

При добавлении в коллекцию схемы (XmlSchema), она компилируется независимо от того, была ли она скомпилирована до этого или нет.

А поскольку процесс компиляции штука крайне небыстрая, а экземпляр XmlValidatingReader повторно работать с другими данными не умеет, то это приводит к тому, что схема компилируется при парсинге каждого xml-документа.

гы. я надеюсь понятно изъясняюсь :)

Affected runtime: 1.1, 2.0
(дальше не проверял, но скорее всего исью будет в 3.0 и 3.5)

Workaround:
кешировать экземпляр XmlSchemaCollection с добавленной схемой/схемами (а не экземпляры XmlSchema).
... >>>

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Categories: .NET | General | Performance
Actions: Permalink | Comments (0) | RSSRSS comment feed