Thursday, December 27, 2007

.NET serialization

Automatic Serialization:
Reflection use metadata exposed by every.NET component. Swrialies the object state into a stream. A stream is a logical sequence of bytes. The various stream types provided by .NET all derive from the abstract class Stream, in the System.IO namespace. By default the user-defined tyoe aren't serializable. [Serializable],[NonSerialized]

Thursday, December 13, 2007

ASP.NET Request Processing

ASP.NET request processing is based on a pipeline model in which ASP.NET passes http requests to all the modules in the pipeline. Each module receives the http request and has full control over it. The module can play with the request in any way it sees fit. Once the request passes through all of the HTTP modules, it is eventually served by an HTTP handler. The HTTP handler performs some processing on it, and the result again passes through the HTTP modules in the pipeline. During the processing of a http request, only one HTTP handler will be called, whereas more thatn one HTTP modules can be called.

Tuesday, December 11, 2007

Working with .NET Events

New term --- The object publishing the event is called the publisher, and the any party interested in the event is called a subscriber.

Delegate based Events

a delegate is nothing more than a type safe method reference,

public delegate void NumberChangedEventHandler(int number)

This delegate can be used to call any method with a matching signature, the name of method and the name of parameter are not important, but you have to have the same signature.

Here is example:

public delegate void NumberChangedEventHander(int number);

public class MyPublisher
{
public NumberChangedEventHander NumberChanged;
}
public class MySubscriber : Page
{
public void OnNumberChanged(int number)
{
string mes = "New value is " + number ;
}
}


UI call the delegate:

MyPublisher publisher = new MyPublisher();
MySubscriber subscriber1 = new MySubscriber();
MySubscriber subscriber2 = new MySubscriber();
publisher.NumberChanged += new NumberChangedEventHander(subscriber1.OnNumberChanged);
publisher.NumberChanged += new NumberChangedEventHander(subscriber2.OnNumberChanged);
publisher.NumberChanged(3);

,NET Request Pipeline

a request enters the pipeline, it handled by an instance of the HttpApplicaton class.
IHttpHandler interface the ProcessRequest method. the main work of a handler implementation goes.
The ProcessRequest method pass the param. HttpContext

.NET Re

Tuesday, December 4, 2007

the different between an abstract class and an interface

an abstract class can still have implementation. an interface can't have implementation or member variables.

a.net class can derive from only one base class, even if that base class is abstract. However, a .net class can implement as many interfaces as required.

an abstract class can derive from any other class or from one or more interfaces.

an abstract class can have nonpublicc methods and prperties, even if they are all abstract. In an interface, by definition, all members are public.

an class can have static methods and static members and can define constants. an interface can have none of those.

an abstract class can have constructors. an interface can't

Requirements for an asynchronous call

1)the component code should be used for both synchronous and asynchronous invacations
2)the client shuld be the one to decide whethere to call a component sychronously or asynchronously.
3)the client is able to issue multiple asynchronous calls and have multiple asynchronous calls in progress.
4)the component should be able to serve multiple concurrent calls

There are

Manage Connection pool

.net managerd providers manage the connection pool for us, using shared database connection. We can control the size of connection pool in connection string, for example:

const string connString = "server=localhost;" +
"uid=scott;" +
"pwd=tiger;" +
"database=Northwind;" +
"Min Pool Size=3;" +
"Max Pool Size=3";

What's that mean and what happened behind the scenes. When SqlConnection.Open() was called, the manager provider instantiatied an internal calls called SqlConnectionProolManger and invoked its GetpooledConnection method, passing into it the connection string. The pool manager examined all current pools to see if there was one that used a connection string that exactly matched the one it was given