Skip to Main Content
C# Cookbook, 2nd Edition
book

C# Cookbook, 2nd Edition

by Jay Hilyard, Stephen Teilhet
January 2006
Intermediate to advanced content levelIntermediate to advanced
1184 pages
43h 23m
English
O'Reilly Media, Inc.
Content preview from C# Cookbook, 2nd Edition
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Controlling Access to Types in a Local Assembly
|
947
Note that as long as the CompanyData object was accessible, you could have also writ-
ten this to access the object directly:
// Instantiate the CompanyData object directly without a proxy.
CompanyData companyData = new CompanyData( );
// Read some data.
Console.WriteLine("CEOPhoneNumExt: " + companyData.CEOPhoneNumExt);
// Write some data.
companyData.AdminPwd = "asdf";
companyData.AdminUserName = "asdf";
// Save and refresh this data.
companyData.SaveNewData( );
companyData.RefreshData( );
If these two blocks of code are run, the same fundamental actions occur: data is read,
data is written, and data is updated/refreshed. This shows you that your proxy
objects are set up correctly and function as they should.
Discussion
The proxy design pattern is useful for several tasks. The most notable—in COM,
COM+, and .NET remoting—is for marshaling data across boundaries such as
AppDomains or even across a network. To the client, a proxy looks and acts exactly the
same as its underlying object; fundamentally, the proxy object is just a wrapper
around the object.
A proxy can test the security and/or identity permissions of the caller before the
underlying object is created or accessed. Proxy objects can also be chained together
to form several layers ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

C# Cookbook

C# Cookbook

Joe Mayo
C# Cookbook

C# Cookbook

Stephen Teilhet, Jay Hilyard
Head First C#, 4th Edition

Head First C#, 4th Edition

Andrew Stellman, Jennifer Greene

Publisher Resources

ISBN: 0596100639Supplemental ContentCatalog PageErrata