13.07.2015 Views

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

B<strong>in</strong>aryWriter writer = new B<strong>in</strong>aryWriter(fs);writer.Write(img);writer.Close();TipWhen convert<strong>in</strong>g a Bitmap object to JPEG, you can control thecompression ratio to obta<strong>in</strong> a better image. However, JPEG is not acompression scheme designed <strong>for</strong> text and simple figures like barcharts. In fact, JPEG was orig<strong>in</strong>ally designed to effectively compressphotographic images. To ensure a better image, you might want touse the GIF <strong>for</strong>mat or control the compression ratio of the f<strong>in</strong>al JPEGimage. You can do that by us<strong>in</strong>g one of the overloads of the Bitmapobject's Save method.Us<strong>in</strong>g the System.Activator ClassA remot<strong>in</strong>g client can obta<strong>in</strong> a proxy to make calls to a remote object <strong>in</strong> two ways: byus<strong>in</strong>g the new operator or by us<strong>in</strong>g methods of the System.Activator class. TheActivator class provides two methods—CreateInstance and GetObject. Clients of wellknownobjects use GetObject, whereas clients of client-activated objects useCreateInstance.GetObject returns a proxy <strong>for</strong> the well-known type served at the specified URL location,as shown <strong>in</strong> the follow<strong>in</strong>g code. GetObject is a wrapper placed around the globalRemot<strong>in</strong>gServices.Connect method. The proxy is built on the client from the remoteobject metadata and exposed to the client application as the orig<strong>in</strong>al type.ServiceSalesProvider ssp;ssp = (ServiceSalesProvider) Activator.GetObject(typeof(ServiceSalesProvider),"http://www.contoso.com/SalesReport");From this relatively simple explanation, it should be clear that .<strong>NET</strong> Remot<strong>in</strong>g is no lessquirky than DCOM, but unlike DCOM, the .<strong>NET</strong> Framework successfully hides a greatwealth of low-level details.CreateInstance differs from GetObject <strong>in</strong> that it actually creates a new remote <strong>in</strong>stanceof the object, as shown here:// Set the URL of the remote objectobject[1] attribs;attribs[0] = new Activation.UrlAttribute(url);// Create the <strong>in</strong>stance of the objectServiceSalesProvider ssp;ssp = (ServiceSalesProvider) Activator.CreateInstance(typeof(ServiceSalesProvider), null, attribs);ConclusionThe .<strong>NET</strong> Remot<strong>in</strong>g system enables you to access .<strong>NET</strong> Framework objects across theboundaries of AppDoma<strong>in</strong>s. It represents the actual implementation of a programm<strong>in</strong>g452

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!