Skip to Content
.NET Framework Security
book

.NET Framework Security

by Brian A. LaMacchia, Sebastian Lange, Matthew Lyons, Rudi Martin, Kevin T. Price
April 2002
Intermediate to advanced
816 pages
20h 56m
English
Addison-Wesley Professional
Content preview from .NET Framework Security

Declarative and Imperative Security

As you can see, there are several different uses of permissions in the .NET Framework. Because of the wide range of uses, there are two different ways to express security actions: declaratively and imperatively. Listing 6.2 shows the same permission demand expressed in both forms.

Listing 6.2. Declarative and Imperative Forms of the Same Permission Demand
// Declarative form
[FileIOPermission(SecurityAction.Demand, Read=@"C:\Payroll.doc")]
public void MyMethod()
{
}

// Imperative form
public void MyMethod()
{
  new FileIOPermission(FileIOPermissionAccess.Read, @"C:\Payroll.doc").Demand();
}

The primary difference between imperative and declarative forms of security actions is that declarative forms are stored ...

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

Programming .NET Security

Programming .NET Security

Adam Freeman, Allen Jones
Pro C# 7: With .NET and .NET Core

Pro C# 7: With .NET and .NET Core

Andrew Troelsen, Philip Japikse
.Net Framework Essentials

.Net Framework Essentials

Thuan L. Thai, Hoang Lam

Publisher Resources

ISBN: 067232184XPurchase book